root / plugins / chat / tinychat_users_ @ 17f78427
Historique | Voir | Annoter | Télécharger (1,37 ko)
| 1 | c6e8f029 | Deathjam | #!/bin/sh |
|---|---|---|---|
| 2 | ######################### |
||
| 3 | # tinychat_users_ |
||
| 4 | ######################### |
||
| 5 | 74ee8b7b | Deathjam | # Munin Plugin to track monitor the number of users a tinychat room gets. |
| 6 | c6e8f029 | Deathjam | # Author Phil Wray ( http://www.infjs.com ) |
| 7 | 17f78427 | Lars Kruse | # |
| 8 | 74ee8b7b | Deathjam | # |
| 9 | c6e8f029 | Deathjam | # |
| 10 | # Usage: |
||
| 11 | # ln -s /usr/share/munin/plugins/tinychat_users_ /etc/munin/plugins/tinychat_users_your-room |
||
| 12 | # |
||
| 13 | 74ee8b7b | Deathjam | |
| 14 | c6e8f029 | Deathjam | # 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 | 189c3953 | Lars Kruse | if command -v curl >/dev/null 2>&1; then |
| 23 | c6e8f029 | Deathjam | 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 | 33e95e6f | Lars Kruse | echo 'graph_category chat' |
| 40 | c6e8f029 | Deathjam | echo 'total_count.label Room Users' |
| 41 | echo 'total_count.draw AREA' |
||
| 42 | 74ee8b7b | Deathjam | echo 'broadcaster_count.draw STACK' |
| 43 | 17f78427 | Lars Kruse | echo 'broadcaster_count.label Broadcasting' |
| 44 | c6e8f029 | Deathjam | 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 | 74ee8b7b | Deathjam | broadcasting_users=$(curl -s http://api.tinychat.com/${room}.json | grep -Eo 'broadcaster_count":[0-9]+' | cut -d':' -f2)
|
| 53 | c6e8f029 | Deathjam | # Output Room Users. |
| 54 | echo "total_count.value $tinychat_users" |
||
| 55 | 74ee8b7b | Deathjam | echo "broadcaster_count.value $broadcasting_users" |
