mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
122 lines
2.7 KiB
Bash
Executable file
122 lines
2.7 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Plugin to parse packetship (http://www.packetship.com/) streaming server statistics.
|
|
#
|
|
# Author:
|
|
# Dave Fennell <dave@microtux.co.uk>
|
|
#
|
|
# Created:
|
|
# 2nd January 2013
|
|
#
|
|
# License:
|
|
# GPLv2
|
|
#
|
|
# Usage:
|
|
# Link in /etc/munin/plugins/ as packetship_streams or packetship_bandwidth (or both)
|
|
#
|
|
|
|
# change those to reflect your bind configuration (use plugin configuration)
|
|
# hostname file
|
|
if [ "$hostname" = "" ]; then
|
|
hostname="localhost"
|
|
fi
|
|
|
|
# url path
|
|
if [ "$url" = "" ]; then
|
|
url="packetship/status.php"
|
|
fi
|
|
|
|
# Get the mode from the plugin symlink name.
|
|
mode=${0#*_}
|
|
|
|
# Check for valid mode.
|
|
if [[ "$mode" != "streams" && "$mode" != "bandwidth" ]]; then
|
|
echo "Link name must be packetship_streams or packetship_bandwidth."
|
|
exit 1
|
|
fi
|
|
|
|
# Fetch the XML formatted stats from packetship.
|
|
xml=$(wget -q -O - http://${hostname}/${url})
|
|
|
|
# Disk stats are from '<ps:disk>' to '</ps:disk>'
|
|
disk_stats=$(echo "$xml" | sed "0,/<ps:disk>/d" | sed -e "/<\/ps:disk>/,\$d" | grep $mode)
|
|
network_stats=$(echo "$xml" | sed "0,/<ps:network>/d" | sed -e "/<\/ps:network>/,\$d" | grep $mode)
|
|
|
|
read_dom () {
|
|
local IFS=\>
|
|
read -d \< ENTITY CONTENT
|
|
TAG_NAME=${ENTITY%% *}
|
|
ATTRIBUTES=${ENTITY#* }
|
|
|
|
# Remove / characters from ATTRIBUTES if present.
|
|
ATTRIBUTES=${ATTRIBUTES//\//}
|
|
|
|
if [[ $ENTITY = "" ]]; then
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
# echo $stats
|
|
|
|
# Config mode.
|
|
if [ "$1" = "config" ]; then
|
|
echo 'graph_args --lower-limit 0'
|
|
echo 'graph_category streaming'
|
|
echo 'graph_info '${mode}' statistics for packetship server'
|
|
echo 'graph_scale no'
|
|
echo 'graph_title Packetship '${mode}
|
|
|
|
if [ "$mode" = "streams" ]; then
|
|
echo 'graph_vlabel streams'
|
|
else
|
|
echo 'graph_vlabel bandwidth (Mbit/sec)'
|
|
fi
|
|
|
|
echo "disk_value.label Disk current"
|
|
echo "disk_value.info Disk current" ${mode}
|
|
echo "disk_value.type GAUGE"
|
|
|
|
echo "disk_max.label Disk max"
|
|
echo "disk_max.info Disk max" ${mode}
|
|
echo "disk_max.type GAUGE"
|
|
|
|
echo "network_value.label Network current"
|
|
echo "network_value.info Network current" ${mode}
|
|
echo "network_value.type GAUGE"
|
|
|
|
echo "network_max.label Network max"
|
|
echo "network_max.info Network max" ${mode}
|
|
echo "network_max.type GAUGE"
|
|
|
|
# If dirty config capability is enabled then fall through
|
|
# to output the data with the config information.
|
|
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
while read_dom; do
|
|
# Ignore empty tags (First loop)
|
|
if [ "$TAG_NAME" = "" ]; then
|
|
continue
|
|
fi
|
|
|
|
eval $ATTRIBUTES
|
|
|
|
echo "disk_value.value " $used
|
|
echo "disk_max.value " $max
|
|
done <<< "$disk_stats"
|
|
|
|
while read_dom; do
|
|
# Ignore empty tags (First loop)
|
|
if [ "$TAG_NAME" = "" ]; then
|
|
continue
|
|
fi
|
|
|
|
eval $ATTRIBUTES
|
|
|
|
echo "network_value.value " $used
|
|
echo "network_max.value " $max
|
|
done <<< "$network_stats"
|