mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
shoutcast application monitor. improvements to powerdns application monitor
git-svn-id: http://www.observium.org/svn/observer/trunk@2606 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,36 +1,32 @@
|
||||
<?php
|
||||
|
||||
$scale_min = 0;
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$scale_min = 0;
|
||||
$colours = "red";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'corruptPackets' => array('descr' => 'Corrupt', 'colour' => 'FF8800FF'),
|
||||
'servfailPackets' => array('descr' => 'Failed', 'colour' => 'FF0000FF'),
|
||||
'q_timedout' => array('descr' => 'Timedout', 'colour' => 'FFFF00FF'),
|
||||
);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
$array = array('corruptPackets' => array('descr' => 'Corrupt', 'colour' => 'FF8800FF'),
|
||||
'servfailPackets' => array('descr' => 'Failed', 'colour' => 'FF0000FF'),
|
||||
'q_timedout' => array('descr' => 'Timed out', 'colour' => 'FFFF00FF'),
|
||||
);
|
||||
|
||||
|
||||
$i = 0;
|
||||
if (is_file($rrd_filename))
|
||||
{
|
||||
foreach ($array as $ds => $vars)
|
||||
{
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else { echo("file missing: $file"); }
|
||||
|
||||
$colours = "red";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
?>
|
||||
|
@@ -1,27 +1,20 @@
|
||||
<?php
|
||||
|
||||
$scale_min = 0;
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$scale_min = 0;
|
||||
$ds = "latency";
|
||||
$colour_area = "6699FF";
|
||||
$colour_line = "336699";
|
||||
$colour_area_max = "FFEE99";
|
||||
$graph_max = 100;
|
||||
$unit_text = "Latency";
|
||||
$powerdns_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
|
||||
$powerdns_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
if (is_file($powerdns_rrd)) {
|
||||
$rrd_filename = $powerdns_rrd;
|
||||
}
|
||||
|
||||
if (is_file($powerdns_rrd))
|
||||
{
|
||||
$rrd_filename = $powerdns_rrd;
|
||||
}
|
||||
|
||||
$ds = "latency";
|
||||
|
||||
$colour_area = "6699FF";
|
||||
$colour_line = "336699";
|
||||
|
||||
$colour_area_max = "FFEE99";
|
||||
|
||||
$graph_max = 100;
|
||||
|
||||
$unit_text = "Latency";
|
||||
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
?>
|
||||
|
@@ -1,36 +1,32 @@
|
||||
<?php
|
||||
|
||||
$scale_min = 0;
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$scale_min = 0;
|
||||
$colours = "blue";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'pc_hit' => array('descr' => 'Hits', 'colour' => '008800FF'),
|
||||
'pc_miss' => array('descr' => 'Misses', 'colour' => '880000FF'),
|
||||
'pc_size' => array('descr' => 'Size', 'colour' => '006699FF'),
|
||||
);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
$array = array('pc_hit' => array('descr' => 'Hits', 'colour' => '008800FF'),
|
||||
'pc_miss' => array('descr' => 'Misses', 'colour' => '880000FF'),
|
||||
'pc_size' => array('descr' => 'Size', 'colour' => '006699FF'),
|
||||
);
|
||||
|
||||
|
||||
$i = 0;
|
||||
if (is_file($rrd_filename))
|
||||
{
|
||||
foreach ($array as $ds => $vars)
|
||||
{
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else { echo("file missing: $file"); }
|
||||
|
||||
$colours = "blue";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
?>
|
||||
|
@@ -1,37 +1,33 @@
|
||||
<?php
|
||||
|
||||
$scale_min = 0;
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$scale_min = 0;
|
||||
$colours = "mixed";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'q_tcpAnswers' => array('descr' => 'TCP Answers', 'colour' => '008800FF'),
|
||||
'q_tcpQueries' => array('descr' => 'TCP Queries', 'colour' => '00FF00FF'),
|
||||
'q_udpAnswers' => array('descr' => 'UDP Answers', 'colour' => '336699FF'),
|
||||
'q_udpQueries' => array('descr' => 'UDP Queries', 'colour' => '6699CCFF'),
|
||||
);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
$array = array('q_tcpAnswers' => array('descr' => 'TCP Answers', 'colour' => '008800FF'),
|
||||
'q_tcpQueries' => array('descr' => 'TCP Queries', 'colour' => '00FF00FF'),
|
||||
'q_udpAnswers' => array('descr' => 'UDP Answers', 'colour' => '336699FF'),
|
||||
'q_udpQueries' => array('descr' => 'UDP Queries', 'colour' => '6699CCFF'),
|
||||
);
|
||||
|
||||
|
||||
$i = 0;
|
||||
if (is_file($rrd_filename))
|
||||
{
|
||||
foreach ($array as $ds => $vars)
|
||||
{
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else { echo("file missing: $file"); }
|
||||
|
||||
$colours = "mixed";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
?>
|
||||
|
@@ -1,37 +1,33 @@
|
||||
<?php
|
||||
|
||||
$scale_min = 0;
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$scale_min = 0;
|
||||
$colours = "mixed";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'q_udp4Answers' => array('descr' => 'UDP4 Answers', 'colour' => '00008888'),
|
||||
'q_udp4Queries' => array('descr' => 'UDP4 Queries', 'colour' => '000088FF'),
|
||||
'q_udp6Answers' => array('descr' => 'UDP6 Answers', 'colour' => '88000088'),
|
||||
'q_udp6Queries' => array('descr' => 'UDP6 Queries', 'colour' => '880000FF'),
|
||||
);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
$array = array('q_udp4Answers' => array('descr' => 'UDP4 Answers\t', 'colour' => '00008888'),
|
||||
'q_udp4Queries' => array('descr' => 'UDP4 Queries ', 'colour' => '000088FF'),
|
||||
'q_udp6Answers' => array('descr' => 'UDP6 Answers ', 'colour' => '88000088'),
|
||||
'q_udp6Queries' => array('descr' => 'UDP6 Queries ', 'colour' => '880000FF'),
|
||||
);
|
||||
|
||||
|
||||
$i = 0;
|
||||
if (is_file($rrd_filename))
|
||||
{
|
||||
foreach ($array as $ds => $vars)
|
||||
{
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else { echo("file missing: $file"); }
|
||||
|
||||
$colours = "mixed";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
?>
|
||||
|
@@ -1,36 +1,31 @@
|
||||
<?php
|
||||
|
||||
$scale_min = 0;
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$scale_min = 0;
|
||||
$colours = "mixed";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'qc_miss' => array('descr' => 'Misses', 'colour' => '750F7DFF'),
|
||||
'qc_hit' => array('descr' => 'Hits', 'colour' => '00FF00FF'),
|
||||
);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
$array = array('qc_miss' => array('descr' => 'Misses', 'colour' => '750F7DFF'),
|
||||
'qc_hit' => array('descr' => 'Hits', 'colour' => '00FF00FF'),
|
||||
);
|
||||
|
||||
|
||||
$i = 0;
|
||||
if (is_file($rrd_filename))
|
||||
{
|
||||
foreach ($array as $ds => $vars)
|
||||
{
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else { echo("file missing: $file"); }
|
||||
|
||||
$colours = "mixed";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
|
||||
//include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
?>
|
||||
|
@@ -1,36 +1,31 @@
|
||||
<?php
|
||||
|
||||
$scale_min = 0;
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
$scale_min = 0;
|
||||
$colours = "mixed";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'rec_questions' => array('descr' => 'Questions', 'colour' => '6699CCFF'),
|
||||
'rec_answers' => array('descr' => 'Answers', 'colour' => '336699FF'),
|
||||
);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
$array = array('rec_questions' => array('descr' => 'Questions', 'colour' => '6699CCFF'),
|
||||
'rec_answers' => array('descr' => 'Answers', 'colour' => '336699FF'),
|
||||
);
|
||||
|
||||
|
||||
$i = 0;
|
||||
if (is_file($rrd_filename))
|
||||
{
|
||||
foreach ($array as $ds => $vars)
|
||||
{
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else { echo("file missing: $file"); }
|
||||
|
||||
$colours = "mixed";
|
||||
$nototal = 0;
|
||||
$unit_text = "Packets/sec";
|
||||
|
||||
//include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
?>
|
||||
|
27
html/includes/graphs/application/shoutcast_bits.inc.php
Normal file
27
html/includes/graphs/application/shoutcast_bits.inc.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
$units = "b";
|
||||
$total_units = "B";
|
||||
$colours_in = "greens";
|
||||
//$multiplier = "0";
|
||||
$colours_out = "blues";
|
||||
|
||||
$nototal = 1;
|
||||
|
||||
$ds_in = "traf_in";
|
||||
$ds_out = "traf_out";
|
||||
|
||||
$graph_title .= "::bits";
|
||||
|
||||
$colour_line_in = "006600";
|
||||
$colour_line_out = "000099";
|
||||
$colour_area_in = "CDEB8B";
|
||||
$colour_area_out = "C3D9FF";
|
||||
|
||||
$rrddir = $config['rrd_dir']."/".$device['hostname'];
|
||||
$hostname = (isset($_GET['hostname']) ? $_GET['hostname'] : "unkown");
|
||||
$rrd_filename = $rrddir."/app-shoutcast-".$app['app_id']."-".$hostname.".rrd";
|
||||
|
||||
include("includes/graphs/generic_bits.inc.php");
|
||||
|
||||
?>
|
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
$units = "b";
|
||||
$total_units = "B";
|
||||
$colours_in = "greens";
|
||||
$multiplier = "8";
|
||||
$colours_out = "blues";
|
||||
|
||||
$nototal = 1;
|
||||
|
||||
$ds_in = "traf_in";
|
||||
$ds_out = "traf_out";
|
||||
|
||||
$graph_title = "Traffic Statistic";
|
||||
|
||||
$colour_line_in = "006600";
|
||||
$colour_line_out = "000099";
|
||||
$colour_area_in = "CDEB8B";
|
||||
$colour_area_out = "C3D9FF";
|
||||
|
||||
$rrddir = $config['rrd_dir']."/".$device['hostname'];
|
||||
$files = array();
|
||||
$i = 0;
|
||||
|
||||
if ($handle = opendir($rrddir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if (eregi("app-shoutcast-".$app['app_id'], $file)) {
|
||||
array_push($files, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($files as $id=>$file) {
|
||||
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
|
||||
$hostname = eregi_replace('.rrd', '', $hostname);
|
||||
list($host, $port) = split('_', $hostname, 2);
|
||||
$rrd_filenames[] = $rrddir."/".$file;
|
||||
$rrd_list[$i]['filename'] = $rrddir."/".$file;
|
||||
$rrd_list[$i]['descr'] = $host.":".$port;
|
||||
$rrd_list[$i]['ds_in'] = $ds_in;
|
||||
$rrd_list[$i]['ds_out'] = $ds_out;
|
||||
$i++;
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_multi_bits_separated.inc.php");
|
||||
|
||||
?>
|
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
//$colour = "random";
|
||||
$unit_text = "ShoutCast Server";
|
||||
$total_text = "Total of all ShoutCast Servers";
|
||||
$nototal = 0;
|
||||
|
||||
$rrddir = $config['rrd_dir']."/".$device['hostname'];
|
||||
$files = array();
|
||||
$i = 0;
|
||||
$x = 0;
|
||||
|
||||
if ($handle = opendir($rrddir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if (eregi("app-shoutcast-".$app['app_id'], $file)) {
|
||||
array_push($files, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($files as $id=>$file) {
|
||||
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
|
||||
$hostname = eregi_replace('.rrd', '', $hostname);
|
||||
list($host, $port) = split('_', $hostname, 2);
|
||||
$rrd_filenames[] = $rrddir."/".$file;
|
||||
$rrd_list[$i]['filename'] = $rrddir."/".$file;
|
||||
$rrd_list[$i]['descr'] = $host.":".$port;
|
||||
$rrd_list[$i]['colour'] = $colour;
|
||||
$i++;
|
||||
}
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
if ($width > "500") {
|
||||
$descr_len = 38;
|
||||
} else {
|
||||
$descr_len = 8;
|
||||
$descr_len += round(($width - 250) / 8);
|
||||
}
|
||||
|
||||
if ($width > "500") {
|
||||
$rrd_options .= " COMMENT:\"".substr(str_pad($unit_text, $descr_len+2), 0, $descr_len+2)." Current Unique Average Peak\\n\"";
|
||||
} else {
|
||||
$rrd_options .= " COMMENT:\"".substr(str_pad($unit_text, $descr_len+5), 0, $descr_len+5)." Now Unique Average Peak\\n\"";
|
||||
}
|
||||
foreach ($rrd_list as $rrd) {
|
||||
$colours = (isset($rrd['colour']) ? $rrd['colour'] : "default");
|
||||
$strlen = ((strlen($rrd['descr'])<$descr_len) ? ($descr_len - strlen($rrd['descr'])) : "0");
|
||||
$descr = (isset($rrd['descr']) ? str_replace(":", "\:", substr(str_pad($rrd['descr'], $desc_len+$strlen), 0, $descr_len+$strlen)) : "Unkown");
|
||||
for ($z=0; $z<$strlen; $z++) { $descr .= " "; }
|
||||
if ($i) { $stack = "STACK"; }
|
||||
$colour = $config['graph_colours'][$colours][$x];
|
||||
$rrd_options .= " DEF:cur".$x."=".$rrd['filename'].":current:AVERAGE";
|
||||
$rrd_options .= " DEF:peak".$x."=".$rrd['filename'].":peak:MAX";
|
||||
$rrd_options .= " DEF:unique".$x."=".$rrd['filename'].":unique:AVERAGE";
|
||||
$rrd_options .= " VDEF:avg".$x."=cur".$x.",AVERAGE";
|
||||
$rrd_options .= " AREA:cur".$x."#".$colour.":\"".$descr."\":$stack";
|
||||
$rrd_options .= " GPRINT:cur".$x.":LAST:\"%6.2lf\"";
|
||||
$rrd_options .= " GPRINT:unique".$x.":LAST:\"%6.2lf%s\"";
|
||||
$rrd_options .= " GPRINT:avg".$x.":\"%6.2lf\"";
|
||||
$rrd_options .= " GPRINT:peak".$x.":LAST:\"%6.2lf\"";
|
||||
$rrd_options .= " COMMENT:\"\\n\"";
|
||||
if ($x) {
|
||||
$totcur .= ",cur".$x.",+";
|
||||
$totpeak .= ",peak".$x.",+";
|
||||
$totunique .= ",unique".$x.",+";
|
||||
}
|
||||
$x = (($x<count($config['graph_colours'][$colours])-1) ? $x+1 : 0);
|
||||
//$x++;
|
||||
}
|
||||
if (!$nototal) {
|
||||
$strlen = ((strlen($total_text)<$descr_len) ? ($descr_len - strlen($total_text)) : "0");
|
||||
$descr = (isset($total_text) ? str_replace(":", "\:", substr(str_pad($total_text, $desc_len+$strlen), 0, $descr_len+$strlen)) : "Total");
|
||||
$colour = $config['graph_colours'][$colours][$x];
|
||||
for ($z=0; $z<$strlen; $z++) { $descr .= " "; }
|
||||
$rrd_options .= " CDEF:totcur=cur0".$totcur;
|
||||
$rrd_options .= " CDEF:totunique=unique0".$totunique;
|
||||
$rrd_options .= " CDEF:totpeak=peak0".$totpeak;
|
||||
$rrd_options .= " VDEF:totavg=totcur,AVERAGE";
|
||||
$rrd_options .= " LINE2:totcur#".$colour.":\"".$descr."\"";
|
||||
$rrd_options .= " GPRINT:totcur:LAST:\"%6.2lf\"";
|
||||
$rrd_options .= " GPRINT:totunique:LAST:\"%6.2lf%s\"";
|
||||
$rrd_options .= " GPRINT:totavg:\"%6.2lf\"";
|
||||
$rrd_options .= " GPRINT:totpeak:LAST:\"%6.2lf\"";
|
||||
$rrd_options .= " COMMENT:\"\\n\"";
|
||||
}
|
||||
|
||||
?>
|
42
html/includes/graphs/application/shoutcast_stats.inc.php
Normal file
42
html/includes/graphs/application/shoutcast_stats.inc.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
$rrddir = $config['rrd_dir']."/".$device['hostname'];
|
||||
$hostname = (isset($_GET['hostname']) ? $_GET['hostname'] : "unkown");
|
||||
$rrd_filename = $rrddir."/app-shoutcast-".$app['app_id']."-".$hostname.".rrd";
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " DEF:cur=".$rrd_filename.":current:AVERAGE";
|
||||
$rrd_options .= " DEF:max=".$rrd_filename.":max:MAX";
|
||||
//$rrd_options .= " DEF:bit=".$rrd_filename.":bitrate:LAST";
|
||||
$rrd_options .= " DEF:bit=".$rrd_filename.":bitrate:MAX";
|
||||
$rrd_options .= " DEF:peak=".$rrd_filename.":peak:MAX";
|
||||
$rrd_options .= " DEF:unique=".$rrd_filename.":unique:AVERAGE";
|
||||
$rrd_options .= " DEF:status=".$rrd_filename.":status:AVERAGE";
|
||||
$rrd_options .= " CDEF:peakm=peak,1,-";
|
||||
$rrd_options .= " VDEF:avg=cur,AVERAGE";
|
||||
$rrd_options .= " VDEF:peakh=peakm,MAXIMUM";
|
||||
$rrd_options .= " CDEF:bitrate=bit,8,*";
|
||||
$rrd_options .= " CDEF:server=status,UN,1,0,IF";
|
||||
$rrd_options .= " CDEF:server_offline=status,1,LT,1,UNKN,IF";
|
||||
$rrd_options .= " CDEF:stream=max,UN,1,0,IF";
|
||||
$rrd_options .= " CDEF:stream_offline=max,1,LT,1,UNKN,IF";
|
||||
$rrd_options .= " AREA:cur#63C2FEFF:\"Current Listeners\"";
|
||||
if ($width >= 355) {
|
||||
$rrd_options .= " GPRINT:cur:LAST:\"\:%8.2lf\"";
|
||||
$rrd_options .= " GPRINT:max:LAST:\"from%8.2lf\"";
|
||||
$rrd_options .= " GPRINT:bitrate:LAST:\"(bitrate\:%8.2lf%s\"";
|
||||
$rrd_options .= " COMMENT:\")\\n\"";
|
||||
} else {
|
||||
$rrd_options .= " GPRINT:cur:LAST:\"\:%8.2lf\\n\"";
|
||||
}
|
||||
$rrd_options .= " AREA:unique#AADEFEFF:\"Unique Listeners \"";
|
||||
$rrd_options .= " GPRINT:unique:LAST:\"\:%8.2lf%s\\n\"";
|
||||
$rrd_options .= " HRULE:avg#FF9000FF:\"Average Listeners\"";
|
||||
$rrd_options .= " GPRINT:avg:\"\:%8.2lf\\n\"";
|
||||
$rrd_options .= " LINE1:peak#C000FFFF:\"Peak Listeners \"";
|
||||
$rrd_options .= " GPRINT:peak:LAST:\"\:%8.2lf\\n\"";
|
||||
$rrd_options .= " TICK:stream_offline#B4FF00FF:1.0:\"Streaming client offline\\n\"";
|
||||
$rrd_options .= " TICK:server_offline".$warn_colour_b."FF:1.0:\"Streaming server offline\"";
|
||||
|
||||
?>
|
62
html/pages/device/apps/shoutcast.inc.php
Normal file
62
html/pages/device/apps/shoutcast.inc.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
global $config;
|
||||
|
||||
$total = true;
|
||||
|
||||
$rrddir = $config['rrd_dir']."/".$device['hostname'];
|
||||
$files = array();
|
||||
|
||||
if ($handle = opendir($rrddir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if (eregi("app-shoutcast-".$app['app_id'], $file)) {
|
||||
array_push($files, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($total) && $total == true) {
|
||||
$graphs = array(
|
||||
'shoutcast_multi_bits' => 'Traffic Statistics - Total of all Shoutcast servers',
|
||||
'shoutcast_multi_stats' => 'Shoutcast Statistics - Total of all Shoutcast servers'
|
||||
);
|
||||
foreach ($graphs as $key => $text) {
|
||||
$graph_type = $key;
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "215";
|
||||
$graph_array['to'] = $now;
|
||||
$graph_array['id'] = $app['app_id'];
|
||||
$graph_array['type'] = "application_".$key;
|
||||
echo('<h3>'.$text.'</h3>');
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=5>");
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
echo("</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($files as $id=>$file) {
|
||||
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
|
||||
$hostname = eregi_replace('.rrd', '', $hostname);
|
||||
list($host, $port) = split('_', $hostname, 2);
|
||||
$graphs = array(
|
||||
'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')',
|
||||
'shoutcast_stats' => 'Shoutcast Statistics - '.$host.' (Port: '.$port.')'
|
||||
);
|
||||
foreach ($graphs as $key => $text) {
|
||||
$graph_type = $key;
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "215";
|
||||
$graph_array['to'] = $now;
|
||||
$graph_array['id'] = $app['app_id'];
|
||||
$graph_array['type'] = "application_".$key;
|
||||
$graph_array['hostname'] = $hostname;
|
||||
echo('<h3>'.$text.'</h3>');
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=5>");
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
echo("</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -2,51 +2,53 @@
|
||||
|
||||
## Polls Apache statistics from script via SNMP
|
||||
|
||||
$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd";
|
||||
$apache_cmd = $config['snmpget'] ." -m NET-SNMP-EXTEND-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$apache_cmd .= " nsExtendOutputFull.6.97.112.97.99.104.101";
|
||||
$apache = shell_exec($apache_cmd);
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd";
|
||||
$options = "-O qv";
|
||||
$oid = "nsExtendOutputFull.6.97.112.97.99.104.101";
|
||||
|
||||
$apache = snmp_get($device, $oid, $options);
|
||||
|
||||
echo(" apache");
|
||||
|
||||
list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers,
|
||||
$score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, $score_closing, $score_logging, $score_graceful, $score_idle, $score_open) = explode("\n", $apache);
|
||||
|
||||
if (!is_file($apache_rrd))
|
||||
{
|
||||
rrdtool_create($apache_rrd, "--step 300 \
|
||||
DS:access:DERIVE:600:0:125000000000 \
|
||||
DS:kbyte:DERIVE:600:0:125000000000 \
|
||||
DS:cpu:GAUGE:600:0:125000000000 \
|
||||
DS:uptime:GAUGE:600:0:125000000000 \
|
||||
DS:reqpersec:GAUGE:600:0:125000000000 \
|
||||
DS:bytespersec:GAUGE:600:0:125000000000 \
|
||||
DS:byesperreq:GAUGE:600:0:125000000000 \
|
||||
DS:busyworkers:GAUGE:600:0:125000000000 \
|
||||
DS:idleworkers:GAUGE:600:0:125000000000 \
|
||||
DS:sb_wait:GAUGE:600:0:125000000000 \
|
||||
DS:sb_start:GAUGE:600:0:125000000000 \
|
||||
DS:sb_reading:GAUGE:600:0:125000000000 \
|
||||
DS:sb_writing:GAUGE:600:0:125000000000 \
|
||||
DS:sb_keepalive:GAUGE:600:0:125000000000 \
|
||||
DS:sb_dns:GAUGE:600:0:125000000000 \
|
||||
DS:sb_closing:GAUGE:600:0:125000000000 \
|
||||
DS:sb_logging:GAUGE:600:0:125000000000 \
|
||||
DS:sb_graceful:GAUGE:600:0:125000000000 \
|
||||
DS:sb_idle:GAUGE:600:0:125000000000 \
|
||||
DS:sb_open:GAUGE:600:0:125000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
if (!is_file($rrd_filename)) {
|
||||
rrdtool_create($rrd_filename, "--step 300 \
|
||||
DS:access:DERIVE:600:0:125000000000 \
|
||||
DS:kbyte:DERIVE:600:0:125000000000 \
|
||||
DS:cpu:GAUGE:600:0:125000000000 \
|
||||
DS:uptime:GAUGE:600:0:125000000000 \
|
||||
DS:reqpersec:GAUGE:600:0:125000000000 \
|
||||
DS:bytespersec:GAUGE:600:0:125000000000 \
|
||||
DS:byesperreq:GAUGE:600:0:125000000000 \
|
||||
DS:busyworkers:GAUGE:600:0:125000000000 \
|
||||
DS:idleworkers:GAUGE:600:0:125000000000 \
|
||||
DS:sb_wait:GAUGE:600:0:125000000000 \
|
||||
DS:sb_start:GAUGE:600:0:125000000000 \
|
||||
DS:sb_reading:GAUGE:600:0:125000000000 \
|
||||
DS:sb_writing:GAUGE:600:0:125000000000 \
|
||||
DS:sb_keepalive:GAUGE:600:0:125000000000 \
|
||||
DS:sb_dns:GAUGE:600:0:125000000000 \
|
||||
DS:sb_closing:GAUGE:600:0:125000000000 \
|
||||
DS:sb_logging:GAUGE:600:0:125000000000 \
|
||||
DS:sb_graceful:GAUGE:600:0:125000000000 \
|
||||
DS:sb_idle:GAUGE:600:0:125000000000 \
|
||||
DS:sb_open:GAUGE:600:0:125000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
}
|
||||
|
||||
rrdtool_update($apache_rrd, "N:$total_access:$total_kbyte:$cpuload:$uptime:$reqpersec:$bytespersec:$bytesperreq:$busyworkers:$idleworkers:$score_wait:$score_start:$score_reading:$score_writing:$score_keepalive:$score_dns:$score_closing:$score_logging:$score_graceful:$score_idle:$score_open");
|
||||
rrdtool_update($rrd_filename, "N:$total_access:$total_kbyte:$cpuload:$uptime:$reqpersec:$bytespersec:$bytesperreq:$busyworkers:$idleworkers:$score_wait:$score_start:$score_reading:$score_writing:$score_keepalive:$score_dns:$score_closing:$score_logging:$score_graceful:$score_idle:$score_open");
|
||||
|
||||
?>
|
@@ -1,57 +1,57 @@
|
||||
<?php
|
||||
|
||||
## FIXME very oldskool snmp code used instead of 2009+ snmp_* functions...
|
||||
|
||||
## Polls powerdns statistics from script via SNMP
|
||||
|
||||
$powerdns_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$powerdns_cmd = $config['snmpget'] ." -m NET-SNMP-EXTEND-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$powerdns_cmd .= " nsExtendOutputFull.8.112.111.119.101.114.100.110.115";
|
||||
$powerdns = shell_exec($powerdns_cmd);
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-powerdns-".$app['app_id'].".rrd";
|
||||
$options = "-O qv";
|
||||
$oid = "nsExtendOutputFull.8.112.111.119.101.114.100.110.115";
|
||||
|
||||
$powerdns = snmp_get($device, $oid, $options);
|
||||
|
||||
echo(" powerdns");
|
||||
|
||||
list ($corrupt, $def_cacheInserts, $def_cacheLookup, $latency, $pc_hit, $pc_miss, $pc_size, $qsize, $qc_hit,
|
||||
$qc_miss, $rec_answers, $rec_questions, $servfail, $tcp_answers, $tcp_queries, $timedout,
|
||||
$udp_answers, $udp_queries, $udp4_answers, $udp4_queries, $udp6_answers, $udp6_queries) = explode("\n", $powerdns);
|
||||
|
||||
if (!is_file($powerdns_rrd))
|
||||
{
|
||||
rrdtool_create($powerdns_rrd, "--step 300 \
|
||||
DS:corruptPackets:DERIVE:600:0:125000000000 \
|
||||
DS:def_cacheInserts:DERIVE:600:0:125000000000 \
|
||||
DS:def_cacheLookup:DERIVE:600:0:125000000000 \
|
||||
DS:latency:DERIVE:600:0:125000000000 \
|
||||
DS:pc_hit:DERIVE:600:0:125000000000 \
|
||||
DS:pc_miss:DERIVE:600:0:125000000000 \
|
||||
DS:pc_size:DERIVE:600:0:125000000000 \
|
||||
DS:qsize:DERIVE:600:0:125000000000 \
|
||||
DS:qc_hit:DERIVE:600:0:125000000000 \
|
||||
DS:qc_miss:DERIVE:600:0:125000000000 \
|
||||
DS:rec_answers:DERIVE:600:0:125000000000 \
|
||||
DS:rec_questions:DERIVE:600:0:125000000000 \
|
||||
DS:servfailPackets:DERIVE:600:0:125000000000 \
|
||||
DS:q_tcpAnswers:DERIVE:600:0:125000000000 \
|
||||
DS:q_tcpQueries:DERIVE:600:0:125000000000 \
|
||||
DS:q_timedout:DERIVE:600:0:125000000000 \
|
||||
DS:q_udpAnswers:DERIVE:600:0:125000000000 \
|
||||
DS:q_udpQueries:DERIVE:600:0:125000000000 \
|
||||
DS:q_udp4Answers:DERIVE:600:0:125000000000 \
|
||||
DS:q_udp4Queries:DERIVE:600:0:125000000000 \
|
||||
DS:q_udp6Answers:DERIVE:600:0:125000000000 \
|
||||
DS:q_udp6Queries:DERIVE:600:0:125000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
if (!is_file($rrd_filename)) {
|
||||
rrdtool_create($rrd_filename, "--step 300 \
|
||||
DS:corruptPackets:DERIVE:600:0:125000000000 \
|
||||
DS:def_cacheInserts:DERIVE:600:0:125000000000 \
|
||||
DS:def_cacheLookup:DERIVE:600:0:125000000000 \
|
||||
DS:latency:DERIVE:600:0:125000000000 \
|
||||
DS:pc_hit:DERIVE:600:0:125000000000 \
|
||||
DS:pc_miss:DERIVE:600:0:125000000000 \
|
||||
DS:pc_size:DERIVE:600:0:125000000000 \
|
||||
DS:qsize:DERIVE:600:0:125000000000 \
|
||||
DS:qc_hit:DERIVE:600:0:125000000000 \
|
||||
DS:qc_miss:DERIVE:600:0:125000000000 \
|
||||
DS:rec_answers:DERIVE:600:0:125000000000 \
|
||||
DS:rec_questions:DERIVE:600:0:125000000000 \
|
||||
DS:servfailPackets:DERIVE:600:0:125000000000 \
|
||||
DS:q_tcpAnswers:DERIVE:600:0:125000000000 \
|
||||
DS:q_tcpQueries:DERIVE:600:0:125000000000 \
|
||||
DS:q_timedout:DERIVE:600:0:125000000000 \
|
||||
DS:q_udpAnswers:DERIVE:600:0:125000000000 \
|
||||
DS:q_udpQueries:DERIVE:600:0:125000000000 \
|
||||
DS:q_udp4Answers:DERIVE:600:0:125000000000 \
|
||||
DS:q_udp4Queries:DERIVE:600:0:125000000000 \
|
||||
DS:q_udp6Answers:DERIVE:600:0:125000000000 \
|
||||
DS:q_udp6Queries:DERIVE:600:0:125000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
}
|
||||
|
||||
rrdtool_update($powerdns_rrd, "N:$corrupt:$def_cacheInserts:$def_cacheLookup:$latency:$pc_hit:$pc_miss:$pc_size:$qsize:$qc_hit:$qc_miss:$rec_answers:$rec_questions:$servfail:$tcp_answers:$tcp_queries:$timedout:$udp_answers:$udp_queries:$udp4_answers:$udp4_queries:$udp6_answers:$udp6_queries");
|
||||
rrdtool_update($rrd_filename, "N:$corrupt:$def_cacheInserts:$def_cacheLookup:$latency:$pc_hit:$pc_miss:$pc_size:$qsize:$qc_hit:$qc_miss:$rec_answers:$rec_questions:$servfail:$tcp_answers:$tcp_queries:$timedout:$udp_answers:$udp_queries:$udp4_answers:$udp4_queries:$udp6_answers:$udp6_queries");
|
||||
|
||||
?>
|
||||
|
55
includes/polling/applications/shoutcast.inc.php
Normal file
55
includes/polling/applications/shoutcast.inc.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
## Polls shoutcast statistics from script via SNMP
|
||||
|
||||
$options = "-O qv";
|
||||
$oid = "nsExtendOutputFull.9.115.104.111.117.116.99.97.115.116";
|
||||
|
||||
$shoutcast = snmp_get($device, $oid, $options);
|
||||
|
||||
echo(" shoutcast");
|
||||
|
||||
$servers = explode("\n", $shoutcast);
|
||||
|
||||
foreach ($servers as $item=>$server) {
|
||||
$server = trim($server);
|
||||
if (!empty($server)) {
|
||||
$data = explode(";", $server);
|
||||
list($host, $port) = split(":", $data['0'], 2);
|
||||
$bitrate = $data['1'];
|
||||
$traf_in = $data['2'];
|
||||
$traf_out = $data['3'];
|
||||
$current = $data['4'];
|
||||
$status = $data['5'];
|
||||
$peak = $data['6'];
|
||||
$max = $data['7'];
|
||||
$unique = $data['8'];
|
||||
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-shoutcast-".$app['app_id']."-".$host."_".$port.".rrd";
|
||||
if (!is_file($rrdfile)) {
|
||||
rrdtool_create($rrdfile, "--step 300 \
|
||||
DS:bitrate:GAUGE:600:0:125000000000 \
|
||||
DS:traf_in:GAUGE:600:0:125000000000 \
|
||||
DS:traf_out:GAUGE:600:0:125000000000 \
|
||||
DS:current:GAUGE:600:0:125000000000 \
|
||||
DS:status:GAUGE:600:0:125000000000 \
|
||||
DS:peak:GAUGE:600:0:125000000000 \
|
||||
DS:max:GAUGE:600:0:125000000000 \
|
||||
DS:unique:GAUGE:600:0:125000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
}
|
||||
rrdtool_update($rrdfile, "N:$bitrate:$traf_in:$traf_out:$current:$status:$peak:$max:$unique");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
3
scripts/shoutcast.default.conf
Normal file
3
scripts/shoutcast.default.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
server1:8050
|
||||
server2:8000
|
||||
server2:8010
|
119
scripts/shoutcast.php
Normal file
119
scripts/shoutcast.php
Normal file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
########################################################################################
|
||||
##
|
||||
## A small script to grab the realtime statistics from a ShoutCast server
|
||||
## Needed commands: php
|
||||
##
|
||||
## Install:
|
||||
## Edit the shoutcast.conf file
|
||||
## Add a crontab (every 5 min) for:
|
||||
## /opt/observium/scripts/shoutcast.php makeCache
|
||||
## Add the following to your snmpd.conf file:
|
||||
## extend shoutcast /opt/observium/scripts/shoutcast.php
|
||||
##
|
||||
## Version 1.0 By:
|
||||
## All In One - Dennis de Houx <info@all-in-one.be>
|
||||
##
|
||||
########################################################################################
|
||||
|
||||
|
||||
#### START SETTINGS ####
|
||||
|
||||
$config = "/opt/observium/scripts/shoutcast.conf";
|
||||
$cache = "/opt/observium/scripts/shoutcast.cache";
|
||||
|
||||
#### END SETTINGS ####
|
||||
|
||||
|
||||
##
|
||||
## DO NOT EDIT BENETH THIS LINE
|
||||
##
|
||||
########################################################################################
|
||||
|
||||
/* Do NOT run this script through a web browser */
|
||||
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
|
||||
die('<span style="color: #880000; text-weight: bold; font-size: 1.3em;">This script is only meant to run at the command line.</span>');
|
||||
}
|
||||
|
||||
function get_data($host, $port) {
|
||||
$fp = @fsockopen($host, $port, &$errno, &$errstr, 5);
|
||||
if(!$fp) { $connect = 0; }
|
||||
if (!isset($connect)) {
|
||||
fputs($fp, "GET /7.html HTTP/1.0\r\n"
|
||||
. "User-Agent: All In One - SHOUTcast Stats Parser"
|
||||
. " (Mozilla Compatible)\r\n\r\n");
|
||||
while (!feof($fp)) {
|
||||
$rawdata = fgets($fp, 1024);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
preg_match('/body>(.*)<\/body/', $rawdata, $matches);
|
||||
$res = explode(',', $matches[1], 7);
|
||||
$res[7] = $host;
|
||||
$res[8] = $port;
|
||||
return $res;
|
||||
}
|
||||
|
||||
function get_list($config) {
|
||||
if (file_exists($config)) {
|
||||
$servers = file($config);
|
||||
$data = array();
|
||||
foreach ($servers as $item=>$server) {
|
||||
list($host, $port) = split(":", $server, 2);
|
||||
array_push($data, get_data(trim($host), trim($port)));
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
function doSNMPv2($vars) {
|
||||
$res = array();
|
||||
foreach ($vars as $items=>$server) {
|
||||
$var['bitrate'] = (isset($server['5']) ? (($server['5'] / 8) * 1000) : "0");
|
||||
//$var['bitrate'] = (isset($server['5']) ? ($server['5'] * 1024) : "0");
|
||||
$var['traf_in'] = (isset($server['1']) ? ($var['bitrate'] * $server['1']) : "0");
|
||||
$var['traf_out'] = (isset($server['0']) ? ($var['bitrate'] * $server['0']) : "0");
|
||||
$var['current'] = (isset($server['0']) ? $server['0'] : "0");
|
||||
$var['status'] = (isset($server['1']) ? $server['1'] : "0");
|
||||
$var['peak'] = (isset($server['2']) ? $server['2'] : "0");
|
||||
$var['max'] = (isset($server['3']) ? $server['3'] : "0");
|
||||
$var['unique'] = (isset($server['4']) ? $server['4'] : "0");
|
||||
$host = (isset($server['7']) ? $server['7'] : "unknown");
|
||||
$port = (isset($server['8']) ? $server['8'] : "unknown");
|
||||
$tmp = $host.":".$port;
|
||||
foreach ($var as $item=>$value) {
|
||||
$tmp .= ";".$value;
|
||||
}
|
||||
array_push($res, $tmp);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function makeCacheFile($data, $cache) {
|
||||
$fp = fopen($cache, 'w');
|
||||
foreach ($data as $item=>$value) {
|
||||
fwrite($fp, $value."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
function readCacheFile($cache) {
|
||||
if (file_exists($cache)) {
|
||||
$data = file($cache);
|
||||
foreach ($data as $item=>$value) {
|
||||
echo trim($value)."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['argv'][1] == "makeCache") {
|
||||
$servers = get_list($config);
|
||||
$data = doSNMPv2($servers);
|
||||
makeCacheFile($data, $cache);
|
||||
} else {
|
||||
readCacheFile($cache);
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user