import groovy.sql.Sql
sql = Sql.newInstance(
"jdbc:sqlserver://localhost;databaseName=msdb",
"sa",
"sa",
"com.microsoft.sqlserver.jdbc.SQLServerDriver")
// SQL Serverに関する統計情報を取得
sql.query("exec sp_monitor") { rs ->
stmt = rs.getStatement()
while(true){
try
{
rset = stmt.getResultSet()
while(rset.next()){
md = rset.getMetaData();
for(ci=1;ci<=md.getColumnCount();ci++){
println(md.getColumnName(ci) + ":" + rset.getString(ci))
}
}
}
finally
{
try { rset.close() } catch(Exception sqlex){}
}
if( stmt.getMoreResults() == false )break;
}
}
動作環境
Groovy 1.6.3, JDK6 Update14, SQL Server JDBC Driver 2.0,
SQL Server 2008 Express
関連情報
sp_monitor
http://msdn.microsoft.com/ja-jp/library/ms188912.aspx
実行結果例
last_run:2009-08-19 23:56:59.003
current_run:2009-08-19 23:57:24.437
seconds:25
cpu_busy:7(0)-0%
io_busy:4(0)-0%
idle:1119(24)-96%
packets_received:307(6)
packets_sent:585(6)
packet_errors:0(0)
total_read:3142(0)
total_write:127(1)
total_errors:0(0)
connections:80(1)
0 件のコメント:
コメントを投稿