Get Rewarded! We will reward you with up to €50 credit on your account for every tutorial that you write and we publish!

Setup monitoring on Managed Server

profile picture
Author
Alexander Knerlein
Published
2019-03-29
Time to read
4 minutes reading time

Introduction

In this tutorial we will setup a simple monitoring on your Managed Server based on the Monitoring Plugins (also known as Nagios Plugins).

Prerequisites

  • Managed Server with enabled SSH access
  • Hetzner Development Package (hos-dev) -> please ask the support
  • An existing local Nagios or Icinga server

Step 1 - Install the Monitoring Plugins

Login to the shell on your Managed Server and execute the commands below inside of your home directory.

wget https://www.monitoring-plugins.org/download/monitoring-plugins-2.4.0.tar.gz
tar xzvf monitoring-plugins-2.4.0.tar.gz
cd monitoring-plugins-2.4.0
./configure --prefix=/usr/home/holu/monitoring-plugins
make -j $(($(grep ^cpu\ cores /proc/cpuinfo | uniq | sed s/[^0-9]//g)+1))
make install

(Optional) Continue with the commands below to install the useful 3rd party plugin check-linux-memory.

cd ../monitoring-plugins/libexec
wget https://raw.githubusercontent.com/hugme/Nag_checks/master/check_linux_memory
chmod 755 check_linux_memory

Step 2 - Prepare your local monitoring server for check-by-ssh

Please login to your existing local Nagios or Icinga server.

The steps below should work for most versions of Nagios and Icinga.

sudo su - nagios -s /bin/bash
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ''
ssh-copy-id -i ~/.ssh/id_ed25519.pub holu@dediX.your-server.de -p222

Step 3 - Configure checks on your local monitoring server

For the exact configuration of your monitoring software, please read the documentation of the responsible developer.

Example load check:

./check_by_ssh -H dediX.your-server.de -p 222 -l holu -C "/usr/home/holu/monitoring-plugins/libexec/check_load -w 10,8,6 -c 20,15,10"
OK - load average: 0.03, 0.08, 0.08|load1=0.030;10.000;20.000;0; load5=0.080;8.000;15.000;0; load15=0.080;6.000;10.000;0;

Example swap check:

./check_by_ssh -H dediX.your-server.de -p 222 -l holu -C "/usr/home/holu/monitoring-plugins/libexec/check_swap -w 60% -c 20%"
SWAP OK - 99% free (4019 MB out of 4095 MB) |swap=4019MB;2457;819;0;4095

Example disk check:

./check_by_ssh -H dediX.your-server.de -p 222 -l holu -C "/usr/home/holu/monitoring-plugins/libexec/check_disk -w 10% -c 5% -p /usr"
DISK OK - free space: /usr 284513 MB (90% inode=95%);| /usr=28210MB;296519;312992;0;329466

Example lm-sensors check:

./check_by_ssh -H dediX.your-server.de -p 222 -l holu -C "/usr/home/holu/monitoring-plugins/libexec/check_sensors -v"
SENSORS OK
acpitz-virtual-0 Adapter: Virtual device temp1: +27.8 C (crit = +105.0 C) temp2: +29.8 C (crit = +105.0 C) coretemp-isa-0000 Adapter: ISA adapter Physical id 0: +33.0 C (high = +80.0 C, crit = +100.0 C) Core 0: +33.0 C (high = +80.0 C, crit = +100.0 C) Core 1: +32.0 C (high = +80.0 C, crit = +100.0 C) Core 2: +31.0 C (high = +80.0 C, crit = +100.0 C) Core 3: +28.0 C (high = +80.0 C, crit = +100.0 C)

Example process check:

./check_by_ssh -H dediX.your-server.de -p 222 -l holu -C "/usr/home/holu/monitoring-plugins/libexec/check_procs -a \"/usr/sbin/apache2 -k start\" -c 1:"
PROCS OK: 5 processes with args '/usr/sbin/apache2 -k start' | procs=5;;1:;0;

Please note: If you would like to watch all processes with check_procs, please ask the support.

Example memory check:

./check_by_ssh -H dediX.your-server.de -p 222 -l holu -C "/usr/home/holu/monitoring-plugins/libexec/check_linux_memory -w 20 -c 10"
MEMORY OK - 57.55% Free - Total:5846.2M Active:3192.04M Inactive:974.828M Buffers:828.434M Cached:1898.42M |Free=57.55;20;10;0 Active=3268648;0;0;0 Inactive=998224;0;0;0 Buffers=848316;0;0;0 Cached=1943984;0;0;0

Conclusion

Now you should be able to monitor various aspects of your Managed Server.

License: MIT
Want to contribute?

Get Rewarded: Get up to €50 in credit! Be a part of the community and contribute. Do it for the money. Do it for the bragging rights. And do it to teach others!

Report Issue
Try Hetzner Cloud

Get €20/$20 free credit!

Valid until: 31 December 2025 Valid for: 3 months and only for new customers
Get started
Want to contribute?

Get Rewarded: Get up to €50 credit on your account for every tutorial you write and we publish!

Find out more