Monitor Service

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
aajewole
Posts: 40
Joined: Fri Aug 12, 2016 11:14 am

Monitor Service

Post 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"
}
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Monitor Service

Post 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
Former Nagios Employee
aajewole
Posts: 40
Joined: Fri Aug 12, 2016 11:14 am

Re: Monitor Service

Post 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.
Attachments
NagiosNegate2.PNG
NagiosNegate.PNG
aajewole
Posts: 40
Joined: Fri Aug 12, 2016 11:14 am

Re: Monitor Service

Post 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$
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Monitor Service

Post by bwallace »

Glad to hear you got it working and thanks for posting the fix. I'll go ahead and lock this thread now.
Be sure to check out the Knowledgebase for helpful articles and solutions!
Locked