From 2912117ad4835febaf101aefcbd01e704159ec72 Mon Sep 17 00:00:00 2001 From: Dave Fennell Date: Thu, 3 Jan 2013 17:36:27 +0000 Subject: [PATCH] Updated packetship plugin to support multiple pumps. --- plugins/streaming/packetship_ | 107 +++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 35 deletions(-) diff --git a/plugins/streaming/packetship_ b/plugins/streaming/packetship_ index c527f392..a9ec0964 100755 --- a/plugins/streaming/packetship_ +++ b/plugins/streaming/packetship_ @@ -38,10 +38,7 @@ fi # Fetch the XML formatted stats from packetship. xml=$(wget -q -O - http://${hostname}/${url}) -# Disk stats are from '' to '' -disk_stats=$(echo "$xml" | sed "0,//d" | sed -e "/<\/ps:disk>/,\$d" | grep $mode) -network_stats=$(echo "$xml" | sed "0,//d" | sed -e "/<\/ps:network>/,\$d" | grep $mode) - +# Function to do simple string parsing of XML data. read_dom () { local IFS=\> read -d \< ENTITY CONTENT @@ -58,7 +55,24 @@ read_dom () { return 0 } -# echo $stats +# Get the number of pumps from the xml feed. +pumps_line=$(echo "$xml" | grep "' to '' + disk_stats=$(echo "$pump_section" | sed "0,//d" | sed -e "/<\/ps:disk>/,\$d" | grep $mode) + network_stats=$(echo "$pump_section" | sed "0,//d" | sed -e "/<\/ps:network>/,\$d" | grep $mode) - eval $ATTRIBUTES + # Output disk values for this pump. + while read_dom; do + # Ignore empty tags (First loop) + if [ "$TAG_NAME" = "" ]; then + continue + fi - echo "network_value.value" $used - echo "network_max.value" $max -done <<< "$network_stats" + eval $ATTRIBUTES + + echo "pump"${pump}"_disk_value.value" $used + echo "pump"${pump}"_disk_max.value" $max + done <<< "$disk_stats" + + # Output network values for this pump + while read_dom; do + # Ignore empty tags (First loop) + if [ "$TAG_NAME" = "" ]; then + continue + fi + + eval $ATTRIBUTES + + echo "pump"${pump}"_network_value.value" $used + echo "pump"${pump}"_network_max.value" $max + done <<< "$network_stats" +done