Projet

Général

Profil

Révision 9694ad80

ID9694ad80283ad10a16f24b41de94f3282b7e96b7
Parent 46b273fd
Enfant c4a82cdd

Ajouté par Alejandro Olivan Alvarez il y a presque 14 ans

- new plugin for shoutcast v2

Voir les différences:

plugins/other/shoutcast2
1
#!/usr/bin/php
2
<?php
3

  
4
// NAME
5
// shoutcast online - Munin plugin to show online for shoutcast v2.0
6

  
7
// CONFIGURATION
8
// none
9

  
10
// MAGIC MARKERS
11

  
12
#%# family=auto
13
#%# capabilities=autoconf
14

  
15

  
16
// VERSION
17
// 1.0 32bit
18
// there are differences in the XML tags used between 32 and 64
19

  
20
// AUTHOR
21
// Alejandro Olivan Alvarez
22
// Based on original 1.9.8 perl plugin by Stanislav Rudenko aka Sandel
23
// Uses PHP shoutcast code by MADxHAWK & m4xin30n
24

  
25
// LICENSE
26
// none at the plugin
27

  
28
/**
29
 *
30
 * @package:    shoutcast
31
 * @version:    $Id: shoutcast.php 4 2011-12-02 17:27:36Z MADxHAWK $
32
 * @copyright:    (c) 2010 by Martin H. (madxhawk@radio-blackpearl.de)
33
 * @licence:
34
[url]http://opensource.org/licenses/gpl-license.php[/url] GNU Public
35
License
36
 *
37
 */
38

  
39
//
40
----------------------------------------------------------------------------
41
// You need to change data to your specific use
42
//
43
----------------------------------------------------------------------------
44
$useragent    = "Mozilla (DNAS 2 Statuscheck)";
45
$sc_host    = 'yourhost.example.com';
46
$sc_port    = '8000';
47
$sc_user    = 'your_admin_user';
48
$sc_pass    = 'your_password';
49
$sc_sid        = '1';
50

  
51

  
52
//
53
----------------------------------------------------------------------------
54
// DO NOT EDIT
55
//
56
----------------------------------------------------------------------------
57

  
58
//init curl connection
59

  
60
$ch = curl_init($sc_host . '/admin.cgi?sid=' . $sc_sid .
61
'&mode=viewxml');
62

  
63

  
64
// set curl connection parameter
65
curl_setopt($ch, CURLOPT_PORT, $sc_port);
66
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
67
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
68
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
69
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
70
curl_setopt($ch, CURLOPT_USERPWD, $sc_user . ':' . $sc_pass);
71

  
72
// connect to shoutcastserver
73
$curl = curl_exec($ch);
74

  
75

  
76

  
77
// now get the xml data
78
if ($curl)
79
{
80
   $xml = @simplexml_load_string($curl);
81

  
82
   $dnas_data = array (
83
       'CURRENTLISTENERS'    => (string)$xml->CURRENTLISTENERS,
84
       'PEAKLISTENERS'        => (string)$xml->PEAKLISTENERS,
85
       'MAXLISTENERS'        => (string)$xml->MAXLISTENERS,
86
       'UNIQUELISTENERS'    => (string)$xml->UNIQUELISTENERS,
87
           );
88

  
89
   // this is the usual case, generating a label and value
90
   echo("max_connections.value {$dnas_data['MAXLISTENERS']}\n");
91
   echo("ax_used_connections.value {$dnas_data['PEAKLISTENERS']}\n");
92
   echo("all_connections.value {$dnas_data['CURRENTLISTENERS']}\n");
93
   echo("unique_connections.value {$dnas_data['UNIQUELISTENERS']}\n");
94

  
95

  
96
}
97
else
98
{
99
   $dnas_data = array('ERROR' => 'Could not connect to dnas-server!');
100
   echo("\n");
101
}
102

  
103

  
104

  
105
// this is for munin's configuration tool
106
// could do something more complicated here
107
if(count($argv) == 2 && $arv[1] == 'authconf') {
108
       exit('yes');
109
}
110

  
111

  
112

  
113
// this is for rrdtool to know how to label the graph
114

  
115
   // Default Settings
116
if(count($argv) == 2 && $argv[1] == 'config') {
117
       echo("graph_title SHOUTcast Online on GlobalMobile port 8026\n");
118
       echo("graph_args --base 1000\n");
119
       echo("graph_category shoutcast\n");
120
       echo("graph_vlabel Connections per \${graph_period}\n");
121

  
122
   // Max Listeners Allowed to Connect to Server
123
       echo("max_connections.draw AREA\n\n");
124
       echo("max_connections.colour cdcfc4\n");
125
       echo("max_connections.min 0\n");
126
       echo("max_connections.label Max Slots\n");
127
       echo("max_connections.type GAUGE\n");
128

  
129
   // Peak Listeners
130
       echo("ax_used_connections.draw AREA\n");
131
       echo("ax_used_connections.colour ffd660\n");
132
       echo("ax_used_connections.min 0\n");
133
       echo("ax_used_connections.label Peak Listeners\n");
134
       echo("ax_used_connections.type GAUGE\n");
135

  
136
    // Max Listeners Connected to Server
137
       echo("all_connections.draw LINE1\n");
138
       echo("all_connections.colour a00e95\n");
139
       echo("all_connections.min 0\n");
140
       echo("all_connections.label Listeners\n");
141
       echo("all_connections.type GAUGE\n");
142

  
143
   // Max Unique Listeners Connected to Server
144
       echo("unique_connections.draw LINE1\n");
145
       echo("unique_connections.colour 330099\n");
146
       echo("unique_connections.min 0\n");
147
       echo("unique_connections.label Unique Listeners\n");
148
       echo("unique_connections.type GAUGE\n");
149

  
150
               exit();
151

  
152
}
153

  
154
//closing the connection
155
curl_close($ch);
156

  
157

  
158
?>

Formats disponibles : Unified diff