2009-09-07 11:07:59 +00:00
< ? php
2007-04-03 14:10:23 +00:00
2011-09-12 04:57:56 +00:00
if ( $_GET [ 'opta' ]) { $_GET [ 'opta' ] = mres ( $_GET [ 'opta' ]); }
2008-07-22 08:24:34 +00:00
2011-09-12 04:57:56 +00:00
if ( $_GET [ 'optb' ] == " port " && is_numeric ( $_GET [ 'opta' ]) && port_permitted ( $_GET [ 'optc' ]))
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-09-12 04:57:56 +00:00
if ( device_permitted ( $_GET [ 'opta' ]) || $check_device == $_GET [ 'opta' ])
2011-03-07 16:23:45 +00:00
{
$selected [ 'iface' ] = " selected " ;
2010-06-12 18:09:58 +00:00
2011-09-12 04:57:56 +00:00
$section = str_replace ( " . " , " " , mres ( $_GET [ 'optb' ]));
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-09-12 04:57:56 +00:00
$device = device_by_id_cache ( $_GET [ 'opta' ]);
2011-05-03 20:13:15 +00:00
$attribs = get_dev_attribs ( $device [ 'device_id' ]);
2011-03-31 17:19:54 +00:00
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-05-13 08:57:54 +00:00
$health = dbFetchCell ( " SELECT COUNT(*) FROM storage WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) +
dbFetchCell ( " SELECT COUNT(sensor_id) FROM sensors WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) +
dbFetchCell ( " SELECT COUNT(*) FROM cempMemPool WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) +
dbFetchCell ( " SELECT COUNT(*) FROM cpmCPU WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) +
dbFetchCell ( " SELECT COUNT(*) FROM processors WHERE device_id = ' " . $device [ 'device_id' ] . " ' " );
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-05-13 08:57:54 +00:00
if ( @ dbFetchCell ( " SELECT COUNT(app_id) FROM applications WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) > '0' )
2011-03-31 17:19:54 +00:00
{
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-05-13 08:57:54 +00:00
if ( @ dbFetchCell ( " SELECT COUNT(interface_id) FROM ports WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) > '0' )
2011-03-31 17:19:54 +00:00
{
2011-04-28 15:03:38 +00:00
echo ( '<li class="' . $select [ 'ports' ] . $select [ 'port' ] . ' " >
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-05-13 08:57:54 +00:00
if ( @ dbFetchCell ( " SELECT COUNT(vlan_id) FROM vlans WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) > '0' )
2011-03-31 17:19:54 +00:00
{
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-05-12 11:17:08 +00:00
if ( @ dbFetchCell ( " SELECT COUNT(id) FROM vminfo WHERE device_id = ' " . $device [ " device_id " ] . " ' " ) > '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-05-13 08:57:54 +00:00
### $routing_tabs is used in device/routing/ to build the tabs menu. we built it here to save some queries
2011-04-17 15:55:38 +00:00
2011-09-12 13:53:37 +00:00
$device_routing_count [ 'ipsec_tunnels' ] = dbFetchCell ( " SELECT COUNT(*) FROM `ipsec_tunnels` WHERE `device_id` = ? " , array ( $device [ 'device_id' ]));
if ( $device_routing_count [ 'ipsec_tunnels' ]) { $routing_tabs [] = 'ipsec_tunnels' ; }
2011-05-13 08:57:54 +00:00
$device_routing_count [ 'bgp' ] = dbFetchCell ( " SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = ? " , array ( $device [ 'device_id' ]));
if ( $device_routing_count [ 'bgp' ]) { $routing_tabs [] = 'bgp' ; }
$device_routing_count [ 'ospf' ] = dbFetchCell ( " SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? " , array ( $device [ 'device_id' ]));
if ( $device_routing_count [ 'ospf' ]) { $routing_tabs [] = 'ospf' ; }
$device_routing_count [ 'cef' ] = dbFetchCell ( " SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ? " , array ( $device [ 'device_id' ]));
if ( $device_routing_count [ 'cef' ]) { $routing_tabs [] = 'cef' ; }
$device_routing_count [ 'vrf' ] = @ dbFetchCell ( " SELECT COUNT(*) FROM `vrfs` WHERE `device_id` = ? " , array ( $device [ 'device_id' ]));
if ( $device_routing_count [ 'vrf' ]) { $routing_tabs [] = 'vrf' ; }
2011-04-27 01:46:01 +00:00
2011-05-13 08:57:54 +00:00
if ( is_array ( $routing_tabs ))
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-05-13 08:57:54 +00:00
if ( $_SESSION [ 'userlevel' ] >= " 5 " && dbFetchCell ( " SELECT COUNT(*) FROM links AS L, ports AS I WHERE I.device_id = ' " . $device [ 'device_id' ] . " ' AND I.interface_id = L.local_interface_id " ))
2011-03-31 17:19:54 +00:00
{
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-05-12 11:17:08 +00:00
if ( $config [ 'enable_inventory' ] && @ dbFetchCell ( " SELECT * FROM `entPhysical` WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) > '0' )
2011-03-31 17:19:54 +00:00
{
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
}
2011-05-12 11:17:08 +00:00
elseif ( device_permitted ( $device [ 'device_id' ]) && $config [ 'enable_inventory' ] && @ dbFetchCell ( " SELECT * FROM `hrDevice` WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) > '0' )
2011-03-31 17:19:54 +00:00
{
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-05-13 08:57:54 +00:00
if ( dbFetchCell ( " SELECT COUNT(service_id) FROM services WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) > '0' )
2011-03-31 17:19:54 +00:00
{
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-05-13 08:57:54 +00:00
if ( @ dbFetchCell ( " SELECT COUNT(toner_id) FROM toner WHERE device_id = ' " . $device [ 'device_id' ] . " ' " ) > '0' )
2011-03-31 17:19:54 +00:00
{
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-09-11 20:55:38 +00:00
echo ( '<li class="' . $select [ 'edit' ] . ' " style= " text - align : right ; " >
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
}
2011-09-12 04:57:56 +00:00
if ( device_permitted ( $device [ 'device_id' ]) || $check_device == $_GET [ 'opta' ]) {
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
?>