/usr/share/munin/plugins/squeezebox_ is in munin-node 1.4.6-3ubuntu3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | #!/bin/bash
: <<=cut
=head1 NAME
squeezebox_ - plugin to monitor a SqueezeCenter and associated
players.
=head1 APPLICABLE SYSTEMS
Probably any system running SqueezeCenter. Change the host to allow
for remote monitoring.
=head1 CONFIGURATION
No configuration should be required if run on the same server as
SqueezeCenter. If the plugin is run from another unit or in a
non-default configuration, please use the environment variables
'squeezebox_host' and 'squeezebox_port' to connect. Also, if your
netcat(1) binary is anywhere else than /bin/nc please define it in the
plugin's environment file (/etc/munin/squeezebox or
similar). Sample follows:
[squeezebox_*]
env.squeezebox_host 192.168.100.10
env.squeezebox_port 9095
env.netcat /usr/local/bin/nc
=head1 INTERPRETATION
The "volume" graphs only graphs the player's volume, not the amplifier
or whatever the player is connected to.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf suggest
=head1 VERSION
$Id: squeezebox_.in 2919 2009-11-09 10:45:14Z bjorn $
=head1 BUGS
None known
=head1 AUTHOR
Bjørn Ruberg
=head1 LICENSE
GPLv2
=cut
#%# family=auto
#%# capabilities=autoconf suggest
HOST=${squeezecenter_host:-localhost}
PORT=${squeezecenter_port:-9090}
NC=${netcat:-/bin/nc}
if [ "$1" = "autoconf" ]; then
if [ ! "which $NC 1>/dev/null 2>&1" ]; then
echo "no (no netcat/nc binary found)"
exit 0
fi
echo exit | $NC $HOST $PORT 1>/dev/null 2>&1
RET=$?
if [ "$RET" != "0" ]; then
echo "no (no connection on $HOST port $PORT)"
exit 0
fi
VERSION=$(printf "%b" "version ?\nexit\n" | $NC $HOST $PORT 2>/dev/null)
if [ "$VERSION" != "" ]; then
echo "yes"
exit 0
else
echo "no (socket responding but version not found: something is weird)"
exit 0
fi
fi
if [ "$1" = "suggest" ]; then
echo "songs"
echo "artists"
echo "albums"
echo "genres"
echo "years"
echo "signalstrength"
echo "volume"
exit 0
fi
# Add this plugin to a cron job with the argument "update"
# Adjust the interval to your own tempo for adding/deleting
# music :-)
#
# example: 5 * * * * /usr/share/munin/plugins/squeezebox_ update
if [ "$1" = "update" ]; then
printf "%b" "rescan\nexit\n" | $NC $HOST $PORT >/dev/null
exit 0
fi
CHECK=$(echo $0 | cut -d _ -f 2-)
case "$CHECK" in
songs)
ATTR="songs"
;;
artists)
ATTR="artists"
;;
albums)
ATTR="albums"
;;
genres)
ATTR="genres"
;;
years)
CMD="years"
;;
signalstrength)
CMD="signalstrength"
TITLE="Signal strength"
;;
volume)
CMD="mixer volume"
TITLE="Mixer volume"
;;
*)
echo "Can't run without a proper symlink. Exiting."
echo "Try running munin-node-configure --suggest."
exit 1
;;
esac
if [ "$ATTR" = "" -a "$CMD" = "" ]; then
echo "Urk"
exit 2
fi
if [ "$CMD" = "years" ]; then
no_of_years=$(printf "%b" "years\nexit\n" | $NC $HOST $PORT | sed 's/%3A/:/g' | cut -d ':' -f 2)
years_array=$(printf "%b" "years 0 $no_of_years\nexit\n" | $NC $HOST $PORT | sed 's/%3A/:/g' | cut -d ' ' -f 4- | sed 's/year://g' | cut -d ' ' -f -$no_of_years)
arr1=( `echo "$years_array" | tr -s ' ' ' '` )
(( no_of_years-- )) # We don't need that last entry in the array
if [ "$1" = "config" ]; then
echo "graph_title Number of years"
echo "graph_category Squeezebox"
echo "graph_args --base 1000 -l 0"
# echo -n "graph_order "
# echo $years_array | tr '[:space:]' " y"
# echo "graph_order y0"
echo -n "graph_order y"; echo $years_array | sed 's/ / y/g'
for i in `seq 0 $no_of_years`; do
year=$(echo ${arr1[$i]})
if [ $year = 0 ]; then
echo y0.label No year
else
echo y${year}.label $year
fi
if [ $i = 0 ]; then
echo y${year}.draw AREA
else
echo y${year}.draw STACK
fi
done
exit 0
fi
for i in `seq 0 $no_of_years`; do
year=$(echo ${arr1[$i]})
echo -n "y${year}.value "
printf "%b" "albums 0 0 year:${year}\nexit\n" | $NC $HOST $PORT | sed 's/%3A/:/g' | cut -d ':' -f 3
done
elif [ "$CMD" = "signalstrength" -o "$CMD" = "mixer volume" ]; then
if [ "$1" = "config" ]; then
echo "graph_title $TITLE"
echo "graph_category Squeezebox"
COUNT=$(printf "%b" "player count ?\nexit\n" | $NC $HOST $PORT | cut -d " " -f 3)
(( COUNT-- ))
for ID in $(seq 0 $COUNT); do
MAC=$(printf "%b" "player id $ID ?\nexit\n" | $NC $HOST $PORT | cut -d " " -f 4 | sed 's/%3A/:/g')
NAME=$(printf "%b" "player name $MAC ?\nexit\n" | $NC $HOST $PORT | cut -d " " -f 4 | sed 's/%20/ /g')
MAC2=$(echo $MAC | sed 's/://g; s/\./_/g')
echo "$MAC2.label $NAME"
done
exit 0
fi
COUNT=$(printf "%b" "player count ?\nexit\n" | $NC $HOST $PORT | cut -d " " -f 3)
(( COUNT-- ))
for ID in $(seq 0 $COUNT); do
MAC=$(printf "%b" "player id $ID ?\nexit\n" | $NC $HOST $PORT | cut -d " " -f 4 | sed 's/%3A/:/g')
VAL=$(printf "%b" "$MAC $CMD ?\nexit\n"| $NC $HOST $PORT | cut -d " " -f 2- | sed "s/$CMD //")
MAC2=$(echo $MAC| sed 's/://g')
echo "$MAC2.value $VAL"
done
else
if [ "$1" = "config" ]; then
echo "graph_title Number of $ATTR"
echo "graph_scale no"
echo "graph_category Squeezebox"
echo "$ATTR.label $ATTR"
exit 0
fi
CMD="info total $ATTR "
echo -n "$ATTR.value "
printf "%b" "$CMD ?\nexit\n" | $NC $HOST $PORT | sed "s/^$CMD//"
fi
|