2009-09-07 11:07:59 +00:00
< ? php
2007-04-03 14:10:23 +00:00
2011-03-07 16:23:45 +00:00
if ( $_GET [ 'id' ]) { $_GET [ 'id' ] = mres ( $_GET [ 'id' ]); }
2008-07-22 08:24:34 +00:00
2011-04-23 10:47:40 +00:00
if ( $_GET [ 'section' ] == " port " && is_numeric ( $_GET [ 'opta' ]) && port_permitted ( $_GET [ 'opta' ]))
2011-03-07 16:23:45 +00:00
{
2010-07-19 11:12:28 +00:00
$check_device = get_device_id_by_interface_id ( $_GET [ 'opta' ]);
$permit_ports = 1 ;
}
2011-03-07 16:23:45 +00:00
if ( device_permitted ( $_GET [ 'id' ]) || $check_device == $_GET [ 'id' ])
{
$selected [ 'iface' ] = " selected " ;
2010-06-12 18:09:58 +00:00
2011-03-07 16:23:45 +00:00
$section = str_replace ( " . " , " " , mres ( $_GET [ 'section' ]));
2007-04-03 14:10:23 +00:00
2011-03-07 16:23:45 +00:00
if ( ! $section )
{
$section = " overview " ;
}
2007-04-03 14:10:23 +00:00
2011-03-07 16:23:45 +00:00
$select [ $section ] = " selected " ;
2009-05-11 13:43:59 +00:00
2011-03-31 17:19:54 +00:00
$device = device_by_id_cache ( $_GET [ 'id' ]);
if ( $config [ 'os' ][ $device [ 'os' ]][ 'group' ]) { $device [ 'os_group' ] = $config [ 'os' ][ $device [ 'os' ]][ 'group' ]; }
2007-04-15 14:38:26 +00:00
2011-04-21 12:59:44 +00:00
echo ( '<table style="margin: 0px 7px 7px 7px;" cellpadding="15" cellspacing="0" class="devicetable" width="99%">' );
#include("includes/hostbox.inc.php");
2011-03-31 17:19:54 +00:00
include ( " includes/device-header.inc.php " );
echo ( '</table>' );
2009-03-11 15:30:01 +00:00
2011-03-31 17:19:54 +00:00
echo ( '<div class="mainpane">' );
echo ( ' <ul id="maintab" class="shadetabs">' );
2010-07-19 11:12:28 +00:00
2011-03-31 17:19:54 +00:00
if ( device_permitted ( $device [ 'device_id' ]))
{
if ( $config [ 'show_overview_tab' ])
2011-03-07 16:23:45 +00:00
{
2011-03-31 17:19:54 +00:00
echo ( '
2011-03-07 16:23:45 +00:00
< li class = " ' . $select['overview'] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/overview/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/server_lightning.png " align = " absmiddle " border = " 0 " > Overview
2010-07-19 11:12:28 +00:00
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2007-04-15 14:38:26 +00:00
2011-03-31 17:19:54 +00:00
echo ( '<li class="' . $select [ 'graphs' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/graphs/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/server_chart.png " align = " absmiddle " border = " 0 " > Graphs
</ a >
</ li > ' );
2009-04-23 21:13:56 +00:00
2011-03-31 17:19:54 +00:00
$health = mysql_result ( mysql_query ( " select count(*) from storage WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
mysql_result ( mysql_query ( " select count(sensor_id) from sensors WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
mysql_result ( mysql_query ( " select count(*) from cempMemPool WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
mysql_result ( mysql_query ( " select count(*) from cpmCPU WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) +
2011-04-13 14:00:12 +00:00
mysql_result ( mysql_query ( " select count(*) from processors WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 );
2011-03-31 17:19:54 +00:00
if ( $health )
{
echo ( '<li class="' . $select [ 'health' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/health/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/icons/sensors.png " align = " absmiddle " border = " 0 " /> Health
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2011-03-07 16:23:45 +00:00
2011-03-31 17:19:54 +00:00
if ( @ mysql_result ( mysql_query ( " select count(app_id) from applications WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' )
{
echo ( '<li class="' . $select [ 'apps' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/apps/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/icons/apps.png " align = " absmiddle " border = " 0 " /> Apps
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2009-03-11 14:46:55 +00:00
2011-03-31 17:19:54 +00:00
if ( is_dir ( $config [ 'collectd_dir' ] . " / " . $device [ 'hostname' ] . " / " ))
{
echo ( '<li class="' . $select [ 'collectd' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/collectd/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/chart_line.png " align = " absmiddle " border = " 0 " /> CollectD
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2007-11-21 14:26:24 +00:00
2011-03-31 17:19:54 +00:00
if ( @ mysql_result ( mysql_query ( " select count(interface_id) from ports WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' )
{
echo ( '<li class="' . $select [ 'ports' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/ports/' . $config['ports_page_default'] . ' " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/connect.png " align = " absmiddle " border = " 0 " /> Ports
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2007-04-03 14:10:23 +00:00
2011-03-31 17:19:54 +00:00
if ( @ mysql_result ( mysql_query ( " select count(vlan_id) from vlans WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' )
{
echo ( '<li class="' . $select [ 'vlans' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/vlans/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/vlans.png " align = " absmiddle " border = " 0 " /> VLANs
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2010-03-12 17:46:25 +00:00
2011-04-06 15:25:35 +00:00
if ( @ mysql_result ( mysql_query ( " SELECT COUNT(id) FROM vminfo WHERE device_id = ' " . $device [ " device_id " ] . " ' " ), 0 ) > '0' )
2011-03-31 17:19:54 +00:00
{
echo ( '<li class="' . $select [ 'vm' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/vm/ " >
2011-03-26 17:16:09 +00:00
< img src = " images/16/server_cog.png " align = " absmiddle " border = " 0 " /> Virtual Machines
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2011-03-26 17:16:09 +00:00
2011-04-28 15:01:36 +00:00
# if (@mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0')
# {
# echo('<li class="' . $select['vrfs'] . '">
# <a href="device/' . $device['device_id'] . '/vrfs/">
# <img src="images/16/layers.png" align="absmiddle" border="0" /> VRFs
# </a>
# </li>');
# }
2010-03-12 17:46:25 +00:00
2011-04-17 15:55:38 +00:00
2011-03-31 17:19:54 +00:00
if ( $config [ 'enable_bgp' ] && $device [ 'bgpLocalAs' ])
{
2011-04-17 15:55:38 +00:00
$bgp_menu = '<li class="' . $select [ 'bgp' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/bgp/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/link.png " align = " absmiddle " border = " 0 " /> BGP
</ a >
2011-04-17 15:55:38 +00:00
</ li > ' ;
}
2011-04-28 09:41:00 +00:00
if ( $config [ 'enable_ospf' ])
{
$ospf_count = mysql_result ( mysql_query ( " select count(*) from ospf_instances WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 );
if ( $ospf_count ) { $ospf_menu = 1 ; }
}
2011-04-27 01:46:01 +00:00
2011-04-28 09:41:00 +00:00
if ( isset ( $bgp_menu ) || isset ( $ospf_menu ) || isset ( $isis_menu ) || isset ( $eigrp_menu ))
2011-04-17 15:55:38 +00:00
{
echo ( '<li class="' . $select [ 'routing' ] . ' " >
2011-04-21 13:41:24 +00:00
< a href = " device/' . $device['device_id'] . '/routing/ " >
2011-04-17 15:55:38 +00:00
< img src = " images/16/arrow_branch.png " align = " absmiddle " border = " 0 " /> Routing
</ a >
2011-03-07 16:23:45 +00:00
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2007-04-03 14:10:23 +00:00
2011-04-19 22:06:17 +00:00
# $cef_query = mysql_query("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = '".$device['device_id']."'");
# $cef_count = mysql_result($cef_query,0);
# if ($cef_count)
# {
# echo('<li class="' . $select['cefswitching'] . '">
# <a href="device/' . $device['device_id'] . '/cefswitching/">
# <img src="images/16/car.png" align="absmiddle" border="0" /> CEF
# </a>
# </li>');
# }
2011-04-12 22:29:29 +00:00
2011-03-31 17:19:54 +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 ))
{
2011-04-23 15:59:06 +00:00
$discovery_links = TRUE ;
2011-03-31 17:19:54 +00:00
echo ( '<li class="' . $select [ 'map' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/map/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/chart_organisation.png " align = " absmiddle " border = " 0 " /> Map
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2010-02-16 20:45:40 +00:00
2011-03-31 17:19:54 +00:00
if ( $config [ 'enable_inventory' ] && @ mysql_result ( mysql_query ( " SELECT * FROM `entPhysical` WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' )
{
echo ( '<li class="' . $select [ 'entphysical' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/entphysical/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/bricks.png " align = " absmiddle " border = " 0 " /> Inventory
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
elseif ( device_permitted ( $device [ 'device_id' ]) && $config [ 'enable_inventory' ] && @ mysql_result ( mysql_query ( " SELECT * FROM `hrDevice` WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' )
{
echo ( '<li class="' . $select [ 'hrdevice' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/hrdevice/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/bricks.png " align = " absmiddle " border = " 0 " /> Inventory
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2011-03-17 00:09:20 +00:00
2011-03-31 17:19:54 +00:00
if ( mysql_result ( mysql_query ( " select count(service_id) from services WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ), 0 ) > '0' )
{
echo ( '<li class="' . $select [ 'srv' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/services/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/icons/services.png " align = " absmiddle " border = " 0 " /> Services
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2010-02-16 20:45:40 +00:00
2011-03-31 17:19:54 +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' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/toner/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/icons/toner.png " align = " absmiddle " border = " 0 " /> Toner
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2011-03-07 16:23:45 +00:00
2011-03-31 17:19:54 +00:00
if ( device_permitted ( $device [ 'device_id' ]))
{
echo ( '<li class="' . $select [ 'events' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/events/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/report_magnify.png " align = " absmiddle " border = " 0 " /> Events
</ a >
</ li > ' );
2011-03-31 17:19:54 +00:00
}
2011-03-07 16:23:45 +00:00
2011-03-31 17:19:54 +00:00
if ( $config [ 'enable_syslog' ])
{
echo ( '<li class="' . $select [ 'syslog' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/syslog/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/printer.png " align = " absmiddle " border = " 0 " /> Syslog
</ a >
2011-03-28 20:29:34 +00:00
</ li > ' );
2011-03-07 16:23:45 +00:00
}
2007-04-03 14:10:23 +00:00
2011-03-28 20:29:34 +00:00
if ( $_SESSION [ 'userlevel' ] >= " 7 " )
2011-03-26 19:12:24 +00:00
{
2011-03-28 20:29:34 +00:00
if ( ! is_array ( $config [ 'rancid_configs' ])) { $config [ 'rancid_configs' ] = array ( $config [ 'rancid_configs' ]); }
foreach ( $config [ 'rancid_configs' ] as $configs )
{
if ( $configs [ strlen ( $configs ) - 1 ] != '/' ) { $configs .= '/' ; }
if ( is_file ( $configs . $device [ 'hostname' ])) { $device_config_file = $configs . $device [ 'hostname' ]; }
}
2011-03-07 16:23:45 +00:00
}
2011-03-28 20:29:34 +00:00
if ( $device_config_file )
{
echo ( '<li class="' . $select [ 'showconfig' ] . ' " >
2011-04-27 14:32:15 +00:00
< a href = " device/' . $device['device_id'] . '/showconfig/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/page_white_text.png " align = " absmiddle " border = " 0 " /> Config
</ a >
2011-03-28 20:29:34 +00:00
</ li > ' );
2011-03-07 16:23:45 +00:00
}
2011-04-07 19:07:47 +00:00
if ( $config [ 'nfsen_enable' ])
{
if ( ! is_array ( $config [ 'nfsen_rrds' ])) { $config [ 'nfsen_rrds' ] = array ( $config [ 'nfsen_rrds' ]); }
foreach ( $config [ 'nfsen_rrds' ] as $nfsenrrds )
{
if ( $configs [ strlen ( $nfsenrrds ) - 1 ] != '/' ) { $nfsenrrds .= '/' ; }
2011-04-11 14:37:05 +00:00
$nfsensuffix = " " ;
if ( $config [ 'nfsen_suffix' ]) { $nfsensuffix = $config [ 'nfsen_suffix' ]; }
2011-04-07 19:07:47 +00:00
$basefilename_underscored = preg_replace ( '/\./' , $config [ 'nfsen_split_char' ], $device [ 'hostname' ]);
2011-04-11 14:37:05 +00:00
$nfsen_filename = ( strstr ( $basefilename_underscored , $nfsensuffix , true ));
if ( is_file ( $nfsenrrds . $nfsen_filename . " .rrd " )) { $nfsen_rrd_file = $nfsenrrds . $basefilename_underscored . " .rrd " ; }
2011-04-07 19:07:47 +00:00
}
}
if ( $nfsen_rrd_file )
{
echo ( '<li class="' . $select [ 'nfsen' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/nfsen/ " >
2011-04-07 19:07:47 +00:00
< img src = " images/16/rainbow.png " align = " absmiddle " border = " 0 " /> Netflow
</ a >
</ li > ' );
}
2011-03-26 19:12:24 +00:00
if ( $_SESSION [ 'userlevel' ] >= " 7 " )
{
2011-03-07 16:23:45 +00:00
echo ( '<li class="' . $select [ 'edit' ] . ' " >
2011-04-15 17:22:35 +00:00
< a href = " device/' . $device['device_id'] . '/edit/ " >
2011-03-07 16:23:45 +00:00
< img src = " images/16/server_edit.png " align = " absmiddle " border = " 0 " /> Settings
</ a >
2011-03-28 20:29:34 +00:00
</ li > ' );
2011-03-07 16:23:45 +00:00
}
echo ( " </ul> " );
2011-04-23 10:47:40 +00:00
}
if ( device_permitted ( $device [ 'device_id' ]) || $check_device == $_GET [ 'id' ]) {
2011-03-07 16:23:45 +00:00
echo ( '<div class="contentstyle">' );
2007-04-03 14:10:23 +00:00
2011-03-28 20:29:34 +00:00
include ( " pages/device/ " . mres ( basename ( $section )) . " .inc.php " );
2009-02-06 14:53:33 +00:00
2011-03-07 16:23:45 +00:00
echo ( " </div> " );
2011-04-23 10:47:40 +00:00
} else {
include ( " includes/error-no-perm.inc.php " );
2011-03-07 16:23:45 +00:00
}
}
2011-03-28 20:29:34 +00:00
2011-04-07 19:07:47 +00:00
?>