root / plugins / streaming / shoutcast @ 31412baa
Historique | Voir | Annoter | Télécharger (3,63 ko)
| 1 | dc7486cf | Stanislav Rudenko | #!/usr/local/bin/perl -w |
|---|---|---|---|
| 2 | # -*- cperl -*- |
||
| 3 | |||
| 4 | =head1 NAME |
||
| 5 | |||
| 6 | shoutcast online - Munin plugin to show online for shoutcast v1.9.8 |
||
| 7 | |||
| 8 | =head1 CONFIGURATION |
||
| 9 | |||
| 10 | This shows the default configuration of this plugin. You can override |
||
| 11 | the status URL. |
||
| 12 | |||
| 13 | [shoutcast*] |
||
| 14 | env.url http://localhost:8000/7.html |
||
| 15 | |||
| 16 | =head1 MAGIC MARKERS |
||
| 17 | |||
| 18 | #%# family=auto |
||
| 19 | #%# capabilities=autoconf |
||
| 20 | |||
| 21 | =head1 VERSION |
||
| 22 | |||
| 23 | 1.0 |
||
| 24 | |||
| 25 | =head1 AUTHOR |
||
| 26 | |||
| 27 | Stanislav Rudenko aka Sandel |
||
| 28 | |||
| 29 | =head1 LICENSE |
||
| 30 | |||
| 31 | none |
||
| 32 | |||
| 33 | =cut |
||
| 34 | |||
| 35 | my $ret = undef; |
||
| 36 | |||
| 37 | if (! eval "require LWP::UserAgent;"){
|
||
| 38 | $ret = "LWP::UserAgent not found"; |
||
| 39 | } |
||
| 40 | |||
| 41 | my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://localhost:8000/7.html";
|
||
| 42 | |||
| 43 | if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
||
| 44 | if ($ret){
|
||
| 45 | print "no ($ret)\n"; |
||
| 46 | exit 0; |
||
| 47 | } |
||
| 48 | |||
| 49 | my $ua = LWP::UserAgent->new(timeout => 30); |
||
| 50 | $ua->agent('XML Getter (Mozilla Compatible)');
|
||
| 51 | |||
| 52 | my $request = HTTP::Request->new( 'GET' => $URL ); |
||
| 53 | $request->protocol('HTTP/1.0');
|
||
| 54 | |||
| 55 | my $response = $ua->request($request); |
||
| 56 | |||
| 57 | unless ($response->is_success and $response->content =~ /<HTML><meta http-equiv="Pragma" content="no-cache"><\/head><body>/im) {
|
||
| 58 | print "no (no shoutcast status on $URL)\n"; |
||
| 59 | exit 0; |
||
| 60 | } else {
|
||
| 61 | print "yes\n"; |
||
| 62 | exit 0; |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
|
||
| 67 | |||
| 68 | # Default Settings |
||
| 69 | print "graph_title SHOUTcast Online\n"; |
||
| 70 | print "graph_args --base 1000\n"; |
||
| 71 | print "graph_category shoutcast\n"; |
||
| 72 | print "graph_vlabel Connections per \${graph_period}\n";
|
||
| 73 | |||
| 74 | # Max Listeners Allowed to Connect to Server |
||
| 75 | print "max_connections.draw AREA\n"; |
||
| 76 | print "max_connections.colour cdcfc4\n"; |
||
| 77 | print "max_connections.min 0\n"; |
||
| 78 | print "max_connections.label Max Slots\n"; |
||
| 79 | print "max_connections.type GAUGE\n"; |
||
| 80 | |||
| 81 | # Peak Listeners |
||
| 82 | print "ax_used_connections.draw AREA\n"; |
||
| 83 | print "ax_used_connections.colour ffd660\n"; |
||
| 84 | print "ax_used_connections.min 0\n"; |
||
| 85 | print "ax_used_connections.label Peak Listeners\n"; |
||
| 86 | print "ax_used_connections.type GAUGE\n"; |
||
| 87 | |||
| 88 | # DJ-Online tag must be eq to Peak Listeners |
||
| 89 | print "djonline_tag.draw AREA\n"; |
||
| 90 | print "djonline_tag.colour e5ff60\n"; |
||
| 91 | print "djonline_tag.min 0\n"; |
||
| 92 | print "djonline_tag.label DJ-Online Tag\n"; |
||
| 93 | print "djonline_tag.type GAUGE\n"; |
||
| 94 | |||
| 95 | # Max Listeners Connected to Server |
||
| 96 | print "all_connections.draw LINE1\n"; |
||
| 97 | print "all_connections.colour a00e95\n"; |
||
| 98 | print "all_connections.min 0\n"; |
||
| 99 | print "all_connections.label Listeners\n"; |
||
| 100 | print "all_connections.type GAUGE\n"; |
||
| 101 | |||
| 102 | # Max Unique Listeners Connected to Server |
||
| 103 | print "unique_connections.draw LINE1\n"; |
||
| 104 | print "unique_connections.colour 330099\n"; |
||
| 105 | print "unique_connections.min 0\n"; |
||
| 106 | print "unique_connections.label Unique Listeners\n"; |
||
| 107 | print "unique_connections.type GAUGE\n"; |
||
| 108 | |||
| 109 | exit 0; |
||
| 110 | } |
||
| 111 | |||
| 112 | #my $ua = LWP::UserAgent->new(timeout => 30); |
||
| 113 | #my $response = $ua->request(HTTP::Request->new('GET',$URL));
|
||
| 114 | |||
| 115 | my $ua = LWP::UserAgent->new(timeout => 30); |
||
| 116 | $ua->agent('XML Getter (Mozilla Compatible)');
|
||
| 117 | |||
| 118 | my $request = HTTP::Request->new( 'GET' => $URL ); |
||
| 119 | $request->protocol('HTTP/1.0');
|
||
| 120 | |||
| 121 | my $response = $ua->request($request); |
||
| 122 | |||
| 123 | #<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>89,1,453,800,87,128,Kitadani Hiroshi - Bushi</body> |
||
| 124 | #print $response->content . "\n\n"; |
||
| 125 | |||
| 126 | if ( $response->content =~ /<HTML><meta http-equiv="Pragma" content="no-cache"><\/head><body>(\d+),(\d+),(\d+),(\d+),(\d+),(\d+),(.*)<\/body>/s ) {
|
||
| 127 | |||
| 128 | my $djonline = ( $7 =~ m/Dj-Online/i ) ? $3 : '0'; |
||
| 129 | |||
| 130 | print "max_connections.value $4\n"; |
||
| 131 | print "ax_used_connections.value $3\n"; |
||
| 132 | print "djonline_tag.value $djonline\n"; |
||
| 133 | print "all_connections.value $1\n"; |
||
| 134 | print "unique_connections.value $5\n"; |
||
| 135 | } else {
|
||
| 136 | print "\n"; |
||
| 137 | } |
