How to monitor Windows Scheduled Tasks?
Natxo Asenjo
natxo.asenjo at gmail.com
Tue Jun 30 14:49:31 CEST 2009
hi,
ok, but I do not have any time to support the script, it is supplied
'as is' without license or obligations on my part. I will not answer
any questions about why it is not working for you (in case it does not
work for you).
#!perl
use strict;
use warnings;
use diagnostics;
# first run schtasks /query /fo /list /v and dump everything to a file
open (JOBS, "schtasks /query /fo list /v |") or die "couldn't exec
schtasks: $!\n";
# Counters
my $count = 0;
my @count = ();
# parse file, if string Last Result is not 0 (success), croak
while (<JOBS>) {
if (/^Last Result:\s+(.*)$/) {
# count how many jobs there are, we'll use this later
$count++;
# By type
$count[$1]++;
}
}
close JOBS;
if ($count[1]) {
warn "WARNING: problem with $count[1] scheduled jobs\n";
exit 1;
}
if ($count[0] == $count) {
warn "OK: all scheduled tasks have run fine\n";
exit 0;
}
else {
# if there is something wrong, give unkonw and errolevel 3
warn "UNKONWN: something else went wrong\n";
exit 3;
}
__END__
--
Groeten,
J.Asenjo
------------------------------------------------------------------------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list