check_snmp_win not working for some service/host

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
Sky
Posts: 4
Joined: Wed Sep 26, 2018 6:43 am

check_snmp_win not working for some service/host

Post by Sky »

Hello.
I have a problem with check_snmp_win.pl (http://nagios.proy.org/snmp_windows.html). When i put this in a host file, it's not working but when i launch it directly it's working.

Code: Select all

./check_windows_service -H host -C community -n "Apache Tomcat for BI 4"
1 services active (matching "Apache Tomcat for BI 4") : OK
The service is up on the Windows server.

The same check working for an another host. And for this host i check CPU, RAM and Disk with SNMP and it's working well. I check if there is a control character or something i can't see but not. I try to rewrite all the service on a new file and same thing happen.

You can see bellow the configuration of the command and the service.
Command definition :

Code: Select all

define command{
        command_name    check_windows_service
        command_line    $USER1$/check_windows_service -H $HOSTADDRESS$ -C $ARG1$ -n $ARG2$
        }
Service definition :

Code: Select all

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       host
        service_description             S-Services Apache Tomcat for BI 4
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           5
        retry_check_interval            2
        contact_groups                  
        notification_options            w,c,r
        notification_interval           960
        notification_period             journee-ouvrable
        check_command                   check_windows_service!community!"Apache Tomcat for BI 4 "
        }
Have you an idea of what can happened?
Thanks
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check_snmp_win not working for some service/host

Post by mcapra »

Sky wrote:When i put this in a host file, it's not working but when i launch it directly it's working.
Can you share exactly what Nagios Core outputs when you attempt to put it in a host file? This is incredibly useful information for troubleshooting.

Did you run this command as root?

Code: Select all

./check_windows_service -H host -C community -n "Apache Tomcat for BI 4"
1 services active (matching "Apache Tomcat for BI 4") : OK
Typically, Nagios Core does not execute things as root; It executes them as whatever user you provided when you installed Nagios Core (by default, the nagios user). Can you run this command again as your Nagios Core system user (by leveraging su,runuser, or whatever command is appropriate for your operating system) and share the output:

Code: Select all

/full/path/to/your/check_windows_service -H host -C community -n "Apache Tomcat for BI 4"
Former Nagios employee
https://www.mcapra.com/
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_snmp_win not working for some service/host

Post by ssax »

Does your SNMP community have any special characters in it?

Does it work as the nagios user as mcapra suggested?

Code: Select all

su - nagios
/usr/local/nagios/libexec/check_windows_service -H host -C community -n "Apache Tomcat for BI 4"
Sky
Posts: 4
Joined: Wed Sep 26, 2018 6:43 am

Re: check_snmp_win not working for some service/host

Post by Sky »

Does your SNMP community have any special characters in it?
No only alphanumeric characters
Can you share exactly what Nagios Core outputs when you attempt to put it in a host file? This is incredibly useful information for troubleshooting.

Code: Select all

No services matching "Apache Tomcat for BI 4" found : CRITICAL 
Did you run this command as root?
Yes.

I will try do launch it with the nagios user.
Sky
Posts: 4
Joined: Wed Sep 26, 2018 6:43 am

Re: check_snmp_win not working for some service/host

Post by Sky »

Does your SNMP community have any special characters in it?
No, only alphanumeric character
Can you share exactly what Nagios Core outputs when you attempt to put it in a host file? This is incredibly useful information for troubleshooting.

Code: Select all

 	
S-Services Apache Tomcat for BI 4	CRITICAL 	27-09-2018 10:23:10 	1d 0h 1m 17s 	3/3 	No services matching "Apache Tomcat for BI 4" found : CRITICAL 
Did you run this command as root?
Yes

Below the result of the command launch as nagios user :

Code: Select all

 ./check_windows_service -H host -C communauty -n "Apache Tomcat for BI 4"
1 services active (matching "Apache Tomcat for BI 4") : OK
Sky
Posts: 4
Joined: Wed Sep 26, 2018 6:43 am

Re: check_snmp_win not working for some service/host

Post by Sky »

I just find what's wrong.
I put a wrong IP when i declared the host and it explain everything.

You can close this thread.
Sorry for this.
Locked