You are here
Using check_by_ssh for Monitoring in Opsview
Opsview includes many agent and agentless checks, this guide covers how to setup the agentless check_by_ssh.
Agentless check_by_ssh simply runs commands over SSH, you can use it to run normal plugins, this can be very useful for systems that do not have the Opsview agent installed.
SSH key exchange
The first step in setting up check_by_ssh is exchanging an SSH key between your Opsview monitoring system and the host it will be monitoring. The key exchange allows a password less SSH connection between your Opsview system and your Host. The Opsview system in this guide is whichever system the checks will be originating from, this could be you master or one of your slave systems.
On the Opsview system
Either login as the Nagios user or change to this user (you will need to be root to do this):
su - nagios
Next generate the SSH key:
ssh-keygen -t dsa
Read back the new key file:
Copy or make a note of the key.
On the client
Add a Nagios user (you will need to be root to do this):
useradd nagios -m -d /home/nagios
Login as the new user:
su - nagios
Navigate to your home directory:
Create an SSH directory
Move to the new directory:
Create an authorised_keys file:
Paste the contents of the key you generated on your Opsview system into this new file. Ctrl-x will exit nano, when prompted select “y” to save.
Test the SSH connection
From the Opsview server as the Nagios user you should now be able to SSH to the slave without requiring a password using the following command:
Using the plugin
The plugin simply runs commands on the host, you can specify the command using the “–C” option, the return is handled in exactly the same way as other plugins, interpreting the status and performance information.
Below is an example check_by_ssh command:
check_by_ssh -H $HOSTADDRESS$ -C "/usr/local/nagios/libexec/check_memory -w 90 -c 98"
This check will read the system memory, this will return in exactly the same way as the check_memory command run via the agent.
To run check_by_ssh commands you will need to put the scripts onto the host. In the example above I had to copy the “check_memory” script to the folder “/usr/local/nagios/libexec/” you will also need to ensure that the script is executable by the Nagios user.
Opsview includes Load Average, Storage Utilisation and System Memory checks that use check_by_ssh in the OS - Unix Agentless host template.
Using SSH is a useful way of running checks against your systems, it is especially handy if you are unable to install the agent on the machine. If you do not already have Opsview you can register for a trial or Opsview Atom and start using check_by_ssh today.