Check by SSH

SSH is a super easy and secure way, to execute monitoring plugins on a remote host.

Create SSH-Key on your openITCOCKPIT Server

If you don't have a SSH-Key for your user nagios yet, you need to create one.

su nagios
mkdir /var/lib/nagios/.ssh

Also you should import the ssh host key of the target host right now: ssh <target-host> and just confirm with yes.

Import SSH-Key on target host

For this example you need to install the nagios-plugins or monitoring-plugins.

apt-get install nagios-plugins

In the next step we create a new user monitoring which will be used to execute the checks via SSH.

addgroup --system monitoring
adduser --system --shell /bin/bash monitoring
adduser monitoring monitoring

mkdir -p /home/monitoring/.ssh/
chown monitoring:monitoring /home/monitoring -R

touch /home/monitoring/.ssh/authorized_keys
chmod 644 /home/monitoring/.ssh/authorized_keys

Now copy your public key to the file /home/monitoring/.ssh/authorized_keys

Create checks

First of all, make sure that the command check_by_ssh at Basic Monitoring Commands is set with the right parameters.

Set as command line $USER1$/check_by_ssh -H $HOSTADDRESS$ -l "$ARG1$" -C "$ARG2$" and press on save. (In previous versions the quotes where missing)

Due to the fact that we are lazy, we create a new macro Expert Monitoring User Defined Macros and set the value to /usr/lib/nagios/plugins. Now we do not need to set the base path for every plugin we like to execute via SSH.

Go to Basic Monitoring Services "New" to create a new service, which will be checked by SSH.

First of all you need to select the host, were you like to create the service for and the service template CHECK_BY_SSH. The system will now load all predefined values of the service template.

Change the Name to CPU Load and click on Expert settings.

New you need to pass your arguments. For Username we set monitoring and for Command $USER2$/check_load -w 15,10,5 -c 30,25,20.

$USER2$ will be automatically replaced with the value from the macro we defined earlier.

Now press on "Save" and repeat this step for every service.

Once you created all services, you need to "Refresh the monitoring configuration".

The new services will be now monitored by the system: