Monitoring Windows 2008 Scheduled Tasks

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Monitoring Windows 2008 Scheduled Tasks

Post by WillemDH »

Hello,

I've had a really hard time today trying to monitor WIndows 2008 scheduled tasks. Is there anyone here who got some experience with this?
I've been looking on http://www.nsclient.org/nscp/wiki/Check ... _tasksched for more information, but it seems like there is some infor missing.

nsclient.ini:

[/modules]
CheckTaskSched1 = 1
CheckTaskSched2 = 1

[root@srvnagios01 ~]# /usr/local/nagios/libexec/check_nrpe -H testserver -t 30 -c CheckTaskSched -p 5666 -a "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=\>0
OK: All scheduled tasks are good.|'eventlog'=0;0;0

While there is at least one scheduled task that hasn't got a status code of 0.
i thought the problem could be that I use the checktasksched1 or so, but

/usr/local/nagios/libexec/check_nrpe -H testserver -t 30 -c CheckTaskSched2 -p 5666 -a "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=\>0
No handler for command: checktasksched2

So he doesn't seem to know checktasksched2..

Any help is welcome..
Nagios XI 5.8.1
https://outsideit.net
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Monitoring Windows 2008 Scheduled Tasks

Post by lmiltchev »

Can you post the whole "nsclient.ini" file (hide the sensitive info)?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Monitoring Windows 2008 Scheduled Tasks

Post by WillemDH »

Hello,

We solved this problem bij creating a powershell script that outputs it's result to Nagios. Works much better then the checktasksched2 in the nscp software.

For people who are interested, this is the powershell script:

Code: Select all

 

#Scheduled Task Result powershell script

$status = 0;

#First, the script will pull a list of all the scheduled tasks on your computer and push it into a CSV file.
schtasks /query /fo csv -v | ConvertFrom-Csv | ? {$_.HostName -match "^$($Env:Computername)$" -and $_.'Scheduled Task State' -eq "Enabled" -and $_.TaskName -notlike '\Microsoft*' } | % {
	if ($_."Last Result" -ne "0") {
		echo "Scheduled task $($_.TaskName) exited with result $($_.'Last Result')"
		$status = 2
	}
}

if ($status -eq 0) {
	echo "All OK"
}
exit $status

Nagios XI 5.8.1
https://outsideit.net
yancy
Posts: 523
Joined: Thu Oct 06, 2011 10:12 am

Re: Monitoring Windows 2008 Scheduled Tasks

Post by yancy »

WilliemDH,

Thanks for posting your Powershell script.

It would be a useful addition to exchange.nagios.org if you have a chance to post it there.

Thanks,

-Yancy
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Monitoring Windows 2008 Scheduled Tasks

Post by WillemDH »

Posted on Exchange. Waiting for approval.
Nagios XI 5.8.1
https://outsideit.net
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitoring Windows 2008 Scheduled Tasks

Post by scottwilkerson »

Thanks!
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked