Page 1 of 1

Monitor Service

Posted: Wed Sep 14, 2016 10:05 am
by aajewole
I currently monitor windows server with below command, it works great. But I want to do the the revise. If a service is running, alert us to disable. We do not want Windows Search running on file server. How can I achieve this.

define service{
use generic-service
hostgroup_name ds-exc-mailbox-servers-prod
service_description Microsoft Exchange Mail Submission
check_command check_nt!SERVICESTATE!-d SHOWALL -l "Microsoft Exchange Mail Submission"
}

Re: Monitor Service

Posted: Wed Sep 14, 2016 10:21 am
by rkennedy
You should be able to use the NEGATE plugin to flip the statuses (OK -> CRITICAL, CRITICAL -> OK) -
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

As an example -

Code: Select all

[root@localhost libexec]# ./negate --o=CRITICAL --c=OK ./check_http -H google.com
HTTP OK: HTTP/1.1 301 Moved Permanently - 559 bytes in 0.083 second response time |time=0.083448s;;;0.000000 size=559B;;;0
[root@localhost libexec]# echo $?
2
[root@localhost libexec]# ./negate --o=CRITICAL --c=OK ./check_http -H google.com2
Name or service not known
HTTP CRITICAL - Unable to open TCP socket
[root@localhost libexec]# echo $?
0

Re: Monitor Service

Posted: Wed Sep 14, 2016 12:45 pm
by aajewole
I was able to set up below commands. If I change "Windows Search" to "Windows Update", it works fine. But the issue is, the service I want to monitor is not installed. I want it to show OK when not installed.

define service{
use generic-service
host_name CWWAPP915
service_description Check Service Negate Windows Search
check_command negate_check!"Windows Search"
}

define command{
command_name negate_check
command_line $USER1$/negate $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v SERVICESTATE -d SHOWALL -l $ARG1$
}

$ ./negate --o=CRITICAL --u=OK ./check_nt -H cwwapp915 -p 12489 -v SERVICESTATE -d SHOWALL -l "Windows Search"
Failed to open service Windows Search: 1060: The specified service does not exist as an installed service.

Re: Monitor Service

Posted: Wed Sep 14, 2016 12:54 pm
by aajewole
Got it to work. This can be close.

FIX
define command{
command_name negate_check
command_line $USER1$/negate --o=CRITICAL --u=OK --w=CRITICAL $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v SERVICESTATE -d SHOWALL -l $ARG1$

Re: Monitor Service

Posted: Wed Sep 14, 2016 3:08 pm
by bwallace
Glad to hear you got it working and thanks for posting the fix. I'll go ahead and lock this thread now.