mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Added plugin for packetship media streaming server.
This commit is contained in:
parent
0628832aef
commit
819e2a6fe9
122
plugins/streaming/packetship_
Executable file
122
plugins/streaming/packetship_
Executable file
@ -0,0 +1,122 @@
|
||||
#!/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"
|
Loading…
Reference in New Issue
Block a user