#!/bin/bash

case $1 in
    config)
    echo "graph_category network"
    echo "graph_title Speedtest latency"
    echo "graph_args --base 1000 -l 0"
    echo "graph_vlabel Ping / jitter"
    echo "graph_scale no"
    echo "ping.label Latency"
    echo "ping.type GAUGE"
    echo "ping.draw LINE1"
    echo "jitter.label Jitter"
    echo "jitter.type GAUGE"
    echo "jitter.draw LINE1"
    echo "graph_info Graph of Internet Connection latency"
    exit 0;;
    esac

OUTPUT=`cat /var/log/munin/speedtest-results.txt`
PING=`echo "$OUTPUT" | grep Latency | awk '{ print $2 }'`
JITTER=`echo "$OUTPUT" |grep "Idle Latency" | awk '{ print $6 }' | sed 's/.$//'`

echo "ping.value $PING"
echo "jitter.value $JITTER"