Projet

Général

Profil

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

root / plugins / chat / tinychat_users_ @ 17f78427

Historique | Voir | Annoter | Télécharger (1,37 ko)

1
#!/bin/sh
2
#########################
3
# tinychat_users_
4
#########################
5
# Munin Plugin to track monitor the number of users a tinychat room gets.
6
# Author Phil Wray ( http://www.infjs.com )
7
#
8
#
9
#
10
# Usage:
11
# 	ln -s /usr/share/munin/plugins/tinychat_users_ /etc/munin/plugins/tinychat_users_your-room
12
#
13

    
14
# Get the Tinychat Room by parsing this scripts filename.
15
room=${0##*tinychat_users_}
16

    
17
##
18
# autoconf
19
##
20
if [ "$1" = "autoconf" ]; then
21
    # Check that curl is installed
22
    if command -v curl >/dev/null 2>&1; then
23
echo "yes"
24
    else
25
echo "no (no curl installed)"
26
    fi
27
exit 0
28
fi
29

    
30
##
31
# config
32
##
33
if [ "$1" = "config" ]; then
34
echo "graph_title Tinychat Users for $room"
35
    echo 'graph_vlabel Room Users'
36
    echo 'graph_args --base 1000'
37
    echo 'graph_scale no'
38
    echo 'graph_vlabel Room Users'
39
    echo 'graph_category chat'
40
    echo 'total_count.label Room Users'
41
    echo 'total_count.draw AREA'
42
    echo 'broadcaster_count.draw STACK'
43
    echo 'broadcaster_count.label Broadcasting'
44
    exit 0
45
fi
46

    
47
##
48
# Main
49
##
50
# Get current Room Users.
51
tinychat_users=$(curl -s http://api.tinychat.com/${room}.json | grep -Eo 'total_count":[0-9]+' | cut -d':' -f2)
52
broadcasting_users=$(curl -s http://api.tinychat.com/${room}.json | grep -Eo 'broadcaster_count":[0-9]+' | cut -d':' -f2)
53
# Output Room Users.
54
echo "total_count.value $tinychat_users"
55
echo "broadcaster_count.value $broadcasting_users"