2013-09-06 23:33:30 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#########################
|
|
|
|
# tinychat_users_
|
|
|
|
#########################
|
2013-09-09 00:03:14 +02:00
|
|
|
# Munin Plugin to track monitor the number of users a tinychat room gets.
|
2013-09-06 23:33:30 +02:00
|
|
|
# Author Phil Wray ( http://www.infjs.com )
|
2013-09-09 00:03:14 +02:00
|
|
|
#
|
|
|
|
#
|
2013-09-06 23:33:30 +02:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# ln -s /usr/share/munin/plugins/tinychat_users_ /etc/munin/plugins/tinychat_users_your-room
|
|
|
|
#
|
2013-09-09 00:03:14 +02:00
|
|
|
|
2013-09-06 23:33:30 +02:00
|
|
|
# Get the Tinychat Room by parsing this scripts filename.
|
|
|
|
room=${0##*tinychat_users_}
|
|
|
|
|
|
|
|
##
|
|
|
|
# autoconf
|
|
|
|
##
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
# Check that curl is installed
|
2014-10-04 20:33:52 +02:00
|
|
|
if hash curl >/dev/null 2>&1; then
|
2013-09-06 23:33:30 +02:00
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "no (no curl installed)"
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
##
|
|
|
|
# config
|
|
|
|
##
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo "graph_title Tinychat Users for $room"
|
|
|
|
echo 'graph_vlabel Room Users'
|
|
|
|
echo 'graph_args --base 1000'
|
|
|
|
echo 'graph_scale no'
|
|
|
|
echo 'graph_vlabel Room Users'
|
2013-09-16 11:36:47 +02:00
|
|
|
echo 'graph_category Chat'
|
2013-09-06 23:33:30 +02:00
|
|
|
echo 'total_count.label Room Users'
|
|
|
|
echo 'total_count.draw AREA'
|
2013-09-09 00:03:14 +02:00
|
|
|
echo 'broadcaster_count.draw STACK'
|
|
|
|
echo 'broadcaster_count.label Broadcasting'
|
2013-09-06 23:33:30 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
##
|
|
|
|
# Main
|
|
|
|
##
|
|
|
|
# Get current Room Users.
|
|
|
|
tinychat_users=$(curl -s http://api.tinychat.com/${room}.json | grep -Eo 'total_count":[0-9]+' | cut -d':' -f2)
|
2013-09-09 00:03:14 +02:00
|
|
|
broadcasting_users=$(curl -s http://api.tinychat.com/${room}.json | grep -Eo 'broadcaster_count":[0-9]+' | cut -d':' -f2)
|
2013-09-06 23:33:30 +02:00
|
|
|
# Output Room Users.
|
|
|
|
echo "total_count.value $tinychat_users"
|
2013-09-09 00:03:14 +02:00
|
|
|
echo "broadcaster_count.value $broadcasting_users"
|