reengineering of port rrdfile. merged ifx (will notify existance of this via database).

****** YOU MUST RUN DISCOVERY OR "php fix-port-rrd.php" AFTER THIS *******



git-svn-id: http://www.observium.org/svn/observer/trunk@1656 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-08-10 15:54:01 +00:00
parent 8297e6aa5e
commit baf538df88
19 changed files with 298 additions and 73 deletions

View File

@@ -10,3 +10,4 @@ INSERT INTO `graph_types` (`graph_type`, `graph_subtype`, `graph_section`, `grap
DROP TABLE `frequency`;
ALTER TABLE `mempools` CHANGE `mempool_index` `mempool_index` VARCHAR( 16 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;
ALTER TABLE `vrfs` CHANGE `mplsVpnVrfRouteDistinguisher` `mplsVpnVrfRouteDistinguisher` varchar(26) default NOT NULL;
## Change port rrds

View File

@@ -67,6 +67,10 @@ if (file_exists('.svn'))
include("fix-events.php"); ## Fix events table (needs to copy some data around, so needs script)
}
if($db_rev+0 < 1656) { //FIXME
include('fix-port-rrd.php');
}
if ($dbu_rev+0 > $db_rev)
{
echo "SVN revision changed.\n";
@@ -91,6 +95,8 @@ if (file_exists('.svn'))
}
}
if(isset($options['d'])) { echo("DEBUG!\n"); $debug = 1; } else { $debug = 0; }

205
fix-port-rrd.php Executable file
View File

@@ -0,0 +1,205 @@
<?php
include("includes/defaults.inc.php");
include("config.php");
$basepath = $config['rrd_dir'].'/';
$files = (getDirectoryTree($basepath));
$count = count($files);
if($config['rrdcached'])
{
$rrdcached = " --daemon " . $config['rrdcached'];
}
echo $count . " Files \n";
$start = date("U");
$i = 0;
foreach($files as $file){
fixRdd($file);
$i++;
if(date("U") - $start > 1)
echo round(($i / $count) * 100, 2) . "%\n";
}
function getDirectoryTree( $outerDir, &$files = array()){
$dirs = array_diff( scandir( $outerDir ), Array( ".", ".." ) );
foreach( $dirs as $d ){
if( is_dir($outerDir."/".$d) ){
getDirectoryTree($outerDir.'/'. $d, $files);
}else{
if(preg_match('/^[\d]+.rrd$/', $d))
array_push($files, preg_replace('/\/+/', '/', $outerDir.'/'. $d));
}
}
return $files;
}
function fixRdd($file){
global $config;
global $rrdcached;
$fileC = shell_exec( "{$config['rrdtool']} dump $file $rrdcached" );
#---------------------------------------------------------------------------------------------------------
$first = <<<FIRST
<ds>
<name> INDISCARDS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> OUTDISCARDS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> INUNKNOWNPROTOS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> INBROADCASTPKTS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> OUTBROADCASTPKTS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> INMULTICASTPKTS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<ds>
<name> OUTMULTICASTPKTS </name>
<type> DERIVE </type>
<minimal_heartbeat> 600 </minimal_heartbeat>
<min> 0.0000000000e+00 </min>
<max> 1.2500000000e+10 </max>
<!-- PDP Status -->
<last_ds> UNKN </last_ds>
<value> 0.0000000000e+00 </value>
<unknown_sec> 0 </unknown_sec>
</ds>
<!-- Round Robin Archives -->
FIRST;
$second = <<<SECOND
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
<ds>
<primary_value> 0.0000000000e+00 </primary_value>
<secondary_value> NaN </secondary_value>
<value> NaN </value>
<unknown_datapoints> 0 </unknown_datapoints>
</ds>
</cdp_prep>
SECOND;
$third = <<<THIRD
<v> NaN </v><v> NaN </v><v> NaN </v><v> NaN </v><v> NaN </v><v> NaN </v><v> NaN </v></row>
THIRD;
#---------------------------------------------------------------------------------------------------------
if(!preg_match('/DISCARDS/', $fileC)){
$fileC = str_replace('<!-- Round Robin Archives -->', $first, $fileC);
$fileC = str_replace('</cdp_prep>', $second, $fileC);
$fileC = str_replace('</row>', $third, $fileC);
$tmpfname = tempnam("/tmp", "OBS");
file_put_contents($tmpfname, $fileC);
unlink($file);
$newfile = preg_replace("/(\d+)\.rrd/", "port-\\1.rrd", $file);
unlink($newfile);
shell_exec($config['rrdtool'] . " restore $tmpfname $newfile");
unlink($tmpfname);
}
}
?>

View File

@@ -22,8 +22,8 @@ while($int = mysql_fetch_assoc($query)) {
}
}
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($int['ifIndex'] . ".rrd")) && $ignore != 1) {
$rrd_filenames[] = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($int['ifIndex'] . ".rrd");
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd")) && $ignore != 1) {
$rrd_filenames[] = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd");
}
unset($ignore);
}

View File

@@ -5,8 +5,8 @@ $i = 1;
foreach(explode(",", $id) as $ifid) {
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
$int = mysql_fetch_row($query);
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . safename($int[0] . ".rrd"))) {
$rrd_filenames[] = $config['rrd_dir'] . "/" . $int[1] . "/" . safename($int[0] . ".rrd");
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . safename($int[0] . ".rrd"))) {
$rrd_filenames[] = $config['rrd_dir'] . "/" . $int[1] . "/port-" . safename($int[0] . ".rrd");
$i++;
}
}

View File

@@ -13,8 +13,8 @@ if($_GET['legend']) { $legend = $_GET['legend']; }
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
$int = mysql_fetch_row($query);
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
$rrd_options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
$rrd_options .= " DEF:outoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE";
$rrd_options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/port-" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
$rrd_options .= " DEF:outoctets" . $i . "=" . $config['rrd_dir'] . "/port-" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE";
$in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF";
$out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF";
$pluses .= $plus;
@@ -28,8 +28,8 @@ if($_GET['legend']) { $legend = $_GET['legend']; }
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
$int = mysql_fetch_row($query);
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
$rrd_options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
$rrd_options .= " DEF:outoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE";
$rrd_options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/port-" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE";
$rrd_options .= " DEF:outoctetsb" . $i . "=" . $config['rrd_dir'] . "/port-" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE";
$in_thingb .= $seperator . "inoctetsb" . $i . ",UN,0," . "inoctetsb" . $i . ",IF";
$out_thingb .= $seperator . "outoctetsb" . $i . ",UN,0," . "outoctetsb" . $i . ",IF";
$plusesb .= $plus;

View File

@@ -13,7 +13,7 @@ function graph_multi_bits ($args) {
foreach(explode(",", $args['ports']) as $ifid) {
$query = mysql_query("SELECT * FROM `ports` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
$int = mysql_fetch_array($query);
$this_rrd = $config['rrd_dir'] . "/" . $int['hostname'] . "/" . safename($int['ifIndex'] . ".rrd");
$this_rrd = $config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd");
$units='bps'; $unit='B'; $colours='greens'; $multiplier = "8"; $coloursb = 'blues';
if(is_file($this_rrd)) {
$name = $int['ifDescr'];

View File

@@ -9,10 +9,10 @@ if($_GET['legend']) { $legend = $_GET['legend']; }
foreach(explode(",", $_GET['ports']) as $ifid) {
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
$int = mysql_fetch_row($query);
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd")) {
if(strstr($inverse, "a")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; }
$rrd_options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE";
$rrd_options .= " DEF:outoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE";
$rrd_options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE";
$rrd_options .= " DEF:outoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE";
$in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF";
$out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF";
$pluses .= $plus;
@@ -25,10 +25,10 @@ if($_GET['legend']) { $legend = $_GET['legend']; }
foreach(explode(",", $_GET['ports_b']) as $ifid) {
$query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id");
$int = mysql_fetch_row($query);
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd")) {
if(strstr($inverse, "b")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; }
$rrd_options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE";
$rrd_options .= " DEF:outoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE";
$rrd_options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE";
$rrd_options .= " DEF:outoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE";
$in_thingb .= $seperator . "inoctetsb" . $i . ",UN,0," . "inoctetsb" . $i . ",IF";
$out_thingb .= $seperator . "outoctetsb" . $i . ",UN,0," . "outoctetsb" . $i . ",IF";
$plusesb .= $plus;
@@ -43,8 +43,8 @@ if($_GET['legend']) { $legend = $_GET['legend']; }
$int = mysql_fetch_row($query);
if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) {
if(strstr($inverse, "c")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; }
$rrd_options .= " DEF:inoctetsc" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE";
$rrd_options .= " DEF:outoctetsc" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE";
$rrd_options .= " DEF:inoctetsc" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE";
$rrd_options .= " DEF:outoctetsc" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE";
$in_thingc .= $seperator . "inoctetsc" . $i . ",UN,0," . "inoctetsc" . $i . ",IF";
$out_thingc .= $seperator . "outoctetsc" . $i . ",UN,0," . "outoctetsc" . $i . ",IF";
$plusesc .= $plus;

View File

@@ -6,6 +6,9 @@ if(is_numeric($id) && port_permitted($id)) {
$title = generate_device_link($device);
$title .= " :: Port ".generate_port_link($port);
$auth = TRUE;
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
}
?>

View File

@@ -1,7 +1,5 @@
<?php
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($port['ifIndex'] . ".rrd");
$rra_in = "INOCTETS";
$rra_out = "OUTOCTETS";

View File

@@ -1,22 +1,30 @@
<?php
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($port['ifIndex'] . ".rrd");
$rrd_list[1]['filename'] = $rrd_filename;
$rrd_list[1]['descr'] = $int['ifDescr'];
$rrd_list[1]['rra_in'] = "INERRORS";
$rrd_list[1]['rra_out'] = "OUTERRORS";
$rrd_list[1]['descr'] = "Errors";
$rrd_list[1]['colour_area_in'] = "FF3300";
$rrd_list[1]['colour_area_out'] = "FF6633";
$rra_in = "INERRORS";
$rra_out = "OUTERRORS";
$rrd_list[4]['filename'] = $rrd_filename;
$rrd_list[4]['descr'] = $int['ifDescr'];
$rrd_list[4]['rra_in'] = "INDISCARDS";
$rrd_list[4]['rra_out'] = "OUTDISCARDS";
$rrd_list[4]['descr'] = "Discards";
$rrd_list[4]['colour_area_in'] = "805080";
$rrd_list[4]['colour_area_out'] = "c0a060";
$colour_area_in = "FF3300";
$colour_line_in = "FF0000";
$colour_area_out = "FF6633";
$colour_line_out = "CC3300";
$units='';
$units_descr='Packets/sec';
$total_units='B';
$colours_in='greens';
$multiplier = "1";
$colours_out = 'blues';
$colour_area_in_max = "FF6633";
$colour_area_out_max = "FF9966";
$nototal = 1;
$graph_max = 1;
$unit_text = "Errors";
include("includes/graphs/generic_duplex.inc.php");
include ("includes/graphs/generic_multi_seperated.inc.php");
?>

View File

@@ -8,7 +8,7 @@ $oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingle
'dot3StatsSymbolErrors');
$i=0;
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("etherlike-" . $port['ifIndex'] . ".rrd");
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("port-" . $port['ifIndex'] . "-dot3.rrd");
if(is_file($rrd_filename)) {
foreach($oids as $oid){
$oid = str_replace("dot3Stats", "", $oid);

View File

@@ -1,8 +1,7 @@
<?php
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/ifx-" . safename($port['ifIndex'] . ".rrd")))
if(1)
{
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ifx-" . safename($port['ifIndex'] . ".rrd");
$rrd_list[1]['filename'] = $config['rrd_dir'] . "/" . $device['hostname'] . "/ifx-" . safename($port['ifIndex'] . ".rrd");
$rrd_list[1]['descr'] = $int['ifDescr'];

View File

@@ -6,8 +6,8 @@ $query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$port['device
$i=0;
while($int = mysql_fetch_array($query)) {
if(is_file($config['rrd_dir'] . "/" . $hostname . "/" . safename($int['ifIndex'] . ".rrd"))) {
$rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $hostname . "/" . safename($int['ifIndex'] . ".rrd");
if(is_file($config['rrd_dir'] . "/" . $hostname . "/port-" . safename($int['ifIndex'] . ".rrd"))) {
$rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $hostname . "/port-" . safename($int['ifIndex'] . ".rrd");
$rrd_list[$i]['descr'] = $int['ifDescr'];
$i++;
}

View File

@@ -1,7 +1,5 @@
<?php
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($port['ifIndex'] . ".rrd");
$rra_in = "INUCASTPKTS";
$rra_out = "OUTUCASTPKTS";

View File

@@ -226,9 +226,9 @@ echo("</td>");
if($graph_type == "etherlike")
{
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-". safename($interface['ifIndex']) . ".rrd";
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-". safename($interface['ifIndex']) . "-dot3.rrd";
} else {
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/". safename($interface['ifIndex']) . ".rrd";
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-". safename($interface['ifIndex']) . ".rrd";
}
if($graph_type && is_file($graph_file)) {

View File

@@ -1,6 +1,6 @@
<?php
if(file_exists($config['rrd_dir'] . "/" . $hostname . "/". $ifIndex . ".rrd")) {
if(file_exists($config['rrd_dir'] . "/" . $hostname . "/port-". $ifIndex . ".rrd")) {
$iid = $id;
echo("<div class=graphhead>Interface Traffic</div>");

View File

@@ -5,19 +5,24 @@
$this_port = &$port_stats[$device[device_id]][$port[ifIndex]];
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("etherlike-".$port['ifIndex'].".rrd");
$old_rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("etherlike-".$port['ifIndex'].".rrd");
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("port-".$port['ifIndex']."-dot3.rrd");
$rrd_create = $config['rrdtool'] . " create $rrdfile ";
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
if(!file_exists($rrdfile)) {
if(file_exists($old_rrdfile)) {
shell_exec('mv '.$old_rrdfile.' '.$rrd_file);
} else {
foreach($etherlike_oids as $oid){
$oid = truncate(str_replace("dot3Stats", "", $oid), 19, '');
$rrd_create .= " DS:$oid:COUNTER:600:U:100000000000";
}
shell_exec($rrd_create);
}
}
$rrdupdate = "N";
foreach($etherlike_oids as $oid) {

View File

@@ -1,4 +1,4 @@
[B<?php
<?php
unset($ports);
$ports = snmp_cache_ifIndex($device); // Cache Port List
@@ -6,9 +6,11 @@
// Build SNMP Cache Array
$data_oids = array('ifName','ifDescr','ifAlias', 'ifAdminStatus', 'ifOperStatus', 'ifMtu', 'ifSpeed', 'ifHighSpeed', 'ifType', 'ifPhysAddress',
'ifPromiscuousMode','ifConnectorPresent','ifDuplex');
$stat_oids = array('ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInNUcastPkts', 'ifOutNUcastPkts',
'ifHCInMulticastPkts', 'ifHCInBroadcastPkts', 'ifHCOutMulticastPkts', 'ifHCOutBroadcastPkts',
'ifInOctets', 'ifOutOctets', 'ifHCInOctets', 'ifHCOutOctets');
'ifInOctets', 'ifOutOctets', 'ifHCInOctets', 'ifHCOutOctets', 'ifInDiscards', 'ifOutDiscards', 'ifInUnknownProtos',
'ifInBroadcastPkts', 'ifOutBroadcastPkts', 'ifInMulticastPkts', 'ifOutMulticastPkts');
$stat_oids_db = array('ifInOctets', 'ifOutOctets', 'ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts'); // From above for DB
@@ -114,6 +116,14 @@
$this_port['ifOutOctets'] = $this_port['ifHCOutOctets'];
}
if(is_numeric($this_port['ifHCInBroadcastPkts']) && is_numeric($this_port['ifHCOutBroadcastPkts']) && is_numeric($this_port['ifHCInMulticastPkts']) && is_numeric($this_port['ifHCOutMulticastPkts'])) {
echo("HC ");
$this_port['ifInBroadcastPkts'] = $this_port['ifHCInBroadcastPkts'];
$this_port['ifOutBroadcastPkts'] = $this_port['ifHCOutBroadcastPkts'];
$this_port['ifInMulticastPkts'] = $this_port['ifHCInMulticastPkts'];
$this_port['ifOutMulticastPkts'] = $this_port['ifHCOutMulticastPkts'];
}
### Overwrite ifSpeed with ifHighSpeed if it's over 10G
if(is_numeric($this_port['ifHighSpeed']) && $this_port['ifSpeed'] > "1000000000")
{
@@ -176,7 +186,7 @@
}
/// Update RRDs
$rrdfile = $host_rrd . "/" . safename($port['ifIndex'] . ".rrd");
$rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd");
if(!is_file($rrdfile)) {
$woo = shell_exec($config['rrdtool'] . " create $rrdfile -s 300 \
DS:INOCTETS:DERIVE:600:0:12500000000 \
@@ -187,6 +197,13 @@
DS:OUTUCASTPKTS:DERIVE:600:0:12500000000 \
DS:INNUCASTPKTS:DERIVE:600:0:12500000000 \
DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000 \
DS:INDISCARDS:DERIVE:600:0:12500000000 \
DS:OUTDISCARDS:DERIVE:600:0:12500000000 \
DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000 \
DS:INBROADCASTPKTS:DERIVE:600:0:12500000000 \
DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000 \
DS:INMULTICASTPKTS:DERIVE:600:0:12500000000 \
DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
@@ -197,36 +214,21 @@
RRA:MAX:0.5:288:797");
}
$ifx_rrd = $host_rrd . "/ifx-" . safename($port['ifIndex'] . ".rrd");
$ifx_rrd_cmd = $config['rrdtool'] . " create $ifx_rrd -s 300 \
DS:InBroadcastPkts:DERIVE:600:0:12500000000 \
DS:OutBroadcastPkts:DERIVE:600:0:12500000000 \
DS:InMulticastPkts:DERIVE:600:0:12500000000 \
DS:OutMulticastPkts:DERIVE:600:0:12500000000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797";
foreach ($stat_oids as $oid) { /// Copy values from array to global variables and force numeric.
$$oid = $this_port[$oid];
if(!is_numeric($$oid)) { $$oid = "0"; }
}
$if_rrd_update = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts";
$if_rrd_update = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts:$ifInDiscards:$ifOutDiscards:$ifInUnknownProtos";
$if_rrd_update .= ":$ifInBroadcastPkts:$ifOutBroadcastPkts:$ifInMulticastPkts:$ifOutMulticastPkts";
$ret = rrdtool_update("$rrdfile", $if_rrd_update);
if($config['enable_ports_Xbcmc'] && $config['os'][$device['os']]['ifXmcbc']) {
if(!is_file($ifx_rrd)) { shell_exec($ifx_rrd_cmd); }
$ifx_rrd_update = "$polled:$ifHCInBroadcastPkts:$ifHCOutBroadcastPkts:$ifHCInMulticastPkts:$ifHCOutMulticastPkts";
$ret = rrdtool_update($ifx_rrd, $ifx_rrd_update);
}
# if($config['enable_ports_Xbcmc'] && $config['os'][$device['os']]['ifXmcbc']) {
# if(!is_file($ifx_rrd)) { shell_exec($ifx_rrd_cmd); }
# $ifx_rrd_update = "$polled:$ifHCInBroadcastPkts:$ifHCOutBroadcastPkts:$ifHCInMulticastPkts:$ifHCOutMulticastPkts";
# $ret = rrdtool_update($ifx_rrd, $ifx_rrd_update);
# }
/// End Update IF-MIB