spiffin
2/3/2015 - 4:51 PM

Munin plugin for ioping (monitor VPS disk latency, seek rate and sequential speed)

Munin plugin for ioping (monitor VPS disk latency, seek rate and sequential speed)

#!/bin/sh
#
# Monitor VPS disk latency, seekrate and speed via ioping
#
# Requirements: 
#
#       ioping 0.8: https://code.google.com/p/ioping/
#       ioping path = /usr/bin/ioping (symlink it if it's somewhere else)
#
# Parameters understood:
#
#       config   (required)
#       autoconf (optional - used by munin-config)
#
#This plugin must be run as root, to do that append the following
#to your /etc/munin/plugins/plugin-conf.d/munin-node:
#
#[ioping_stats]
#user root
#
# Magic markers (optional - used by munin-config and installation scripts):
#
#%# family=auto
#%# capabilities=autoconf

if [ "$1" = "autoconf" ]; then
  echo yes
  exit 0
fi

output_config() {
    echo "graph_category disk"
    echo "graph_args --base 1000 -l 0"
    echo "graph_title Ioping stats"
    echo "graph_vlabel usec"
    echo "iolatency.label Latency"
    echo "seekrate.label Seekrate"
    echo "sequentialspeed.label Sequential-speed"
}

output_values() {
    printf "iolatency.value %d\n" $(iolatency)
    printf "seekrate.value %d\n" $(seekrate)
    printf "sequentialspeed.value %d\n" $(sequentialspeed)
}

iolatency() {
    ioping -q / -c 5 -p 5 | cut -d' ' -f6
}

seekrate() {
    ioping -R / -c 50 -p 50 | cut -d' ' -f6
}

sequentialspeed() {
    ioping -RL / -c 50 -p 50 | cut -d' ' -f6
}

output_usage() {
    printf >&2 "%s - munin plugin to graph ioping stats\n" ${0##*/}
    printf >&2 "Usage: %s [config]\n" ${0##*/}
}

case $# in
    0)
        output_values
        ;;
    1)
        case $1 in
            config)
                output_config
                ;;
            *)
                output_usage
                exit 1
                ;;
        esac
        ;;
    *)
        output_usage
        exit 1
        ;;
esac