Projet

Général

Profil

Révision 819e2a6f

ID819e2a6fe923eb715023de0c9bf77f563e02b1cf
Parent 0628832a
Enfant 9bfb1101

Ajouté par Dave Fennell il y a presque 13 ans

Added plugin for packetship media streaming server.

Voir les différences:

plugins/streaming/packetship_
1
#!/bin/bash
2
#
3
# Plugin to parse packetship (http://www.packetship.com/) streaming server statistics.
4
#
5
# Author:
6
#    Dave Fennell <dave@microtux.co.uk>
7
#
8
# Created:
9
#    2nd January 2013
10
#
11
# License:
12
#    GPLv2
13
#
14
# Usage:
15
#    Link in /etc/munin/plugins/ as packetship_streams or packetship_bandwidth (or both)
16
#
17

  
18
# change those to reflect your bind configuration (use plugin configuration)
19
# hostname file
20
if [ "$hostname" = "" ]; then
21
	hostname="localhost"
22
fi
23

  
24
# url path
25
if [ "$url" = "" ]; then
26
	url="packetship/status.php"
27
fi
28

  
29
# Get the mode from the plugin symlink name.
30
mode=${0#*_}
31

  
32
# Check for valid mode.
33
if [[ "$mode" != "streams" && "$mode" != "bandwidth" ]]; then
34
	echo "Link name must be packetship_streams or packetship_bandwidth."
35
	exit 1
36
fi
37

  
38
# Fetch the XML formatted stats from packetship.
39
xml=$(wget -q -O - http://${hostname}/${url})
40

  
41
# Disk stats are from '<ps:disk>' to '</ps:disk>'
42
disk_stats=$(echo "$xml" | sed "0,/<ps:disk>/d" | sed -e "/<\/ps:disk>/,\$d" | grep $mode)
43
network_stats=$(echo "$xml" | sed "0,/<ps:network>/d" | sed -e "/<\/ps:network>/,\$d" | grep $mode)
44

  
45
read_dom () {
46
	local IFS=\>
47
	read -d \< ENTITY CONTENT
48
	TAG_NAME=${ENTITY%% *}
49
	ATTRIBUTES=${ENTITY#* }
50

  
51
	# Remove / characters from ATTRIBUTES if present.
52
	ATTRIBUTES=${ATTRIBUTES//\//}
53

  
54
	if [[ $ENTITY = "" ]]; then
55
		return 1
56
	fi
57

  
58
	return 0
59
}
60

  
61
# echo $stats
62

  
63
# Config mode.
64
if [ "$1" = "config" ]; then
65
	echo 'graph_args --lower-limit 0'
66
	echo 'graph_category streaming'
67
	echo 'graph_info '${mode}' statistics for packetship server'
68
	echo 'graph_scale no'
69
	echo 'graph_title Packetship '${mode}
70

  
71
	if [ "$mode" = "streams" ]; then
72
		echo 'graph_vlabel streams'
73
	else
74
		echo 'graph_vlabel bandwidth (Mbit/sec)'
75
	fi
76

  
77
	echo "disk_value.label Disk current"
78
	echo "disk_value.info Disk current" ${mode}
79
	echo "disk_value.type GAUGE"
80

  
81
	echo "disk_max.label Disk max"
82
	echo "disk_max.info Disk max" ${mode}
83
	echo "disk_max.type GAUGE"
84

  
85
	echo "network_value.label Network current"
86
	echo "network_value.info Network current" ${mode}
87
	echo "network_value.type GAUGE"
88

  
89
	echo "network_max.label Network max"
90
	echo "network_max.info Network max" ${mode}
91
	echo "network_max.type GAUGE"
92

  
93
	# If dirty config capability is enabled then fall through
94
	# to output the data with the config information.
95
	if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
96
		exit 0
97
	fi
98
fi
99

  
100
while read_dom; do
101
	# Ignore empty tags (First loop)
102
	if [ "$TAG_NAME" = "" ]; then
103
		continue
104
	fi
105

  
106
	eval $ATTRIBUTES
107

  
108
	echo "disk_value.value " $used
109
	echo "disk_max.value " $max
110
done <<< "$disk_stats"
111

  
112
while read_dom; do
113
	# Ignore empty tags (First loop)
114
	if [ "$TAG_NAME" = "" ]; then
115
		continue
116
	fi
117

  
118
	eval $ATTRIBUTES
119

  
120
	echo "network_value.value " $used
121
	echo "network_max.value " $max
122
done <<< "$network_stats"

Formats disponibles : Unified diff