add sqlserver input plugin

This commit is contained in:
root 2016-01-15 21:39:43 +01:00
parent 963a9429dd
commit 37e5af4cff
4 changed files with 1200 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import (
_ "github.com/influxdb/telegraf/plugins/inputs/redis" _ "github.com/influxdb/telegraf/plugins/inputs/redis"
_ "github.com/influxdb/telegraf/plugins/inputs/rethinkdb" _ "github.com/influxdb/telegraf/plugins/inputs/rethinkdb"
_ "github.com/influxdb/telegraf/plugins/inputs/sensors" _ "github.com/influxdb/telegraf/plugins/inputs/sensors"
_ "github.com/influxdb/telegraf/plugins/inputs/sqlserver"
_ "github.com/influxdb/telegraf/plugins/inputs/statsd" _ "github.com/influxdb/telegraf/plugins/inputs/statsd"
_ "github.com/influxdb/telegraf/plugins/inputs/system" _ "github.com/influxdb/telegraf/plugins/inputs/system"
_ "github.com/influxdb/telegraf/plugins/inputs/trig" _ "github.com/influxdb/telegraf/plugins/inputs/trig"

View File

@ -0,0 +1,27 @@
# SQL Server plugin
This sqlserver plugin provides metrics for your SQL Server instance.
It currently works with SQL Server versions 2008+.
Recorded metrics are lightweight and use Dynamic Management Views supplied by SQL Server:
```
Performance counters : 1000+ metrics from sys.dm_os_performance_counters
Performance metrics : some special performance metrics
Wait stats : list of wait tasks categorized from sys.dm_os_wait_stats
Memory clerk : memory breakdown from sys.dm_os_memory_clerks
Database size : database size trend, data and log file from sys.dm_io_virtual_file_stats
Database IO : database I/O from sys.dm_io_virtual_file_stats
Database latency : database reads and writes latency from sys.dm_io_virtual_file_stats
CPU : cpu usage from sys.dm_os_ring_buffers
```
You must create a login on every instance you want to monitor, with following script:
```SQL
USE master;
GO
CREATE LOGIN [telegraf] WITH PASSWORD = N'mystrongpassword';
GO
GRANT VIEW SERVER STATE TO [telegraf];
GO
GRANT VIEW ANY DEFINITION TO [telegraf];
GO
```

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
package sqlserver
import (
"testing"
"github.com/influxdb/telegraf/testutil"
"github.com/stretchr/testify/require"
)
func TestSqlServerGeneratesMetrics(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
s := &SqlServer{}
s.Servers = append(s.Servers, &Server{ConnectionString: "Server=192.168.1.30;User Id=linuxuser;Password=linuxuser;app name=telegraf;log=1;"})
var acc testutil.Accumulator
err := s.Gather(&acc)
require.NoError(t, err)
}