Re: Check MS SQL Stored Procedure
Posted: Wed Sep 06, 2017 9:06 am
Sounds good. Keep us posted.
Support for Nagios products and services
https://support.nagios.com/forum/
Code: Select all
/check_mssql_sproc_parameters.pl -H sqldev_digitallog -u DigitalLogNagios -P fsanw_54d -d digital_log_d -p "dbo.uspDgtlGetErrorLogs @DgtlLogMinutes = 999999, @DgtlLogSourceId = 16, @DgtlLogLevel = 4" -w 1 -c 2
DBI connect('Driver=MySQL;SERVER=sqldev_digitallog;PORT=4000','DigitalLogNagios',...) failed: [unixODBC][MySQL][ODBC 5.1 Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 104 (SQL-08S01) at ./check_mssql_sproc_parameters.pl line 72
Error: Unable to connect to MS-SQL database!
[unixODBC][MySQL][ODBC 5.1 Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 104 (SQL-08S01)
Code: Select all
[root@nagios libexec]# ./check_mssql.php --hostname 1.1.1.1 --username username --password password --port 1443 --database database --query "EXEC some_sp @field1=2815, @field2=76;"
OK: Query duration=0.023742 seconds. Query result=2815 Query result=09 Query result=4.2199999999999998 Query result=45.5 Query result=3.9780000000000002 Query result=0 Query result=4.2199999999999998 Query result=3.9780000000000002 Query result=89 Query result=1 Query result=1 Query result=1 Query result=1|query_duration=0.023742s;Code: Select all
yum -y install telnet
telnet digitallog 4000
Code: Select all
check_mssql -H sqldev_digitallog --username DigitalLogNagios --password fsanw_54d --port 4000 --database digital_log_d --query "dbo.uspDgtlGetErrorLogs @DgtlLogMinutes = 999999, @DgtlLogSourceId = 16, @DgtlLogLevel = 4"
UNKNOWN: Invalid characters in the hostname.Code: Select all
check_mssql -H x.x.x.x --username DigitalLogNagios --password fsanw_54d --port 4000 --database digital_log_d --query "dbo.uspDgtlGetErrorLogs @DgtlLogMinutes = 999999, @DgtlLogSourceId = 16, @DgtlLogLevel = 4"
OK: Query duration=0.035074 seconds.|query_duration=0.035074s;;Code: Select all
// Validate the hostname
if (isset($db_host)) {
if (!preg_match("/^([a-zA-Z0-9-]+[\.])+([a-zA-Z0-9]+)$/", $db_host)) {
print "UNKNOWN: Invalid characters in the hostname.\n";
exit(3);
}
} else {
print "UNKNOWN: The required hostname field is missing.\n";
exit(3);
}
Code: Select all
[root@nagios ~]# /usr/local/nagios/libexec/check_mssql.php --hostname 1.1.1.1 --username username --password password --port 1443 --database database --query "EXEC some_sp @field1=2815, @field2=76;"
OK: Query duration=0.18552 seconds. Query result=2815 Query result=09 Query result=4.2199999999999998 Query result=45.5 Query result=3.9780000000000002 Query result=0 Query result=4.2199999999999998 Query result=3.9780000000000002 Query result=89 Query result=1 Query result=1 Query result=1 Query result=1|query_duration=0.18552s;
[root@nagios ~]# /usr/local/nagios/libexec/check_mssql.php --hostname somehost --username username --password password --port 1443 --database database --query "EXEC some_sp @field1=2815, @field2=76;"
OK: Query duration=0.029853 seconds. Query result=2815 Query result=09 Query result=4.2199999999999998 Query result=45.5 Query result=3.9780000000000002 Query result=0 Query result=4.2199999999999998 Query result=3.9780000000000002 Query result=89 Query result=1 Query result=1 Query result=1 Query result=1|query_duration=0.029853s;
It's actually designed to be valid hostname charsmcapra wrote:It's actually hard-wired to look for IP addresses exclusively:
Code: Select all
// Validate the hostname if (isset($db_host)) { if (!preg_match("/^([a-zA-Z0-9-]+[\.])+([a-zA-Z0-9]+)$/", $db_host)) { print "UNKNOWN: Invalid characters in the hostname.\n"; exit(3); } } else { print "UNKNOWN: The required hostname field is missing.\n"; exit(3); }
https://en.wikipedia.org/wiki/HostnameHowever, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted. While a hostname may not contain other characters, such as the underscore character (_), other DNS names may contain the underscore.