18. 11. 2009 Patrick Zambelli Unified Monitoring

Monitoraggio avanzato Microsoft SQL Server

Esistono ormai vari Plugin Nagios che controllano la disponibilita’ e la reazione di un Database Server Microsoft. Un progetto con lo scopo di andare pero’ oltre questo monitoraggio e stato implementato e pubblicato sotto licenza GPL da un partner Nagios in Germania.

Questo plugin, sviluppato in Perl, permette di estrarre e analizzare piu’ di 20 metriche da un SQL Server, tra cui sempre i classici come memoria libera, cpu utilizzata, utenti collegati, ma anche transazioni/sec, richieste batch/sec, tempi di attesa per Latches, lock requests e anche tanto altro.

In aggiunta di tutto questo permette anche di eseguire direttamente query che ritornano valori singoli, interpretabili direttamente e da validare con le soglie di warning e critical definite.
Proprio questa attivita’ e’ stata svolta per un cliente per controllare il numero di transazioni, presenti in forma di elementi in una tabella, dentro il DB.

Il primo step consiste nell’installazione dei requisiti per poter stabilire la connessione vero un Database SQL remoto: FreeTDS.
Sono scaricabili le sorgenti e le istruzioni dal sito http://www.freetds.org/.
Moduli aggiuntivi Perl da installare sono inoltre:
– perl-DBD-ODBC
– perl-DBD-Pg
– perl-DBD-Sybase
– perl-DBI

Una volta soddisfatti i requisiti si puo’ procedere di scaricare il plugin gia’ configurato per NetEye direttamente qui: check_mssql_health o accedere per scaricare direttamente le sorgenti del check_mssql_health al sito del progetto.

Il plugin va copiato ( nel primo caso ) nella cartella dei plugin di Nagios ( /usr/lib/nagios/plugins per Neteye ) o altrimenti installando con i commandi comuni ./configure, make e make install.

La sintassi di utilizzo puo’ essere richiamata utilizzando l’argomento –help e le descrizioni sono molto dettagliate.
Qui di seguito vorrei illustrare solo velocemente l’estratto delle metriche gia’ incorporate:

the mode of the plugin. select one of the following keywords:
connection-time                  (Time to connect to the server)
cpu-busy                         (Cpu busy in percent)
io-busy                          (IO busy in percent)
full-scans                       (Full table scans per second)
connected-users                  (Number of currently connected users)
transactions                     (Transactions per second (per database))
batch-requests                   (Batch requests per second)
latches-waits                    (Number of latch requests that could not be granted immediately)
latches-wait-time                (Average time for a latch to wait before the request is met)
locks-waits                      (The number of locks per second that had to wait)
locks-timeouts                   (The number of locks per second that timed out)
locks-deadlocks                  (The number of deadlocks per second)
sql-recompilations               (Re-Compilations per second)
sql-initcompilations             (Initial compilations per second)
total-server-memory              (The amount of memory that SQL Server has allocated to it)
mem-pool-data-buffer-hit-ratio   (Data Buffer Cache Hit Ratio)
mem-pool-data-buffer-hit-ratio   (Data Buffer Cache Hit Ratio)
lazy-writes                      (Lazy writes per second)
page-life-expectancy             (Seconds a page is kept in memory before being flushed)
free-list-stalls                 (Requests per second that had to wait for a free page)
checkpoint-pages                 (Dirty pages flushed to disk per second. (usually by a checkpoint))
database-free                    (Free space in database)
backup-age                       (Elapsed time (in hours) since a database was last backupped)
sql                              (any sql command returning a single number)
list-databases                   (convenience function which lists all databases)
list-datafiles                   (convenience function which lists all datafiles)
list-locks                       (convenience function which lists all locks)

Il nostro esempio prosegue, come indicato all’inizio, con l’implementazione di una query che ritorna un numero singolo interpretabile dal plugin.

La query esegue il count dei risultati presenti dentro una tabella definita. Seguendo questo principio si potrebbero pero’ implementare anche check che interpretano valori da singoli campi, estraggono massimali e minimi da intere colonne etc.

Commando Nagios che andiamo a chiamare “check_mssql_health”:
$USER1$/check_mssql_health –hostname=$HOSTNAME$ –username=$USER5$ –password=$USER5$ -t 15  –mode=sql –name=”$ARG1$” –warning=$ARG2$ –critical=$ARG3$

L’implementazione del servizio “MSSQL TRANSACTIONS” ha poi questa forma:
check_mssql_health!select Count(*) AS Tmp FROM dbo.GCAcrTestataTransazioneTRG!100!1000

Un run del check sul server SQL avrebbe poi un risultato come illustrato da questa videata:

LINKS:

Tutorial (inglese) molto utile per l’installazione e configurazione del freeTDS e dei moduli Perl:
http://www.perlmonks.org/?node_id=392385

Il sito del progetto FreeTDS:
http://www.freetds.org/

Il progetto del Plugin Nagios (inglese):
http://labs.consol.de/lang/en/nagios/check_mssql_health/;
Link diretto per il download

Patrick Zambelli

Patrick Zambelli

Project Manager at Würth Phoenix
After my graduation in Applied Computer Science at the Free University of Bolzano I decided to start my professional career outside the province. With a bit of good timing and good luck I went into the booming IT-Dept. of Geox in the shoe district of Montebelluna, where I realized how a big IT infrastructure has to grow and adapt to quickly changing requirements. During this experience I had also the nice possibility to travel the world, while setting up the various production and retail areas of this company. Arrived at Würth Phoenix I started developing on our monitoring solution NetEye. Today, in my position as Consulting an Project Manager I am continuously heading to implement our solutions to meet the expectation of your enterprise customers.

Author

Patrick Zambelli

After my graduation in Applied Computer Science at the Free University of Bolzano I decided to start my professional career outside the province. With a bit of good timing and good luck I went into the booming IT-Dept. of Geox in the shoe district of Montebelluna, where I realized how a big IT infrastructure has to grow and adapt to quickly changing requirements. During this experience I had also the nice possibility to travel the world, while setting up the various production and retail areas of this company. Arrived at Würth Phoenix I started developing on our monitoring solution NetEye. Today, in my position as Consulting an Project Manager I am continuously heading to implement our solutions to meet the expectation of your enterprise customers.

Leave a Reply

Your email address will not be published. Required fields are marked *

Archive