Hetzner - DokuWiki

Monitoring mit Munin/en

Inhaltsverzeichnis

S.M.A.R.T. Monitoring with Munin

Compared to other monitoring solutions, Munin is a relatively straightforward tool. This page describes the (not so intuitive) process of reading data, even from a 3ware RAID Controller.

These instructions apply to Debian Sarge (3.0), but are also almost identical for Etch (4.0) with the exception of the use of backports.

As munin can first only read more recent versions of S.M.A.R.T. data from the drives behind RAID Controllers, we rely on backports.

If Debian Sarge (3.0) is still being used, the following step will be of interest to you. If however you are already using Etch, you can skip the step about the backports archive.

In file:

# nano /etc/apt/sources.list

insert:

#
# backports (most recent version of munin)
#
deb http://www.backports.org/debian/ sarge-backports main contrib non-free

then update the package list:

# apt-get update

and test everything that needs to be updated:

# apt-get install -t sarge-backports munin munin-node -s

if there is no incompatibility in the list, install munin:

# apt-get install -t sarge-backports munin munin-node

We do the same with smartmontools (installs smartctl, the program that then reads the status of the drive)

# apt-get install -t sarge-backports smartmontools -s

and after a check, install:

# apt-get install -t sarge-backports smartmontools

If the tools are already installed, proceed exactly as described above.

Links to the scripts which are converted into a status graphic can now be found in /etc/munin/plugins.

Here we set up two new symbolic inks for each drive:

# cd /etc/munin/plugins
# ln -s /usr/share/munin/plugins/smart_ smart_twe0-0
# ln -s /usr/share/munin/plugins/smart_ smart_twe0-1

Normally, a symbolic link would need to be created here (e.g. if there is only one drive) in the form of:

# ln -s /usr/share/munin/plugins/smart_ smart_twe0-1

As we wish to monitor both drives however we need to use this somewhat unconventional form.

To check to see if twe0 really is a drive, it can be tested in advance using smartctl:

# smartctl -a /dev/twe0 -d 3ware,0

would be the first drive and

# smartctl -a /dev/twe0 -d 3ware,1

the second. The output:

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Caviar SE family
Device Model:     WDC WD1600JB-22GVC0
Serial Number:    WD-WCAL9xxxxxxx

shows if this is correct. Now we need to adjust the configuration for Munin:

# nano /etc/munin/plugin-conf.d/munin-node

We add both of the drives to the end of the file:

[smart_*]
user root
group disk
[smart_twe0-0]
env.smartargs -H -l error -d 3ware,0
[smart_twe0-1]
env.smartargs -H -l error -d 3ware,1

Then restart munin:

# /etc/init.d/munin-node restart

This results in two (one for each drive) S.M.A.R.T. status graphics:

Drive Temperature Output

If the temperature of the drives is to be shown, a symbolic link can be created on the hddtemp script:

# cd /etc/munin/plugins
# ln -s /usr/share/munin/plugins/hddtemp_smartctl hddtemp_smartctl

Configuration is similar to the above:

# nano /etc/munin/plugin-conf.d/munin-node
[hddtemp_smartctl]
user root
env.drives twe0_0 twe0_1
env.type_twe0_0 3ware,0
env.type_twe0_1 3ware,1

and do not forget to restart munin. Progress can then be monitored on the pages generated by munin:

Hddtemp smartctl-day.png

Configuration for Linux Software Raid

If a 3ware Controller is not being used and if Linux Software RAID is being used, the configuration is very similar. Symbolic links are created for both devices:

# cd /etc/munin/plugins
# ln -s /usr/share/munin/plugins/smart_ smart_sda
# ln -s /usr/share/munin/plugins/smart_ smart_sdb

Next add the plugin configuration:

# nano /etc/munin/plugin-conf.d/munin-node

At the end of the file add:

[smart_*]
user root
group disk


[smart_sda]
env.smartargs -H -l error -d ata

[smart_sdb]
env.smartargs -H -l error -d ata

Hard Disk Temperatures with Software Raid

# cd /etc/munin/plugins
# ln -s /usr/share/munin/plugins/hddtemp_smartctl hddtemp_smartctl

Editing the plugin configuration:

#nano /etc/munin/plugin-conf.d/munin-node

Add the following paragraph at the end of the file:

[hddtemp_smartctl]
user root
env.drives sda sdb
env.type_sda ata
env.type_sdb ata

Next, do not forget to restart Munin:

# /etc/init.d/munin-node restart

Monitor Available FTP Backup Space

lftp is needed here.

# apt-get install lftp

Integrate the following script into /usr/share/munin/plugins/

#!/bin/bash
MAXLABEL=20
if [ "$1" == "autoconf" ]; then
	echo yes
 exit 0
fi
if [ "$1" == "config" ]; then
 echo 'graph_title Backup-Space'
 echo 'graph_args --base 1000 -l 0'
 echo 'graph_vlabel Space in GB'
 echo 'graph_category Backup'
 echo 'graph_order max space'
 echo 'space.label Current'
 echo 'space.draw LINE'
 echo 'max.label Max'
 echo 'max.draw AREA'
 exit 0
fi
echo -en "space.value " && echo du . | lftp -u ${user},${pass} ${ip} | awk -v LIMIT="${max}" '$1~/[0-9]+/ {QUOTA=LIMIT*1024*1024; print ($1)/1024/1024 }' | tail -1
echo -en "max.value " && echo ${max}

and link it

ln -s /usr/share/munin/plugins/backup_space.sh /etc/munin/plugins/backup_space

In /etc/munin/plugin-conf.d/munin-node add

[backup_space]
env.user username
env.pass passwort
env.ip ftpserver
env.max 100

Restart Munin:

# /etc/init.d/munin-node restart

or

service munin-node restart

Check the script

/etc/munin/plugins# munin-run backup_space

With the message

Certificate verification: Not trusted

in /etc/lftp.conf add

set ssl:verify-certificate no

and save.

The output should approximately look like this

space.value 17.8776
max.value 100


© 2018. Hetzner Online GmbH. Alle Rechte vorbehalten.