Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3970 from crcro/app-dhcp-stats
app-dhcp-stats initial release
- Loading branch information
Showing
5 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
require 'includes/graphs/common.inc.php'; | ||
$name = 'dhcp-stats'; | ||
$app_id = $app['app_id']; | ||
$scale_min = 0; | ||
$colours = 'mixed'; | ||
$unit_text = 'Leases'; | ||
$unitlen = 10; | ||
$bigdescrlen = 15; | ||
$smalldescrlen = 15; | ||
$dostack = 0; | ||
$printtotal = 0; | ||
$addarea = 1; | ||
$transparency = 15; | ||
|
||
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id)); | ||
|
||
$array = array( | ||
'dhcp_total' => array('descr' => 'Total','colour' => '582A72',), | ||
'dhcp_active' => array('descr' => 'Active','colour' => '28774F',), | ||
'dhcp_expired' => array('descr' => 'Expired','colour' => 'AA6C39',), | ||
'dhcp_released' => array('descr' => 'Released','colour' => '88CC88',), | ||
'dhcp_abandoned' => array('descr' => 'Abandoned','colour' => 'D46A6A',), | ||
'dhcp_reset' => array('descr' => 'Reset','colour' => 'FFD1AA',), | ||
'dhcp_bootp' => array('descr' => 'BootP','colour' => '582A72',), | ||
'dhcp_backup' => array('descr' => 'Backup','colour' => 'AA5439',), | ||
'dhcp_free' => array('descr' => 'Free','colour' => '28536C',), | ||
); | ||
|
||
$i = 0; | ||
if (is_file($rrd_filename)) { | ||
foreach ($array as $ds => $vars) { | ||
$rrd_list[$i]['filename'] = $rrd_filename; | ||
$rrd_list[$i]['descr'] = $vars['descr']; | ||
$rrd_list[$i]['ds'] = $ds; | ||
$rrd_list[$i]['colour'] = $vars['colour']; | ||
$i++; | ||
} | ||
} | ||
else { | ||
echo "file missing: $rrd_filename"; | ||
} | ||
|
||
require 'includes/graphs/generic_v3_multiline.inc.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
global $config; | ||
|
||
$graphs = array( | ||
'dhcp-stats' => 'DHCP Stats', | ||
); | ||
|
||
foreach ($graphs as $key => $text) { | ||
$graph_type = $key; | ||
$graph_array['height'] = '100'; | ||
$graph_array['width'] = '215'; | ||
$graph_array['to'] = $config['time']['now']; | ||
$graph_array['id'] = $app['app_id']; | ||
$graph_array['type'] = 'application_'.$key; | ||
|
||
echo '<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">'.$text.'</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<div class="row">'; | ||
include 'includes/print-graphrow.inc.php'; | ||
echo '</div>'; | ||
echo '</div>'; | ||
echo '</div>'; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
$name = 'dhcp-stats'; | ||
$app_id = $app['app_id']; | ||
$options = '-O qv'; | ||
$mib = 'NET-SNMP-EXTEND-MIB'; | ||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.100.104.99.112.115.116.97.116.115'; | ||
|
||
$dhcpstats = snmp_walk($device, $oid, $options, $mib); | ||
list($dhcp_total,$dhcp_active,$dhcp_expired,$dhcp_released,$dhcp_abandoned,$dhcp_reset,$dhcp_bootp,$dhcp_backup,$dhcp_free) = explode("\n",$dhcpstats); | ||
|
||
$rrd_name = array('app', $name, $app_id); | ||
$rrd_def = array( | ||
'DS:dhcp_total:GAUGE:600:0:U', | ||
'DS:dhcp_active:GAUGE:600:0:U', | ||
'DS:dhcp_expired:GAUGE:600:0:U', | ||
'DS:dhcp_released:GAUGE:600:0:U', | ||
'DS:dhcp_abandoned:GAUGE:600:0:U', | ||
'DS:dhcp_reset:GAUGE:600:0:U', | ||
'DS:dhcp_bootp:GAUGE:600:0:U', | ||
'DS:dhcp_backup:GAUGE:600:0:U', | ||
'DS:dhcp_free:GAUGE:600:0:U', | ||
); | ||
|
||
$fields = array( | ||
'dhcp_total' => $dhcp_total, | ||
'dhcp_active' => $dhcp_active, | ||
'dhcp_expired' => $dhcp_expired, | ||
'dhcp_released' => $dhcp_released, | ||
'dhcp_abandoned' => $dhcp_abandoned, | ||
'dhcp_reset' => $dhcp_reset, | ||
'dhcp_bootp' => $dhcp_bootp, | ||
'dhcp_backup' => $dhcp_backup, | ||
'dhcp_free' => $dhcp_free, | ||
); | ||
|
||
$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); | ||
data_update($device, 'app', $tags, $fields); |