Hello Team,
I have stored MSSQL credentials in the resource.cfg file and tried to call those macros in the check_mssql plugin but it does not seems to be working.
resource.cfg entries
---------------------------
$USER30$=Domain\USSQL
$USER31$=Cr$d3nt1a10#&&
Command:
/usr/local/nagios/libexec/check_mssql -H server1.domain.com --username '$USER30$' --password '$USER31' --database master --query "SELECT+COUNT%28%2A%29+FROM+sys.sysperfinfo" --result "Expected result" --decode --warning 50 --critical 200
it does working when passing clear text password without domain name.
Command:
/usr/local/nagios/libexec/check_mssql -H server1.domain.com --username 'USSQL' --password 'Cr$d3nt1a10#&&' --database master --query "SELECT+COUNT%28%2A%29+FROM+sys.sysperfinfo" --result "Expected result" --decode --warning 50 --critical 200
CRITICAL: CRITICAL: Query expected "Expected result" but got "2389".
Any help on this? I would really need to perform this check with $USER$ macros!
check_mssql $USER$ macro problem
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: check_mssql $USER$ macro problem
It seems to be working great, other than you are telling it to expect a result of "Expected result" with --result "Expected result". You should change the text in quotes to a number or string that you are actually expecting. It seems to be returning 2389 for example.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: check_mssql $USER$ macro problem
Actually you are missing the second $ sign in $USER31$
sureshkraj2012 wrote: /usr/local/nagios/libexec/check_mssql -H server1.domain.com --username '$USER30$' --password '$USER31' --database master --query "SELECT+COUNT%28%2A%29+FROM+sys.sysperfinfo" --result "Expected result" --decode --warning 50 --critical 200
Former Nagios employee
-
sureshkraj2012
- Posts: 65
- Joined: Tue Aug 06, 2013 11:06 pm
Re: check_mssql $USER$ macro problem
No. That's not a problem. (Missed $ only in the post).
The below part might be the issue since its validating username and password.
I think I should comment it and try
// Validate the username
if (isset($db_user)) {
if (!preg_match("/^[a-zA-Z0-9-]{2,32}$/", $db_user)) {
print "UNKNOWN: Invalid characters in the username.\n";
exit(3);
}
} else {
print "UNKNOWN: You must specify a username for this DB connection.\n";
exit(3);
}
// Validate the password
if (empty($db_pass)) {
print "UNKNOWN: You must specify a password for this DB connection.\n";
exit(3);
}
The below part might be the issue since its validating username and password.
I think I should comment it and try
// Validate the username
if (isset($db_user)) {
if (!preg_match("/^[a-zA-Z0-9-]{2,32}$/", $db_user)) {
print "UNKNOWN: Invalid characters in the username.\n";
exit(3);
}
} else {
print "UNKNOWN: You must specify a username for this DB connection.\n";
exit(3);
}
// Validate the password
if (empty($db_pass)) {
print "UNKNOWN: You must specify a password for this DB connection.\n";
exit(3);
}
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: check_mssql $USER$ macro problem
You can certainly try commenting those out, however I can almost guarantee that it will break the plugin and cause undefined behavior within the perl script if you attempt to use any other symbols, they are generally escaped\rejected for good reason. I would also note, that you are not getting either of the unknown errors in your output, so I am slightly confused as to why you feel this is the proper portion to remove.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: check_mssql $USER$ macro problem
I think that when you use single quotes around macros they are treated as plain text (i.e. the characters $USER30$ are sent instead of their values).sureshkraj2012 wrote:Command:
/usr/local/nagios/libexec/check_mssql -H server1.domain.com --username '$USER30$' --password '$USER31' --database master --query "SELECT+COUNT%28%2A%29+FROM+sys.sysperfinfo" --result "Expected result" --decode --warning 50 --critical 200
Try using double quotes instead:
Code: Select all
--username "$USER30$" --password "$USER31"As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.