Use of $HOSTADDRESS

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
jriker1
Posts: 115
Joined: Tue Dec 15, 2015 8:40 pm

Use of $HOSTADDRESS

Post by jriker1 »

I am curious when someone uses:

command_line $USER1$/check_snmp_printer -H $HOSTADDRESS

in a command definition, how $HOSTADDRESS is resolved? Being on a unix box I know things do not always resolve physical names on the network.

So in my host definition am I supposed to enter the fully qualified domain name there? I have the IP listed as well as "address" but doesn't seem to be working right. Thought that field was just a display name not necessarily the actual machine name.

Here is what I'm doing.

In the printer.cfg:

Code: Select all

define host{
        use             generic-printer         ; Inherit default values from a template
        host_name       Dell_2130cn_Color_Laser ; The name we're giving to this printer
        alias           Dell LaserJet 2130n     ; A longer name associated with the printer
        address         192.168.0.4             ; IP address of the printer
        hostgroups      network-printers        ; Host groups this printer is associated with
        }


define service {
        host_name Dell_2130cn_Color_Laser
        use generic-service
        service_description Yellow2
        check_command check_printer!public!"CONSUM yellow"!20!10

In the command.cfg:

Code: Select all

define command{
        command_name check_printer
        command_line $USER1$/snmp_check_printer -H $HOSTADDRESS -C $ARG1$ -x $ARG2 -w $ARG3$ -c $ARG4$
        }
Output I get is:

Code: Select all

WARNING: No SNMP response from -C! Make sure host is up and SNMP is configured properly
This works manually so thinking the hostaddress isn't being passed as it seems to be using the -C as the device name.

JR
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Use of $HOSTADDRESS

Post by Box293 »

Your problem is that you are missing the $ that goes at the end, it should be $HOSTADDRESS$
jriker1 wrote:So in my host definition am I supposed to enter the fully qualified domain name there? I have the IP listed as well as "address" but doesn't seem to be working right. Thought that field was just a display name not necessarily the actual machine name.
The address directive is what $HOSTADDRESS$ relates to.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jriker1
Posts: 115
Joined: Tue Dec 15, 2015 8:40 pm

Re: Use of $HOSTADDRESS

Post by jriker1 »

Bingo. Thanks. I can run some commands OK manually, but when the definitions are setup, they don't always work like this. Is there anyway to physically see what Nagios executed when the test ran?

Like when I do:

Code: Select all

./snmp_check_printer -H 192.168.0.4 -C public -x "CONSUM yellow"
I get:

Code: Select all

Yellow Cartridge is at 10% - WARNING!
When Nagios runs with the setup in my first post, I get

Code: Select all

UNKNOWN - OID not found! Your printer may not support checking this consumable. Use the CONSUM TEST option to determine which consumables may be monitored. 
Thanks.

JR
jriker1
Posts: 115
Joined: Tue Dec 15, 2015 8:40 pm

Re: Use of $HOSTADDRESS

Post by jriker1 »

Note found the problem in an older post. With authors of the plugins would update things but guess good they have created these at all. Sample from author was missing the end dollar sign after $ARG2. Still like to know if there is a way to see the output of what Nagios ran when it executes these things.

JR
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Use of $HOSTADDRESS

Post by Box293 »

For that level of troubleshooting you would need to enable debug logging in nagios.cfg (-1) and then watch the nagios.debug log file.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Use of $HOSTADDRESS

Post by hsmith »

Not exactly what you're looking for, but you can get a ton of information if you do the following:

Code: Select all

vi /usr/local/nagios/etc/nagios.cfg 
change debug_level=0 to debug_level=-1
service nagios restart
tail -f /usr/local/nagios/var/nagios.debug
Former Nagios Employee.
me.
Locked