2009-09-07 11:07:59 +00:00
< ? php
2007-04-03 14:10:23 +00:00
2008-07-22 08:24:34 +00:00
if ( $_GET [ 'id' ]) { $_GET [ 'id' ] = mres ( $_GET [ 'id' ]); }
2007-11-21 14:26:24 +00:00
if ( devicepermitted ( $_GET [ 'id' ])) {
2007-04-09 16:39:23 +00:00
$selected [ 'iface' ] = " selected " ;
2007-04-03 14:10:23 +00:00
2007-04-09 16:39:23 +00:00
if ( ! $_GET [ 'section' ]) {
2008-11-27 12:36:37 +00:00
$_GET [ 'section' ] = " overview " ;
2007-04-03 14:10:23 +00:00
}
2008-07-22 08:24:34 +00:00
$section = mres ( $_GET [ 'section' ]);
$section = str_replace ( " . " , " " , $section );
2007-06-06 16:43:08 +00:00
$select [ $section ] = " selected " ;
2007-04-03 14:10:23 +00:00
2007-04-09 16:39:23 +00:00
$device_query = mysql_query ( " SELECT * FROM `devices` WHERE `device_id` = ' " . $_GET [ 'id' ] . " ' " );
2007-04-03 14:10:23 +00:00
while ( $device = mysql_fetch_array ( $device_query )) {
2010-06-12 18:09:58 +00:00
2010-06-12 20:14:41 +00:00
if ( $os_groups [ $device [ 'os' ]]) { $device [ 'os_group' ] = $os_groups [ $device [ 'os' ]]; }
2010-06-12 18:09:58 +00:00
2010-01-09 00:42:45 +00:00
echo ( '<table cellpadding="15" cellspacing="0" class="devicetable" width="100%">' );
2010-02-20 17:37:42 +00:00
include ( " includes/device-header.inc.php " );
2009-09-18 09:11:52 +00:00
echo ( " </table> " );
2007-04-03 14:10:23 +00:00
echo ( " <div class=mainpane> " );
2010-01-09 00:42:45 +00:00
echo ( '<ul id="maintab" class="shadetabs">' );
2009-05-11 13:43:59 +00:00
2010-02-23 16:38:33 +00:00
if ( $config [ 'show_overview_tab' ]) {
echo ( "
< li class = " . $select['overview'] . " >
< a href = '".$config[' base_url ']."/device/" . $device[' device_id '] . "/overview/' >
< img src = 'images/16/server_lightning.png' align = absmiddle border = 0 > Overview
</ a >
</ li > " );
}
2007-04-15 14:38:26 +00:00
2010-06-12 18:09:58 +00:00
2010-06-10 22:40:27 +00:00
if (( is_file ( $config [ 'install_dir' ] . " /html/pages/device/graphs/os- " . $device [ 'os' ] . " .inc.php " )) ||
2010-06-12 18:09:58 +00:00
( $device [ 'os_group' ] && is_file ( $config [ 'install_dir' ] . " /html/pages/device/graphs/os- " . $device [ 'os_group' ] . " .inc.php " )))
2010-06-10 22:40:27 +00:00
{
echo ( '<li class="' . $select [ 'graphs' ] . ' " >
2010-01-09 00:42:45 +00:00
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/graphs/ " >
< img src = " images/16/server_chart.png " align = " absmiddle " border = " 0 " > Graphs
2009-03-11 15:30:01 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2010-06-10 22:40:27 +00:00
}
2009-03-11 15:30:01 +00:00
2010-02-24 02:16:56 +00:00
$health = mysql_result ( mysql_query ( " select count(*) from storage WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
2010-02-13 07:40:43 +00:00
mysql_result ( mysql_query ( " select count(temp_id) from temperature WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
2009-04-23 21:13:56 +00:00
mysql_result ( mysql_query ( " select count(*) from cempMemPool WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
2010-02-13 21:45:39 +00:00
mysql_result ( mysql_query ( " select count(*) from cpmCPU WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
2010-06-03 10:23:11 +00:00
mysql_result ( mysql_query ( " select count(*) from processors WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
2010-06-09 20:20:38 +00:00
mysql_result ( mysql_query ( " select count(current_id) from current WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
mysql_result ( mysql_query ( " select count(freq_id) from frequencies WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
2010-06-03 10:23:11 +00:00
mysql_result ( mysql_query ( " select count(volt_id) from voltage WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
mysql_result ( mysql_query ( " select count(fan_id) from fanspeed WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 );
2009-04-23 21:13:56 +00:00
if ( $health ) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'health' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/health/ " >
2010-04-11 13:45:19 +00:00
< img src = " images/icons/sensors.png " align = " absmiddle " border = " 0 " /> Health
2009-04-23 21:13:56 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2009-04-23 21:13:56 +00:00
}
2010-04-11 13:45:19 +00:00
### This needs to die, rolled into generic sensors! (still need to implement booleans, tx/rx powers and currents)
2010-03-23 15:39:59 +00:00
2010-04-11 13:45:19 +00:00
#$cisco_sensors = mysql_result(mysql_query("SELECT count(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%'"),0);
2010-03-23 15:39:59 +00:00
#if($cisco_sensors) {
# echo('<li class="' . $select['ciscosensors'] . '">
# <a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ciscosensors/">
# <img src="images/16/contrast.png" align="absmiddle" border="0" /> Sensors
# </a>
#</li>');
#}
2009-05-06 16:50:51 +00:00
2009-04-23 21:13:56 +00:00
if ( is_dir ( $config [ 'collectd_dir' ] . " / " . $device [ 'hostname' ] . " / " )) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'collectd' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/collectd/ " >
< img src = " images/16/chart_line.png " align = " absmiddle " border = " 0 " /> CollectD
2009-04-23 21:13:56 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2009-04-23 21:13:56 +00:00
}
2010-02-20 17:22:22 +00:00
if ( @ mysql_result ( mysql_query ( " select count(interface_id) from ports WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' ) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'ports' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/ports/' . $config['ports_page_default'] . ' " >
< img src = " images/16/connect.png " align = " absmiddle " border = " 0 " /> Ports
2009-04-23 21:13:56 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2009-04-23 21:13:56 +00:00
}
2007-04-15 14:38:26 +00:00
if ( @ mysql_result ( mysql_query ( " select count(vlan_id) from vlans WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' ) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'vlans' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/vlans/ " >
< img src = " images/16/vlans.png " align = " absmiddle " border = " 0 " /> VLANs
2007-04-15 14:38:26 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2007-04-15 14:38:26 +00:00
}
2008-10-28 22:06:00 +00:00
if ( @ mysql_result ( mysql_query ( " select count(*) from vrfs WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' ) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'vrfs' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/vrfs/ " >
< img src = " images/16/layers.png " align = " absmiddle " border = " 0 " /> VRFs
2008-10-28 22:06:00 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2008-10-28 22:06:00 +00:00
}
2008-03-18 13:35:17 +00:00
if ( $config [ 'enable_bgp' ] && $device [ 'bgpLocalAs' ]) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'bgp' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/bgp/ " >
< img src = " images/16/link.png " align = " absmiddle " border = " 0 " /> BGP
2008-03-15 17:58:15 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2008-03-15 17:58:15 +00:00
}
2010-04-11 13:45:19 +00:00
### This probably needs to die? DEATH TO NAGIOS!
2010-01-30 21:48:22 +00:00
#if(@mysql_result(mysql_query("SELECT count(*) FROM nagios_hosts WHERE address = '".$device['hostname']."'", $nagios_link), 0) > '0') {
# echo('<li class="' . $select['nagios'] . '">
# <a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/nagios/">
# <img src="images/16/transmit_blue.png" align="absmiddle" border="0" /> Nagios
# </a>
#</li>');
#}
2007-04-15 14:38:26 +00:00
2009-04-23 21:13:56 +00:00
2010-02-20 17:22:22 +00:00
if ( $_SESSION [ 'userlevel' ] >= " 5 " && mysql_result ( mysql_query ( " SELECT count(*) FROM links AS L, ports AS I WHERE I.device_id = ' " . $device [ 'device_id' ] . " ' AND I.interface_id = L.local_interface_id " ), 0 )) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'map' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/map/ " >
< img src = " images/16/chart_organisation.png " align = " absmiddle " border = " 0 " /> Map
2009-03-11 14:46:55 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2009-03-11 14:46:55 +00:00
}
2009-01-09 15:01:36 +00:00
if ( $config [ 'enable_inventory' ] && @ mysql_result ( mysql_query ( " SELECT * FROM `entPhysical` WHERE device_id = ' " . $_GET [ 'id' ] . " ' " ), 0 ) > '0' ) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'entphysical' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/entphysical/ " >
< img src = " images/16/bricks.png " align = " absmiddle " border = " 0 " /> Inventory
2007-11-21 14:26:24 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2010-01-07 18:27:33 +00:00
} elseif ( $config [ 'enable_inventory' ] && @ mysql_result ( mysql_query ( " SELECT * FROM `hrDevice` WHERE device_id = ' " . $_GET [ 'id' ] . " ' " ), 0 ) > '0' ) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'hrdevice' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/hrdevice/ " >
< img src = " images/16/bricks.png " align = " absmiddle " border = " 0 " /> Inventory
2010-01-07 18:27:33 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2010-01-07 18:27:33 +00:00
}
2007-11-21 14:26:24 +00:00
2010-02-24 02:16:56 +00:00
#if(mysql_result(mysql_query("select count(storage_id) from storage WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
2009-05-11 13:43:59 +00:00
# echo("
#<li class=" . $select['storage'] . ">
2010-01-09 00:42:45 +00:00
# <a href='".$config['base_url']."/device/" . $device['device_id'] . '/storage/">
# <img src="images/16/database.png" align="absmiddle" border="0" /> Storage
2009-05-11 13:43:59 +00:00
# </a>
#</li>
#");
#}
2007-11-21 14:26:24 +00:00
2010-02-21 19:32:08 +00:00
if ( mysql_result ( mysql_query ( " select count(service_id) from services WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' ) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'srv' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/srv/ " >
< img src = " images/16/server_cog.png " align = " absmiddle " border = " 0 " /> Services
2007-04-03 14:10:23 +00:00
</ a >
</ li >
2010-01-09 00:42:45 +00:00
' );
2007-04-03 14:10:23 +00:00
}
2010-03-12 17:46:25 +00:00
if ( @ mysql_result ( mysql_query ( " select count(toner_id) from toner WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' ) {
echo ( '<li class="' . $select [ 'toner' ] . ' " >
< a href = " '. $config['base_url'] .'/device/' . $device['device_id'] . '/toner/ " >
2010-03-12 18:13:30 +00:00
< img src = " images/16/palette.png " align = " absmiddle " border = " 0 " /> Toner
2010-03-12 17:46:25 +00:00
</ a >
</ li > ' );
}
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'events' ] . ' " >
< a href = " '. $config['base_url'] . " / device / " . $device['device_id'] . '/events/ " >
< img src = " images/16/report_magnify.png " align = " absmiddle " border = " 0 " /> Events
2007-04-03 14:10:23 +00:00
</ a >
2010-01-09 00:42:45 +00:00
</ li > ' );
2007-04-03 14:10:23 +00:00
2010-01-09 00:42:45 +00:00
if ( $config [ 'enable_syslog' ]) {
2010-01-09 01:46:12 +00:00
echo ( '<li class="' . $select [ 'syslog' ] . ' " >
2010-01-09 00:42:45 +00:00
< a href = " '. $config['base_url'] . " / device / " . $device['device_id'] . '/syslog/ " >
< img src = " images/16/printer.png " align = " absmiddle " border = " 0 " /> Syslog
2007-04-03 14:10:23 +00:00
</ a >
</ li >
2010-01-09 00:42:45 +00:00
' );
}
2007-04-03 14:10:23 +00:00
2010-02-16 20:45:40 +00:00
2010-03-17 15:15:36 +00:00
if ( $_SESSION [ 'userlevel' ] >= " 7 " ) {
2010-02-16 20:45:40 +00:00
if ( ! is_array ( $config [ 'rancid_configs' ])) { $config [ 'rancid_configs' ] = array ( $config [ 'rancid_configs' ]); }
foreach ( $config [ 'rancid_configs' ] as $configs ) {
2010-03-06 01:46:36 +00:00
if ( $configs [ strlen ( $configs ) - 1 ] != '/' ) { $configs .= '/' ; }
2010-02-16 20:45:40 +00:00
if ( is_file ( $configs . $device [ 'hostname' ])) { $device_config_file = $configs . $device [ 'hostname' ]; }
}
}
if ( $device_config_file ) {
2010-01-30 21:48:22 +00:00
echo ( '<li class="' . $select [ 'showconfig' ] . ' " >
2010-01-09 00:42:45 +00:00
< a href = " '. $config['base_url'] . " / device / " . $device['device_id'] . '/showconfig/ " >
< img src = " images/16/page_white_text.png " align = " absmiddle " border = " 0 " /> Config
2009-02-04 16:18:11 +00:00
</ a >
</ li >
2010-01-09 00:42:45 +00:00
' );
2009-02-04 16:18:11 +00:00
}
2010-03-17 15:15:36 +00:00
if ( $_SESSION [ 'userlevel' ] >= " 7 " ) {
2010-01-09 00:42:45 +00:00
echo ( '<li class="' . $select [ 'edit' ] . ' " >
< a href = " '. $config['base_url'] . " / device / " . $device['device_id'] . '/edit/ " >
< img src = " images/16/server_edit.png " align = " absmiddle " border = " 0 " /> Settings
2007-04-03 14:10:23 +00:00
</ a >
</ li >
2010-01-09 00:42:45 +00:00
' );
2007-04-03 14:10:23 +00:00
}
echo ( " </ul> " );
2010-01-09 00:42:45 +00:00
echo ( '
< div class = " contentstyle " > ' );
2007-04-03 14:10:23 +00:00
2008-11-27 12:36:37 +00:00
include ( " pages/device/ " . mres ( $section ) . " .inc.php " );
2007-04-03 14:10:23 +00:00
2009-02-06 14:53:33 +00:00
2007-04-03 14:10:23 +00:00
echo ( " </div>
" );
}
2007-11-21 14:26:24 +00:00
2009-08-12 15:20:20 +00:00
} else { include ( " includes/error-no-perm-dev.inc.php " ); }
2007-04-03 14:10:23 +00:00
?>