Ad Widget

Collapse

"zabbix external" packetloss

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frater
    Senior Member
    • Oct 2010
    • 340

    #1

    "zabbix external" packetloss

    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
    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}"
    ln -s /usr/local/sbin/packetloss /etc/zabbix/externalscripts
    • 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)}&gt;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)}&gt;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)}&gt;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>
    Last edited by frater; 15-03-2012, 19:19.
    Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP
  • jherazob
    Junior Member
    • Sep 2011
    • 20

    #2
    Thanks for this tip, i'm now using a slightly modified version of your script (no parameter? then we're just checking if we have Internet access and ping Google instead) to check for host availability: Last 120 seconds the minimum value for the item (with a check every 30 seconds) has been 100? Fire the trigger. It has reduced both false positives and missed alerts.

    Plus of course alerting when the packet loss to a server is getting high, of course

    Comment

    • frater
      Senior Member
      • Oct 2010
      • 340

      #3
      The script is intended to run on the Zabbix server and should check the site of your client.to test the speed of the client I'm using a agent test that will do an httping to http://www.google.nl.
      This can be done using standard Zabbix functionality.

      Search for httpspeed or httping on this forum for an external check.
      Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

      Comment

      Working...