Skip to content

Commit

Permalink
Merge pull request #268 from laf/issue-laf-32
Browse files Browse the repository at this point in the history
Added support for Cisco ASA Connection graphs
  • Loading branch information
paulgear committed Jul 17, 2014
2 parents d49a0b6 + 2f89df2 commit b9c2d68
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 1 deletion.
32 changes: 32 additions & 0 deletions html/includes/graphs/device/asa_conns.inc.php
@@ -0,0 +1,32 @@
<?php

/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ fua http://www.lathwood.co.uk>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/

$scale_min = "0";

include("includes/graphs/common.inc.php");

$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/asa_conns.rrd";

$rrd_options .= " DEF:connections=$rrd_filename:connections:AVERAGE";
$rrd_options .= " DEF:connections_max=$rrd_filename:connections:MAX";
$rrd_options .= " DEF:connections_min=$rrd_filename:connections:MIN";
$rrd_options .= " AREA:connections_min";

$rrd_options .= " LINE1.5:connections#cc0000:'" . rrdtool_escape('Current connections')."'";
$rrd_options .= " GPRINT:connections_min:MIN:%4.0lf";
$rrd_options .= " GPRINT:connections:LAST:%4.0lf";
$rrd_options .= " GPRINT:connections_max:MAX:%4.0lf\\\\l";


?>
1 change: 1 addition & 0 deletions includes/defaults.inc.php
Expand Up @@ -529,6 +529,7 @@
$config['poller_modules']['aruba-controller'] = 1;
$config['poller_modules']['entity-physical'] = 1;
$config['poller_modules']['applications'] = 1;
$config['poller_modules']['cisco-asa-firewall'] = 1;

// List of discovery modules. Need to be in this array to be
// considered for execution.
Expand Down
4 changes: 4 additions & 0 deletions includes/definitions.inc.php
Expand Up @@ -1079,6 +1079,10 @@
$config['graph_types']['device']['netscaler_tcp_pkts']['order'] = '0';
$config['graph_types']['device']['netscaler_tcp_pkts']['descr'] = 'TCP Packets';

$config['graph_types']['device']['asa_conns']['section'] = 'firewall';
$config['graph_types']['device']['asa_conns']['order'] = '0';
$config['graph_types']['device']['asa_conns']['descr'] = 'Current connections';

$config['graph_descr']['device_smokeping_in_all'] = "This is an aggregate graph of the incoming smokeping tests to this host. The line corresponds to the average RTT. The shaded area around each line denotes the standard deviation.";
$config['graph_descr']['device_processor'] = "This is an aggregate graph of all processors in the system.";

Expand Down
2 changes: 1 addition & 1 deletion includes/functions.php
Expand Up @@ -239,7 +239,7 @@ function delete_device($id)
dbDelete('devices', "`device_id` = ?", array($id));

$device_tables = array('entPhysical', 'devices_attribs', 'devices_perms', 'bgpPeers', 'vlans', 'vrfs', 'storage', 'alerts', 'eventlog',
'syslog', 'ports', 'services', 'toner', 'frequency', 'current', 'sensors');
'syslog', 'ports', 'services', 'toner', 'frequency', 'current', 'sensors','ciscoASA');

foreach ($device_tables as $table)
{
Expand Down
58 changes: 58 additions & 0 deletions includes/polling/cisco-asa-firewall.inc.php
@@ -0,0 +1,58 @@
<?php

/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ fua http://www.lathwood.co.uk>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/

if($device['os_group'] == "cisco" && $device['os'] == "asa" && $device['type'] == "firewall")
{

$oid_list = "cfwConnectionStatValue.protoIp.currentInUse";
$temp_data = snmpwalk_cache_double_oid($device, $oid_list, array(), "CISCO-FIREWALL-MIB");
foreach ($temp_data as $oid => $result)
{
$oid = substr(strchr($oid, '.'),1);
$data[$oid]['data'] = $result['cfwConnectionStatValue'];
$asa_db = dbFetchCell("SELECT `ciscoASA_id` FROM `ciscoASA` WHERE `device_id` = ? AND `oid` = ?", array($device['device_id'],$oid));
if(!is_numeric($asa_db))
{
$asa_db = dbInsert(array('device_id' => $device['device_id'], 'oid' => $oid, 'data' => $result['cfwConnectionStatValue']), 'ciscoASA');
}
else
{
$asa_db = dbUpdate(array('data' => $result['cfwConnectionStatValue']), 'ciscoASA', 'device_id=?',array($device['device_id']));
}
$data[$oid]['db_id'] = $asa_db;
}

$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("asa_conns.rrd");

$rrd_create .= " DS:connections:GAUGE:600:0:U";
$rrd_create .= $config['rrd_rra'];

if(is_file($rrd_filename) || $data['currentInUse'])
{
if (!file_exists($rrd_filename))
{
rrdtool_create($rrd_filename, $rrd_create);
}

$rrd_update = "N";
$rrd_update .= ":".$data['currentInUse']['data'];

rrdtool_update($rrd_filename, $rrd_update);
$graphs['asa_conns'] = TRUE;
echo(" ASA Connections");
}
unset($data,$rrd_filename,$rrd_create,$rrd_update);
}

?>
2 changes: 2 additions & 0 deletions sql-schema/032.sql
@@ -0,0 +1,2 @@
CREATE TABLE IF NOT EXISTS `ciscoASA` ( `ciscoASA_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `oid` varchar(255) NOT NULL, `data` bigint(20) NOT NULL, `high_alert` bigint(20) NOT NULL, `low_alert` bigint(20) NOT NULL, `disabled` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`ciscoASA_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
INSERT INTO `graph_types` SET `graph_type`='device', `graph_subtype`='asa_conns',`graph_section`='firewall',`graph_descr`='Current connections',`graph_order`='0';

0 comments on commit b9c2d68

Please sign in to comment.