Automating Nagios service checks via SSH

Making check_http run properly on the remote server

OK, time to turn to the LD_LIBRARY_PATH trick. This tells the system to look for libraries in the directory where I copied them first.

[rudd-o@amauta2 ~]$ export LD_LIBRARY_PATH=$HOME/nagios/lib
[rudd-o@amauta2 ~]$ nagios/bin/check_http
nagios/bin/check_http: relocation error: /home/rudd-o/nagios/lib/libc.so.6: symbol _dl_tls_get_addr_soft, version GLIBC_PRIVATE not defined in file ld-linux.so.2 with link time reference
Relowhat? I couldn’t run check_http directly, since the linker is linked against version 2.2 of the C library, and the program is linked against version 2.4. Damn.

But here comes the linker I copied (part of the GNU C library) to the rescue:

[rudd-o@amauta2 ~]$ nagios/lib/ld-linux.so.2 nagios/bin/check_http
check_http: Could not parse arguments
Usage: check_http -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]
       [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]
       [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]
       [-s string] [-l] [-r <regex> | -R <case-insensitive regex>] [-P string]
       [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>] [-A string] [-k string]
Great! Let’s create a nagiosrun script to automate this odious task, and save it in my bin/ directory:
[rudd-o@amauta2 ~]$ cat bin/nagiosrun

!/bin/bash

export LD_LIBRARY_PATH=$HOME/nagios/lib exec $HOME/nagios/lib/ld-linux.so.2 "$@" This snippet (once made executable) simply automates the setup of the library path, then execs the arguments I pass. Now I can do:

[rudd-o@amauta2 ~]$ nagiosrun nagios/bin/check_http
Keep reading to find out how I run this command from my home workstation.

Pages: 1 2 3 4 5 6 7

One Response to “Automating Nagios service checks via SSH”

  1. Joe Says:

    Hi,

    Why not generate a public /private key pair, then append the public key to /root/.ssh/authorized_keys on the target server? Then ssh will authenticate you on the basis of this key. You will need to establish the connection once manually, the target machine is added to a list of known hosts on the nagios server, from then on the logins will be silently granted without a password.

Leave a Reply