Using check_by_shh with --service=service1:service2


#1

I can get check_by_ssh to work fine when it calls a single check. But rather than incur the overhead of multiple ssh invocations, I want to make one call for more than one check.

Here is what happens when I run it from the command line:

TSXUTIL01:/usr/local/nagios/libexec # ./check_by_ssh -H xxx.xxx.31.12 --logname=nagios --service=swap:disk --command='/usr/local/nagios/libexec/check_swap -w 20 -c 10' --command='/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /' Password: SWAP OK - 100% free (4102 MB out of 4102 MB) |swap=4102MB;0;0;0;4102 STATUS CODE: 0 DISK OK - free space: / 17731 MB (94% inode=98%);| /=957MB;19668;19678;0;19688 STATUS CODE: 0

When I create it as a command in Nagios, then use the command in a service, the host shows only the swap service check. How do I get Nagios to accept it as two services and display them both?

TIA!


#2

Those are two different services for Nagios (swap and disk). It has two exit codes and two statuses. Nagios only takes the first one, because it can only take one exit code and one status per service.

On the other hand you could write a script that would check both services and return only one exit code and one status, depending on how you configure it. You can put it to show OK if both services are OK, or just one, or none. That depends on your script. But, that way you wouldn’t really know the status of specific service you’re checking.

I suggest you create two separate services.