fix services stuff

git-svn-id: http://www.observium.org/svn/observer/trunk@3090 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-04-26 13:05:52 +00:00
parent 4045c970af
commit 77d055f9d6
4 changed files with 26 additions and 40 deletions
+6 -5
View File
@@ -3,6 +3,8 @@
chdir(dirname($argv[0])); chdir(dirname($argv[0]));
$debug=1;
include("includes/defaults.inc.php"); include("includes/defaults.inc.php");
include("config.php"); include("config.php");
include("includes/functions.php"); include("includes/functions.php");
@@ -58,16 +60,15 @@ foreach (dbFetchRows("SELECT * FROM `devices` AS D, `services` AS S WHERE S.devi
if (!is_file($rrd)) if (!is_file($rrd))
{ {
rrdtool_create($rrd,"--step 300 \ rrdtool_create ($rrd, "DS:status:GAUGE:600:0:1 ".$config['rrd_rra']);
DS:status:GAUGE:600:0:1 \
RRA:AVERAGE:0.5:1:1200 \
RRA:AVERAGE:0.5:12:2400");
} }
if ($status == "1" || $status == "0") if ($status == "1" || $status == "0")
{ {
rrdtool_update($rrd,"N:".$status); rrdtool_update($rrd,"N:".$status);
} else {
rrdtool_update($rrd,"N:U");
} }
} # while } # while
?> ?>
-2
View File
@@ -36,8 +36,6 @@ if ($device_id)
{ {
if (!$samehost) if (!$samehost)
{ {
$device['device_id'] = $device_id;
$device['hostname'] = $device_hostname;
echo("<td valign=top width=250><span style='font-weight:bold;'>" . generate_device_link($device) . "</span></td>"); echo("<td valign=top width=250><span style='font-weight:bold;'>" . generate_device_link($device) . "</span></td>");
} else { } else {
echo("<td></td>"); echo("<td></td>");
+9 -17
View File
@@ -5,21 +5,16 @@ echo("<span style='font-weight: bold;'>Services</span> &#187; ");
$menu_options = array('basic' => 'Basic', $menu_options = array('basic' => 'Basic',
'details' => 'Details'); 'details' => 'Details');
if (!$_GET['optc']) { $_GET['optc'] = "basic"; } if (!$vars['view']) { $vars['view'] = "basic"; }
$sep = ""; $sep = "";
foreach ($menu_options as $option => $text) foreach ($menu_options as $option => $text)
{ {
if(empty($vars['view'])) { $vars['view'] = $option; }
echo($sep); echo($sep);
if ($_GET['optc'] == $option) if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); }
{ echo(generate_link($text, $vars, array('view'=>$option)));
echo("<span class='pagemenu-selected'>"); if ($vars['view'] == $option) { echo("</span>"); }
}
echo('<a href="device/' . $device['device_id'] . '/services/' . $option . ($_GET['optd'] ? '/' . $_GET['optd'] : ''). '/">' . $text . '</a>');
if ($_GET['optc'] == $option)
{
echo("</span>");
}
$sep = " | "; $sep = " | ";
} }
@@ -35,7 +30,7 @@ if (dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE device_id = ?",
{ {
include("includes/print-service.inc.php"); include("includes/print-service.inc.php");
if ($_GET['optc'] == "details") if ($vars['view'] == "details")
{ {
$graph_array['height'] = "100"; $graph_array['height'] = "100";
$graph_array['width'] = "210"; $graph_array['width'] = "210";
@@ -46,12 +41,9 @@ if (dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE device_id = ?",
$periods = array('day', 'week', 'month', 'year'); $periods = array('day', 'week', 'month', 'year');
echo('<tr style="background-color: '.$bg.'; padding: 7px;"><td colspan=4>'); echo('<tr style="background-color: '.$bg.'; padding: 7px;"><td colspan=4>');
foreach ($periods as $period)
{ include("includes/print-quadgraphs.inc.php");
$graph_array['from'] = $$period;
$graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400";
echo(overlib_link("#", generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL));
}
echo("</td></tr>"); echo("</td></tr>");
} }
} }
+11 -16
View File
@@ -4,26 +4,21 @@ $pagetitle[] = "Services";
print_optionbar_start(); print_optionbar_start();
echo('<span style="font-weight: bold;">Services</span> &#187; '); echo("<span style='font-weight: bold;'>Services</span> &#187; ");
$menu_options = array('basic' => 'Basic', $menu_options = array('basic' => 'Basic',
'details' => 'Details'); 'details' => 'Details');
if (!$_GET['opta']) { $_GET['opta'] = "basic"; } if (!$vars['view']) { $vars['view'] = "basic"; }
$sep = ""; $sep = "";
foreach ($menu_options as $option => $text) foreach ($menu_options as $option => $text)
{ {
if(empty($vars['view'])) { $vars['view'] = $option; }
echo($sep); echo($sep);
if ($_GET['opta'] == $option) if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); }
{ echo(generate_link($text, $vars, array('view'=>$option)));
echo("<span class='pagemenu-selected'>"); if ($vars['view'] == $option) { echo("</span>"); }
}
echo('<a href="services/' . $option . ($_GET['optb'] ? '/' . $_GET['optb'] : ''). '/">' . $text . '</a>');
if ($_GET['opta'] == $option)
{
echo("</span>");
}
$sep = " | "; $sep = " | ";
} }
@@ -44,16 +39,16 @@ if ($_SESSION['userlevel'] >= '5')
$host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = ? GROUP BY D.hostname ORDER BY D.hostname"; $host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = ? GROUP BY D.hostname ORDER BY D.hostname";
$host_par = array($_SESSION['user_id']); $host_par = array($_SESSION['user_id']);
} }
foreach (dbFetchRows($host_sql, $host_par) as $host_data) foreach (dbFetchRows($host_sql, $host_par) as $device)
{ {
$device_id = $host_data['device_id']; $device_id = $device['device_id'];
$device_hostname = $host_data['hostname']; $device_hostname = $device['hostname'];
foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ?", array($host_data['device_id'])) as $service) foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ?", array($device['device_id'])) as $service)
{ {
include("includes/print-service.inc.php"); include("includes/print-service.inc.php");
# $samehost = 1; # $samehost = 1;
if ($_GET['opta'] == "details") if ($vars['view'] == "details")
{ {
$graph_array['height'] = "100"; $graph_array['height'] = "100";
$graph_array['width'] = "215"; $graph_array['width'] = "215";