Projekt

Allgemein

Profil

Config zabbix18agent » Historie » Version 1

Jeremias Keihsler, 13.01.2017 11:21

1 1 Jeremias Keihsler
h1. Zabbix Agent 1.8
2
3
h2. preliminary note
4
5
this is mostly taken from http://www.torservers.net/wiki/setup/zabbix
6
7
h3. Firewall
8
9
In case you use iptables you need to open port 10050 on the client side and 10050 and 10051 on the server side (or any other port of course if you configured Zabbix to use non-standard ports). As an alternative you can also use Active Checks which don't require open Ports on the Nodes that are to be monitored and also help to reduce load on the Server side, since the Client does all the work itself in this case.
10
11
h2. Advanced
12
13
h3. stunnel
14
15
UserParameter=hdd.sda.temperature,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Temperature_Celsius
16
UserParameter=hdd.sda.raw_read_error_rate,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Raw_Read_Error_Rate
17
UserParameter=hdd.sda.reallocated_sector_count,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Reallocated_Sector_Ct
18
 
19
UserParameter=hdd.sdb.temperature,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Temperature_Celsius
20
UserParameter=hdd.sdb.raw_read_error_rate,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Raw_Read_Error_Rate
21
UserParameter=hdd.sdb.reallocated_sector_count,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Reallocated_Sector_Ct
22
23
h3. Custom Scripts "md"
24
25
Here is a small script for monitoring md. It can only monitor Raid1 systems so far, since we don't have the need to monitor Raid5 or anything else. Feel free to expand this in case you need it.
26
27
<pre><code class="bash">
28
#!/bin/bash
29
if [ $# -ne 1 ];
30
then
31
echo "Usage: $0 "
32
exit
33
fi
34
var_mdnum="$1"
35
if [[ "$var_mdnum" != md* ]]
36
then
37
var_mdnum=`echo $var_mdnum | sed 's/\/[a-z]*\/md*/md/'`
38
fi
39
if [ `cat /proc/mdstat | grep -C 1 $var_mdnum | grep -o UU` == "UU" ]
40
then
41
echo 0
42
exit
43
else
44
echo 1
45
exit
46
fi
47
</code></pre>
48
49
Put something like
50
51
<pre><code class="bash">UserParameter=raid.md0.status, /etc/zabbix/scripts/get_md_status.sh md0</code></pre>
52
in your zabbix_agentd.conf to use this and configure an Item for it on the Zabbix Server for the node you wish to use this for or in its underlying template.
53
54
h3. Custom Scripts "Smart"
55
56
<pre><code class="bash">
57
#!/bin/bash
58
if [ $# -ne 2 ];
59
then
60
echo "Usage: $0 <device> <parameter>"
61
exit
62
fi
63
 
64
sudo smartctl -A $1 | grep $2 | tr -s ' ' | sed "s/^[[:space:]]*\(.*\)[[:space:]]*$/\1/" | cut -d " " -f 10
65
</code></pre>
66
67
Make sure smartmontools are installed and accessible for Zabbix.
68
You might need something like 
69
<pre><code class="bash">
70
%zabbix ALL= NOPASSWD: /usr/sbin/smartctl
71
</code></pre>
72
in your sudoers file.
73
74
Here are my UserParameters:
75
<pre><code class="bash">
76
UserParameter=hdd.sda.temperature,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Temperature_Celsius
77
UserParameter=hdd.sda.raw_read_error_rate,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Raw_Read_Error_Rate
78
UserParameter=hdd.sda.reallocated_sector_count,/etc/zabbix/scripts/get_smart_value.sh /dev/sda Reallocated_Sector_Ct
79
 
80
UserParameter=hdd.sdb.temperature,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Temperature_Celsius
81
UserParameter=hdd.sdb.raw_read_error_rate,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Raw_Read_Error_Rate
82
UserParameter=hdd.sdb.reallocated_sector_count,/etc/zabbix/scripts/get_smart_value.sh /dev/sdb Reallocated_Sector_Ct
83
</code></pre>
84
85
h2. FPing
86
87
When using Active Checks you might still want to Monitor a hosts uptime. For this you need to install fping on the Server and do a chown root:zabbix on its binary for zabbix to be able to use it.