Page 1 of 1

Need to use something other than ping command for host up

Posted: Mon Sep 09, 2024 10:12 am
by cjstgreen
Hello,
I am brand new to Nagios. Inherited what was set up and working from someone left left. Now ping has been disabled by IT and all hosts are showing down. In the host definition, the check command is currently blank. Can I use something other than ping to check if host is up or down? Can I use curl? Is there a curl command already or is this something I'd need to create? Has anyone else had to use something other ping and how did you resolve this? FYI, the Nagios server is on Linux and the clients are a mix of Windows and Linux. Not sure if that matters. Thanks for your patience in help with a rookie.
Tim

Re: Need to use something other than ping command for host up

Posted: Mon Sep 09, 2024 11:50 am
by gregbeyer
Hi Tim, yes, there is a curl check plugin, check_curl, documentation below.

To use it,
- Go into CCM, create a new command, and craft a command line, using the options you need, below. Apply config.
- Then in CCM, go to Services, and create a new service, and select that new command as your check command. Set all the other check and notification parameters as appropriate. Apply config.
- You test it with Run Check Command button at bottom.
-When it works to your liking, you would apply the Service to Hosts, or Hostgroups or Servicegroups (Common Settings tab) that you want checked with this monitor.

There is a lot of "Zen" in creating a new check, but that's the outline of it.


------- check_curl.php written by Vit Safar (CZ), v1.0, 20.10.2006 ---------
------------------- modified by Donald Fellow (US), v1.1, 08.06.2007 ---------
------------------- modified by Ryan Snyder (US), v1.2, 14.04.2011 ---------
------------------- modified by Miguel Calvo (ES), v1.3, 26.06.2018 ---------
------------------- modified by Tatsuya Morikawa (JP), v1.4, 9.06.2020 ---------


Syntax:
-Me Protocol (Custom string for request. Available protocols: HTTP, FTP, IMAP, POP3 and SMTP)
-U URL (s)
-A Agent (s)(default: Mozilla/5.0 ... )
-a Authentication (s)(example: '[user]:[password]')
-ao Authentication method to use (example: 'CURLAUTH_DIGEST')
-G Search that the indicated text exist on the page (can be set multiple times)
-NG Search that the indicated text not exist on the page (can be set multiple times)
-Gn Number of apparitions of Grep
-he Any other tags to be sent in http header. Use multiple times for additional headers (example: 'X-Requested-Auth: Digest')
-L Show page (-)
-F Follow redirects (-)
-I Ignore SSL certificate errors (-)
-X Exclude performance data (default: include)
-Tc Critical page return time (i)
-Tw Warning page return time (i)
-Sbc Critical page size below SIZE (i)
-Soc Critical page size over SIZE (i)
-Sbw Warning page size below SIZE (i)
-Sow Warning page size over SIZE (i)
-S Find string between ARG1 and ARG2, return first match (s s) (example: value=" " )
-T Timeout (i)(default: 10sec)
-O Output Driven Check - Page Should respond with "Status: OK" or otherwise
-hc HTTP expected code (default: 200)
-tag Tag to identify the check in the return message
-Px Set proxy to use
-PxPort proxy port
-PxAuth User name and password to use for proxy authentication


Example:
check_curl.php -U http://test.example.net

Incidentally, to see ALL of the plugins that you could use in a command, in the new command window, click the "available plugins" to scroll thru the whole list. Select one to see the documentation for it.

Re: Need to use something other than ping command for host up

Posted: Mon Sep 09, 2024 1:12 pm
by cjstgreen
Thank you very much for the reply. I am confused about the content of the check_curl.php file. Where do I download that plugin from?

Also, I thought I would try the command from our Nagios server to the Window client, but seems like the http syntax does not work. I get the error shown below. However, if I do a curl telnet command, it is successful. I was looking through the arguments for the syntax and don't see an option to use telnet. Can I use this check_curl command with the syntax I need? I would assume that there is a firewall preventing http to work. The team responsible for opening firewall ports have already told us that we can't get any exceptions to allow ping, so I would assume same will be true with port for http.

curl http://<ip address>:5693
curl: (56) Recv failure: Connection reset by peer


curl -v telnet://<ip address>:5693
* About to connect() to 10.233.96.139 port 5693 (#0)
* Trying 10.233.96.139...
* Connected to 10.233.96.139 (10.233.96.139) port 5693 (#0)

Re: Need to use something other than ping command for host up

Posted: Mon Sep 09, 2024 1:39 pm
by snapier3
I have used check_tcp to test availability of remote access/management ports on the target endpoint as an alternative to icmp or agent.

Windows 3389 for RDP or 5985/5986 for WinRM
Linux/Unix port 22 to SSH
check_tcp.PNG
Happy Monitoring!
--SN

Re: Need to use something other than ping command for host up

Posted: Tue Sep 10, 2024 8:25 am
by cjstgreen
Thank you so much for the suggestions. I have had some success using check_tcp. But it only works the first time after I restart Nagios services (systemctl restart ncpa) on the client. After that, I get a message that says unknown host. If I restart Nagios services again, it will work and can connect, but then will fail next time.

Below is the syntax of the check_curl command:
curl -v telnet://<ip address>.139:5693


Below is the error I see in the Nagios dashboard:
avelp3523v10.av.ge.com (10.233.232.80)

Re: Need to use something other than ping command for host up

Posted: Tue Sep 10, 2024 9:24 am
by snapier3
Below is the syntax of the check_curl command:
curl -v telnet://<ip address>.139:5693
Port 5693 is for NCPA (Nagios Cross Platform Agent), if you do not have the agent installed it's not going to respond on that port.

Try this for Windows
curl -v telnet://<ip address>:3389

Linux
curl -v telnet://<ip address>:22

--SN