Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_mssql_sproc

Rating
2 votes
Favoured:
0
Hits
108304
Files:
FileDescription
check_mssql_sproc.plcheck_mssql_sproc.pl
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
This script will connect to an MS SQL server, run a stored procedure, and alert based on the results. NOTE: Tested and works on Windows. Should work on *nix, unable to test right now
From the Help file:

Usage: check_mssql_sproc.pl -H HOSTNAME -p PROCEDURE -u user -P password -w -c


check_mssql_sproc.pl 1.01
Copyright (c) 2005 Jeremy D. Pavleck
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


-p, --procedure

Stored procedure to execute

-H, --hostname

Hostname of database server

-d --database

Database to run Stored Procedure against

-u, --user

SQL Username

-P, --password

SQL Password

-c, --critical

Value at which when met or exceeded will send a critical alert

-w, --warning

Value at which when met or exceeded (but is lower then critical value) will send a warning alert.

-h, --help

Display detailed help

-v, --version

Show version information

This program will connect to a remote MS SQL server, execute a stored procedure, and then process the results
to determine if there is an error state or not.
Currently it only works if the stored procedure returns a single result in one column. It has not been tested
to work with any other result sets; There is currently a sister script which DOES handle these things, as well as
boolean and word results. It should be available shortly.
Additional Notes & Tips: If you don't wish to have your SQL passwords exposed to the world you can do one of two
things - 1. Set $USERx$ in resource.cfg to the password - this will be passed to the program by Nagios, but will
not be visible from the web console or 2. If you have a universal SQL login for all of your Nagios queries, then
you may hardcode the username & password into the beginning of this script.


Reviews (2)
I made an update in the original code, because it works with procedures that only return one column, but does not allow parameters and doesn't work if the procedure returns more than one column. With this update the procedure must return the first column as an int (procedure return) called "retorno".

More info:
https://github.com/brunocantisano/check_mssql_sproc_parameters

This plugin helped me a lot, so I had to update the code as a thanking way. :)
Thanks Jeremy D. Pavleck (the original author)
bydcoote, April 19, 2011
I must admit I haven't tested thoroughly but I did wrestle for hours before finding out.

A quick change is required to make this work on *nix systems. Damn case sensitive.

For *nix systems
$conn{"dsn"} = "dbi:ODBC:Driver={SQL Server};SERVER=" . $conn{"server"};

Should read
$conn{"dsn"} = "dbi:ODBC:DRIVER={SQL Server};SERVER=" . $conn{"server"};