Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / streaming / icecast2 @ 31412baa

Historique | Voir | Annoter | Télécharger (3,74 ko)

1
#!/bin/sh
2
# 
3
# Plugin to monitor icecast2 streams / listeners
4
# 
5
# Contributed by drew Roberts
6
#
7
# based on the postfix_mailqueue plugin as per below
8
# 
9
# Plugin to monitor postfix mail spools
10
# 
11
# Contributed by Nicolai Langfeldt
12
# 
13
# $Log$
14
# Revision 1.0  2008/07/04 16:02:36  zotz
15
# Initial work
16

    
17
#
18
# 
19
#%# family=auto
20
#%# capabilities=autoconf
21

    
22
# Can be set via environment, but default is /var/spool/postfix
23
ICEDIR=${icedir:-/var/www/rrd/logs/stream_stats/}
24

    
25
case $1 in
26
    autoconf|detect)
27
	if [ -d $ICEDIR/ ] ; then
28
	    echo yes
29
	    exit 0
30
        else
31
	    echo "no (icedir not found)"
32
	    exit 1
33
        fi;;
34
    config)
35
	cat <<'EOF'
36
graph_title Icecast2 Stream Listeners
37
graph_args --base 1000 -l 0
38
graph_vlabel Listeners for Streams
39
graph_category streaming
40
cool_ogg.label cool_ogg
41
cool_ogg.draw AREA
42
cool_ogg.type GAUGE
43
cool_mp3.label cool_mp3
44
cool_mp3.draw STACK
45
cool_mp3.type GAGUE
46
jamz_ogg.label jamz_ogg
47
jamz_ogg.draw STACK
48
jamz_ogg.type GAGUE
49
jamz_mp3.label jamz_mp3
50
jamz_mp3.draw STACK
51
jamz_mp3.type GAGUE
52
joy_ogg.label joy_ogg
53
joy_ogg.draw STACK
54
joy_ogg.type GAGUE
55
joy_mp3.label joy_mp3
56
joy_mp3.draw STACK
57
joy_mp3.type GAGUE
58
y_ogg.label y_ogg
59
y_ogg.draw STACK
60
y_ogg.type GAGUE
61
y_mp3.label y_mp3
62
y_mp3.draw STACK
63
y_mp3.type GAGUE
64
EOF
65
	exit 0;;
66
esac
67

    
68
cd $ICEDIR >/dev/null 2>/dev/null || {
69
     echo "# Cannot cd to $ICEDIR"
70
     exit 1
71
}
72

    
73
/usr/bin/curl -s localhost:7144/status2.xsl > /tmp/ice.txt
74
/usr/bin/tail -n 1 /tmp/ice.txt > /tmp/ice1.txt
75

    
76
awk 'BEGIN {FS=","} {tot = 0 ; i = (NF-1)/6 ; j=1 ; while (j <= i) {tot = (tot + $(((j-1)*6)+4)) ; print $(((j-1)*6)+1), ":", $(((j-1)*6)+4) > "/tmp/ice2.txt" ; j++}; print "total :", tot >> "/tmp/ice2.txt"} ' /tmp/ice1.txt
77

    
78
# Cool ogg stream
79
grep cool.ogg /tmp/ice2.txt > /dev/null 2>&1
80
if [ "$?" -ne "0" ]; then
81
  coologg="0"
82
else
83
  coologg=`grep cool.ogg /tmp/ice2.txt | cut -d ":" -f 2 - `
84
  coologg=$(($coologg+0))
85
fi
86
#echo $coologg
87

    
88
# Cool mp3 stream
89
grep coolmp3 /tmp/ice2.txt > /dev/null 2>&1
90
if [ "$?" -ne "0" ]; then
91
  coolmp3="0"
92
else
93
  coolmp3=`grep coolmp3 /tmp/ice2.txt | cut -d ":" -f 2 - `
94
  coolmp3=$(($coolmp3+0))
95
fi
96
#echo $coolmp3
97

    
98
# Jamz ogg stream
99
grep jamz.ogg /tmp/ice2.txt > /dev/null 2>&1
100
if [ "$?" -ne "0" ]; then
101
  jamzogg="0"
102
else
103
  jamzogg=`grep jamz.ogg /tmp/ice2.txt | cut -d ":" -f 2 - `
104
  jamzogg=$(($jamzogg+0))
105
fi
106
#echo $jamzogg
107

    
108
# Jamz mp3 stream
109
grep jamzmp3 /tmp/ice2.txt > /dev/null 2>&1
110
if [ "$?" -ne "0" ]; then
111
  jamzmp3="0"
112
else
113
  jamzmp3=`grep jamzmp3 /tmp/ice2.txt | cut -d ":" -f 2 - `
114
  jamzmp3=$(($jamzmp3+0))
115
fi
116
#echo $jamzmp3
117

    
118
# Joy ogg stream
119
grep joy.ogg /tmp/ice2.txt > /dev/null 2>&1
120
if [ "$?" -ne "0" ]; then
121
  joyogg="0"
122
else
123
  joyogg=`grep joy.ogg /tmp/ice2.txt | cut -d ":" -f 2 - `
124
  joyogg=$(($joyogg+0))
125
fi
126
#echo $joyogg
127

    
128
# Joy mp3 stream
129
grep joymp3 /tmp/ice2.txt > /dev/null 2>&1
130
if [ "$?" -ne "0" ]; then
131
  joymp3="0"
132
else
133
  joymp3=`grep joymp3 /tmp/ice2.txt | cut -d ":" -f 2 - `
134
  joymp3=$(($joymp3+0))
135
fi
136
#echo $joymp3
137

    
138
# Y ogg stream
139
grep "/y.ogg" /tmp/ice2.txt > /dev/null 2>&1
140
if [ "$?" -ne "0" ]; then
141
  yogg="0"
142
else
143
  yogg=`grep "/y.ogg" /tmp/ice2.txt | cut -d ":" -f 2 - `
144
  yogg=$(($yogg+0))
145
fi
146
#echo $yogg
147

    
148
# Y mp3 stream
149
grep "/ymp3" /tmp/ice2.txt > /dev/null 2>&1
150
if [ "$?" -ne "0" ]; then
151
  ymp3="0"
152
else
153
  ymp3=`grep "/ymp3" /tmp/ice2.txt | cut -d ":" -f 2 - `
154
  ymp3=$(($ymp3+0))
155
fi
156
#echo $ymp3
157

    
158
# total streams
159
grep total /tmp/ice2.txt > /dev/null 2>&1
160
if [ "$?" -ne "0" ]; then
161
  totals="0"
162
else
163
  totals=`grep total /tmp/ice2.txt | cut -d ":" -f 2 - `
164
  totals=$(($totals+0))
165
fi
166
#echo $totals
167

    
168
# output=`echo $coologg:$coolmp3:$jamzogg:$jamzmp3:$joyogg:$joymp3:$yogg:$ymp3:$totals`
169

    
170

    
171
cat <<EOF
172
cool_ogg.value $coologg
173
cool_mp3.value $coolmp3
174
jamz_ogg.value $jamzogg
175
jamz_mp3.value $jamzmp3
176
joy_ogg.value $joyogg
177
joy_mp3.value $joymp3
178
y_ogg.value $yogg
179
y_mp3.value $ymp3
180
EOF
181