mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-22 18:33:45 +01:00
Added --queryfile and --namefromfile parameters
This commit is contained in:
parent
b27defe0a7
commit
07d6692aa7
@ -2877,6 +2877,8 @@ my @params = (
|
|||||||
"database=s",
|
"database=s",
|
||||||
"datafile=s",
|
"datafile=s",
|
||||||
"waitevent=s",
|
"waitevent=s",
|
||||||
|
"namefromfile=s",
|
||||||
|
"queryfile=s",
|
||||||
"name=s",
|
"name=s",
|
||||||
"name2=s",
|
"name2=s",
|
||||||
"regexp",
|
"regexp",
|
||||||
@ -2923,6 +2925,11 @@ if ($commandline{mode} eq "encode") {
|
|||||||
exit $ERRORS{OK};
|
exit $ERRORS{OK};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!exists $commandline{queryfile} || !$commandline{queryfile}) {
|
||||||
|
$commandline{queryfile} = "/etc/nagios/check_mssql_health-queries";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (exists $commandline{3}) {
|
if (exists $commandline{3}) {
|
||||||
$ENV{NRPE_MULTILINESUPPORT} = 1;
|
$ENV{NRPE_MULTILINESUPPORT} = 1;
|
||||||
}
|
}
|
||||||
@ -2978,6 +2985,34 @@ if (exists $commandline{runas}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exists $commandline{namefromfile}) {
|
||||||
|
if (!open QF, "<$commandline{queryfile}") {
|
||||||
|
print "Unable to open queryfile $commandline{queryfile} param --queryfile\n";
|
||||||
|
print_help();
|
||||||
|
exit $ERRORS{OK};
|
||||||
|
}
|
||||||
|
|
||||||
|
my $sql = '';
|
||||||
|
while (my $l = <QF>) {
|
||||||
|
# Double chomp if needed
|
||||||
|
chomp($l) for (0..1);
|
||||||
|
|
||||||
|
my ($k, $sql_line) = split(/\s*=\s*/, $l);
|
||||||
|
|
||||||
|
if ($k eq $commandline{namefromfile}) {
|
||||||
|
$sql = $sql_line;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close QF;
|
||||||
|
|
||||||
|
if (!$sql) {
|
||||||
|
print "Unable to find namefromfile key $commandline{namefromfile} in file $commandline{queryfile}\n";
|
||||||
|
exit $ERRORS{OK};
|
||||||
|
}
|
||||||
|
$commandline{name}=$sql;
|
||||||
|
}
|
||||||
|
|
||||||
if ($needs_restart) {
|
if ($needs_restart) {
|
||||||
my @newargv = ();
|
my @newargv = ();
|
||||||
my $runas = undef;
|
my $runas = undef;
|
||||||
|
Loading…
Reference in New Issue
Block a user