Problem Pinging hosts with IP address through a port

I’ve installed Nagios on Ubuntu 8.04 for the first time. Nagios 3.0.6 and Nagios Plugins 1.4.13.

I have multiple access points that I need to monitor on various sites and so I looked at Nagios and am giving it a try.

Nagios installed successfully and I configured one of my local managed switches to be monitored by pinging it regularly and it worked fine.

I tried configuring a remote AP at another site with a WAN IP and port number and in the nagios web interface it gives me the following error:

“check_ping: Invalid hostname/address - 68.15.135.213:60003”

Unfortunately I don’t have a site-to-site VPN setup yet so I can’t just configure it with local host private IPs and have to configure my remote routers with port forwarding for each AP behind it. But it doesn’t look like Nagios supports this. If Nagios does, that would be awsome and any direction on how to go about this would be great.

Here’s the configuration of my “/usr/local/nagios/etc/objects/switch.cfg”:

Define the switch that we’ll be monitoring

define host{
use generic-switch ; Inherit default values from a template
host_name smcswitch ; The name we’re giving to this switch
alias smcswitch ; A longer name associated with the switch
address 68.15.135.213:60003 ; IP address of the switch
hostgroups switches ; Host groups this switch is associated with
}

Create a service to PING to switch

define service{
use generic-service ; Inherit values from a template
host_name smcswitch ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 1 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}

You don’t ping a port number… You ping a host…
A host in Nagios never has a port number…
(Edit: A service can have port numbers, not a host)

If you have multiple NAT’d hosts, accessible only via portmap, you have two options…
[list]]Set a custom host check command to probe the service that’s on the port in question instead of using ping…/:m]
]Ignore the host status and just check the port as a service…/:m][/list:u]
Ie. If port 60003 is an HTTP service, then you could use check_http with the relevant settings to use port 60003 instead of 80 as the host check…

Myself, I just have the NAT device (firewall/router) pingable and rely on the service checks for host alive status.

Thanks for the data.

I get what you’re saying.

How do you create a custom host check command to probe the service that’s on the port in question instead of using ping?

Can’t find the answer readily elsewhere.

Thanks.

Object Definitions … Specifically, the “check_command”, here you can override the default command (ping) for something else…

isn’t check_tcp enough?

Usage:check_tcp -H host -p port -w ] -c ] -s ]

[quote=“luca”]isn’t check_tcp enough?

Usage:check_tcp -H host -p port -w ] -c ] -s ][/quote]

If you’re doing check_tcp, you might as well do check_http if you’re doing it against an HTTP port - as they’re pretty much the same, except the latter understands HTTP. Depends on your semantics - either would rely on the HTTP server (if it was an HTTP server for example) being alive.

uhm i missed something i ssuspect. :slight_smile: if it is an http server it’s better for sure.