Check by SSH¶
SSH provides an easy and secure way to run monitoring plugins on a remote host.
Creating an SSH key on the openITCOCKPIT server¶
If you don't already have an SSH key for the user
nagios ,you will need to create one.
After this process completes you should import the SSH host key into your target system:
ssh <target-host> and confirm this choice with
Import the SSH key into the target system¶
For this example you need the packages
monitoring-plugins installed on the target host.
apt-get install nagios-plugins
We now need to create a new user
monitoring, that will be used to run 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
chmod 644 /home/monitoring/.ssh/authorized_keys
Now copy your public key to the file
Monitoring -> Objects -> Commands and make sure the
check_by_ssh command exists. This is a standard openITCOCKPIT command. If the command is not available, click the
+ New button and create it.
|Service check command
$USER1$/check_by_ssh -H $HOSTADDRESS$ -l "$ARG1$" -C "$ARG2$"
|Command argument ($ARG1)
|Command argument ($ARG2)
check_by_ssh plugin can be used to execute all types of commands on the remote host. For check plugins to run you must set the absolute path to the plugin. Also, by creating a macro with the plugin path you will save yourself a lot of work.
Monitoring -> Objects -> Custom Macros and click the
+ New button.
$USER2$ (or any other)
Path of monitoring-plugins on remote host used by check_by_ssh
Monitoring -> Services and click the
+ New button.
Select your host and the predefined service template
|Service templates definition
$USER2$/check_load -w 15,10,5 -c 30,25,20
To continue click
$USER2$ is automatically replaced with the value stored in the previous macro.
Repeat this step for all the services you need.
For the new changes to take effect, you must update the monitoring configuration.
The new services will now be monitored by the system.