I wrote this little script to be used in the template standalone.
It will give you a value 0~100 (percentages) for the amount of packetloss
# cat /usr/local/sbin/packetloss
ln -s /usr/local/sbin/packetloss /etc/zabbix/externalscripts
Because I'm running 1.9.7 I'm missing the items out of an XML-export...
This is the info you need for the triggers...
It will give you a value 0~100 (percentages) for the amount of packetloss
# cat /usr/local/sbin/packetloss
Code:
#!/bin/bash
PACKETLOSS=`ping -q -c5 -i0.3 -w4 ${1} | grep transmitted | grep -Eo '[0-9%]* packet loss' | tr -cd '0-9'`
[ -z "${PACKETLOSS}" ] && PACKETLOSS=100
echo "${PACKETLOSS}"
- name: Packetloss on $1
- Type: Zabbix External
- Interval: 60
- Key: packetloss[{HOST.CONN1}]
- type: Numeric (unsigned)
- Units: %
Because I'm running 1.9.7 I'm missing the items out of an XML-export...
This is the info you need for the triggers...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export version="1.0" date="14.11.11" time="17.35">
<hosts>
<host name="Template_Standalone">
<name>Template_Standalone</name>
<status>3</status>
<groups>
<group>Templates</group>
</groups>
<triggers>
<trigger>
<description>Site {HOST.CONN} is unreachable (Internet Down) - {HOSTNAME}</description>
<type>0</type>
<expression>{Template_Standalone:icmpping.max(#3)}=0</expression>
<url></url>
<status>0</status>
<priority>4</priority>
<comments></comments>
</trigger>
<trigger>
<description>Site {HOST.CONN} has minor packetloss ({ITEM.LASTVALUE1}) - {HOSTNAME}</description>
<type>0</type>
<expression>{Template_Standalone:packetloss[{HOST.CONN1}].last(0)}>1</expression>
<url></url>
<status>0</status>
<priority>1</priority>
<comments></comments>
</trigger>
<trigger>
<description>Site {HOST.CONN} has packetloss ({ITEM.LASTVALUE1}) - {HOSTNAME}</description>
<type>0</type>
<expression>{Template_Standalone:packetloss[{HOST.CONN1}].last(0)}>8</expression>
<url></url>
<status>0</status>
<priority>2</priority>
<comments></comments>
</trigger>
<trigger>
<description>Site {HOST.CONN} has severe packetloss ({ITEM.LASTVALUE1}) - {HOSTNAME}</description>
<type>0</type>
<expression>{Template_Standalone:packetloss[{HOST.CONN1}].last(0)}>40</expression>
<url></url>
<status>0</status>
<priority>3</priority>
<comments></comments>
</trigger>
</triggers>
<items/>
<templates/>
<screens/>
<graphs/>
<macros/>
</host>
</hosts>
<dependencies>
<dependency description="Template_Standalone:Site {HOST.CONN} has minor packetloss ({ITEM.LASTVALUE1}) - {HOSTNAME}">
<depends>Template_Standalone:Site {HOST.CONN} is unreachable (Internet Down) - {HOSTNAME}</depends>
</dependency>
<dependency description="Template_Standalone:Site {HOST.CONN} has packetloss ({ITEM.LASTVALUE1}) - {HOSTNAME}">
<depends>Template_Standalone:Site {HOST.CONN} has severe packetloss ({ITEM.LASTVALUE1}) - {HOSTNAME}</depends>
</dependency>
<dependency description="Template_Standalone:Site {HOST.CONN} has severe packetloss ({ITEM.LASTVALUE1}) - {HOSTNAME}">
<depends>Template_Standalone:Site {HOST.CONN} is unreachable (Internet Down) - {HOSTNAME}</depends>
</dependency>
</dependencies>
</zabbix_export>
Comment