diff --git a/html/includes/graphs/application/powerdns_fail.inc.php b/html/includes/graphs/application/powerdns_fail.inc.php index a1370b86f6..12a9205218 100644 --- a/html/includes/graphs/application/powerdns_fail.inc.php +++ b/html/includes/graphs/application/powerdns_fail.inc.php @@ -1,36 +1,32 @@ 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"); ?> diff --git a/html/includes/graphs/application/powerdns_latency.inc.php b/html/includes/graphs/application/powerdns_latency.inc.php index 68cf52218c..aee53a538c 100644 --- a/html/includes/graphs/application/powerdns_latency.inc.php +++ b/html/includes/graphs/application/powerdns_latency.inc.php @@ -1,27 +1,20 @@ diff --git a/html/includes/graphs/application/powerdns_packetcache.inc.php b/html/includes/graphs/application/powerdns_packetcache.inc.php index c7ba418d93..8baaacbaef 100644 --- a/html/includes/graphs/application/powerdns_packetcache.inc.php +++ b/html/includes/graphs/application/powerdns_packetcache.inc.php @@ -1,36 +1,32 @@ 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"); ?> diff --git a/html/includes/graphs/application/powerdns_queries.inc.php b/html/includes/graphs/application/powerdns_queries.inc.php index ee1933f444..d66ab960f3 100644 --- a/html/includes/graphs/application/powerdns_queries.inc.php +++ b/html/includes/graphs/application/powerdns_queries.inc.php @@ -1,37 +1,33 @@ 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"); ?> diff --git a/html/includes/graphs/application/powerdns_queries_udp.inc.php b/html/includes/graphs/application/powerdns_queries_udp.inc.php index 065f4a4115..510662b20c 100644 --- a/html/includes/graphs/application/powerdns_queries_udp.inc.php +++ b/html/includes/graphs/application/powerdns_queries_udp.inc.php @@ -1,37 +1,33 @@ 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"); ?> diff --git a/html/includes/graphs/application/powerdns_querycache.inc.php b/html/includes/graphs/application/powerdns_querycache.inc.php index 1f3986ead0..1db491c10c 100644 --- a/html/includes/graphs/application/powerdns_querycache.inc.php +++ b/html/includes/graphs/application/powerdns_querycache.inc.php @@ -1,36 +1,31 @@ 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"); ?> diff --git a/html/includes/graphs/application/powerdns_recursing.inc.php b/html/includes/graphs/application/powerdns_recursing.inc.php index 780687e3ec..772d5a3f92 100644 --- a/html/includes/graphs/application/powerdns_recursing.inc.php +++ b/html/includes/graphs/application/powerdns_recursing.inc.php @@ -1,36 +1,31 @@ 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"); ?> diff --git a/html/includes/graphs/application/shoutcast_bits.inc.php b/html/includes/graphs/application/shoutcast_bits.inc.php new file mode 100644 index 0000000000..ec71155054 --- /dev/null +++ b/html/includes/graphs/application/shoutcast_bits.inc.php @@ -0,0 +1,27 @@ + diff --git a/html/includes/graphs/application/shoutcast_multi_bits.inc.php b/html/includes/graphs/application/shoutcast_multi_bits.inc.php new file mode 100644 index 0000000000..587ff5a166 --- /dev/null +++ b/html/includes/graphs/application/shoutcast_multi_bits.inc.php @@ -0,0 +1,49 @@ +$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"); + +?> diff --git a/html/includes/graphs/application/shoutcast_multi_stats.inc.php b/html/includes/graphs/application/shoutcast_multi_stats.inc.php new file mode 100644 index 0000000000..ab8563f969 --- /dev/null +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -0,0 +1,90 @@ +$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 diff --git a/html/includes/graphs/application/shoutcast_stats.inc.php b/html/includes/graphs/application/shoutcast_stats.inc.php new file mode 100644 index 0000000000..7de4ddbefe --- /dev/null +++ b/html/includes/graphs/application/shoutcast_stats.inc.php @@ -0,0 +1,42 @@ += 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\""; + +?> diff --git a/html/pages/device/apps/shoutcast.inc.php b/html/pages/device/apps/shoutcast.inc.php new file mode 100644 index 0000000000..0dfcfcb04b --- /dev/null +++ b/html/pages/device/apps/shoutcast.inc.php @@ -0,0 +1,62 @@ + '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('

'.$text.'

'); + echo(""); + include("includes/print-quadgraphs.inc.php"); + echo(""); + } + } + + 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('

'.$text.'

'); + echo(""); + include("includes/print-quadgraphs.inc.php"); + echo(""); + } + } + +?> \ No newline at end of file diff --git a/includes/polling/applications/apache.inc.php b/includes/polling/applications/apache.inc.php index 4b5e42c858..f6efa79988 100644 --- a/includes/polling/applications/apache.inc.php +++ b/includes/polling/applications/apache.inc.php @@ -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"); ?> \ No newline at end of file diff --git a/includes/polling/applications/powerdns.inc.php b/includes/polling/applications/powerdns.inc.php index 10c330b67d..006945b6a2 100644 --- a/includes/polling/applications/powerdns.inc.php +++ b/includes/polling/applications/powerdns.inc.php @@ -1,57 +1,57 @@ diff --git a/includes/polling/applications/shoutcast.inc.php b/includes/polling/applications/shoutcast.inc.php new file mode 100644 index 0000000000..113130990e --- /dev/null +++ b/includes/polling/applications/shoutcast.inc.php @@ -0,0 +1,55 @@ +$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"); + } +} + +?> diff --git a/scripts/shoutcast.default.conf b/scripts/shoutcast.default.conf new file mode 100644 index 0000000000..d38367babb --- /dev/null +++ b/scripts/shoutcast.default.conf @@ -0,0 +1,3 @@ +server1:8050 +server2:8000 +server2:8010 diff --git a/scripts/shoutcast.php b/scripts/shoutcast.php new file mode 100644 index 0000000000..e6217227a3 --- /dev/null +++ b/scripts/shoutcast.php @@ -0,0 +1,119 @@ +#!/usr/bin/env php + + ## + ######################################################################################## + + + #### 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('This script is only meant to run at the command line.'); + } + + 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); + } + +?>