smokeping basic working

git-svn-id: http://www.observium.org/svn/observer/trunk@2622 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-09-30 19:46:32 +00:00
parent 8bbd0b8ca5
commit b3a19908ab
4 changed files with 65 additions and 81 deletions

View File

@@ -1,36 +1,9 @@
<?php <?php
$files = array(); include("smokeping_common.inc.php");
if ($handle = opendir($config['smokeping']['dir']))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if (eregi(".rrd", $file))
{
if (eregi("~", $file))
{
list($target,$slave) = explode("~", str_replace(".rrd", "", $file));
if($target == $device['hostname'])
{
$files[$slave] = $file;
}
} else {
$target = str_replace(".rrd", "", $file);
if($target == $device['hostname'])
{
$files['observium'] = $file;
}
}
}
}
}
}
$i=0; $i=0;
foreach($files as $source => $filename) foreach($smokeping_files['in'][$device['hostname']] as $source => $filename)
{ {
$i++; $i++;
$rrd_list[$i]['filename'] = $config['smokeping']['dir'] . $filename; $rrd_list[$i]['filename'] = $config['smokeping']['dir'] . $filename;

View File

@@ -1,31 +1,10 @@
<?php <?php
$config['smokeping']['dir'] = "/var/lib/smokeping/";
$files = array();
if ($handle = opendir($config['smokeping']['dir']))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if (eregi(".rrd", $file))
{
if (eregi("~", $file))
{
list($target,$slave) = explode("~", str_replace(".rrd", "", $file));
if($slave == $device['hostname'])
{
$files[$target] = $file;
}
}
}
}
}
}
$i=0; $i=0;
foreach($files as $source => $filename)
include("smokeping_common.inc.php");
foreach($smokeping_files['out'][$device['hostname']] as $source => $filename)
{ {
$i++; $i++;
$rrd_list[$i]['filename'] = $config['smokeping']['dir'] . $filename; $rrd_list[$i]['filename'] = $config['smokeping']['dir'] . $filename;

View File

@@ -75,7 +75,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
</li>'); </li>');
} }
if (is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) if (isset($config['collectd_dir']) && is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/"))
{ {
echo('<li class="' . $select['collectd'] . '"> echo('<li class="' . $select['collectd'] . '">
<a href="'.generate_device_url($device, array('tab' => 'collectd')).'"> <a href="'.generate_device_url($device, array('tab' => 'collectd')).'">
@@ -93,6 +93,37 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
</li>'); </li>');
} }
if(isset($config['smokeping']['dir'])) {
$smokeping_files = array();
if ($handle = opendir($config['smokeping']['dir'])) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (eregi(".rrd", $file)) {
if (eregi("~", $file)) {
list($target,$slave) = explode("~", str_replace(".rrd", "", $file));
$smokeping_files['in'][$target][$slave] = $file;
$smokeping_files['out'][$slave][$target] = $file;
} else {
$target = str_replace(".rrd", "", $file);
$smokeping_files['in'][$target][$config['own_hostname']] = $file;
$smokeping_files['out'][$config['own_hostname']][$target] = $file;
}
}
}
}
}
}
if (count($smokeping_files))
{
echo('<li class="' . $select['latency'] . '">
<a href="'.generate_device_url($device, array('tab' => 'latency')).'">
<img src="images/16/arrow_undo.png" align="absmiddle" border="0" /> Latency
</a>
</li>');
}
if (@dbFetchCell("SELECT COUNT(vlan_id) FROM vlans WHERE device_id = '" . $device['device_id'] . "'") > '0') if (@dbFetchCell("SELECT COUNT(vlan_id) FROM vlans WHERE device_id = '" . $device['device_id'] . "'") > '0')
{ {
echo('<li class="' . $select['vlans'] . '"> echo('<li class="' . $select['vlans'] . '">

View File

@@ -1,32 +1,39 @@
<?php <?php
#if(!$vars['view']) { $vars['view'] = "incoming"; }
if(!$vars['view']) { $vars['view'] = "outgoing"; } if(!$vars['view']) { $vars['view'] = "outgoing"; }
$files = array(); print_optionbar_start();
if ($handle = opendir($config['smokeping']['dir'])) { echo("<span style='font-weight: bold;'>Latency</span> &#187; ");
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { $menu_options = array('incoming' => 'Incoming',
if (eregi(".rrd", $file)) { 'outgoing' => 'Outgoing');
if (eregi("~", $file)) {
list($target,$slave) = explode("~", str_replace(".rrd", "", $file)); $sep = "";
$files[$target][$slave] = $file; foreach ($menu_options as $option => $text)
$files_rev[$slave][$target] = $file; {
} else { echo($sep);
$target = str_replace(".rrd", "", $file); if ($vars['view'] == $option)
$files[$target]['observium'] = $file; {
} echo("<span class='pagemenu-selected'>");
} }
} echo(generate_link($text,$vars,array('view'=>$option)));
} if ($vars['view'] == $option)
} {
echo("</span>");
}
$sep = " | ";
}
unset($sep);
print_optionbar_end();
if($vars['view'] == "incoming") if($vars['view'] == "incoming")
{ {
if(count($files_rev[$device['hostname']])) if(count($smokeping_files['in'][$device['hostname']]))
{ {
$graph_array['type'] = "device_smokeping_in_all"; $graph_array['type'] = "device_smokeping_in_all";
@@ -38,7 +45,7 @@ if($vars['view'] == "incoming")
} else { } else {
if(count($files[$device['hostname']])) if(count($smokeping_files['out'][$device['hostname']]))
{ {
$graph_array['type'] = "device_smokeping_out_all"; $graph_array['type'] = "device_smokeping_out_all";
@@ -50,10 +57,4 @@ if($vars['view'] == "incoming")
} }
echo("<pre>");
print_r($files);
echo("</pre>");
?> ?>