Code to Delete interfaces that match bad_if?
So I spent a lot of time digging through the code to figure out how bad_if works.
I wanted to remove the stacking "ports" there were showing up.
Added this code to my config: $config['bad_if'][] = "stack";
However the ports weren't getting removed. Upon further investigation I found that the current code only prevents the addition of a match. However, if the port is already in the database nothing is done.
Is this the desired behaviour or should ports that match be removed from the database?
~pyther
Things put into that array should be removed on the next discovery cycle (if not poller)
adam.
On Sun, 09 Oct 2011 23:51:52 -0400, Matthew Gyurgyik pyther@pyther.net wrote:
So I spent a lot of time digging through the code to figure out how bad_if works.
I wanted to remove the stacking "ports" there were showing up.
Added this code to my config: $config['bad_if'][] = "stack";
However the ports weren't getting removed. Upon further investigation I found that the current code only prevents the addition of a match. However, if the port is already in the database nothing is done.
Is this the desired behaviour or should ports that match be removed from
the database?
~pyther _______________________________________________ observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
is_port_valid() checks to see if a given interface matches the anything in the bad_if array.
This then gets called between lines 101-125 in includes/poller/ports.inc.php
/// New interface detection foreach ($port_stats as $ifIndex => $port) { if (is_port_valid($port, $device)) { if (!is_array($ports[$port['ifIndex']])) { $interface_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports'); $ports[$port['ifIndex']] = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($interface_id)); echo("Adding: ".$port['ifName']."(".$ifIndex.")(".$ports[$port['ifIndex']]['interface_id'].")"); #print_r($ports); } elseif ($ports[$ifIndex]['deleted'] == "1") { dbUpdate(array('deleted' => '0'), 'ports', '`interface_id` = ?', array($ports[$ifIndex]['interface_id'])); $ports[$ifIndex]['deleted'] = "0"; } } } /// End New interface detection
This is the only instance where is_port_valid is called.
Do we want to set the deleted field to 1 for the port?
Maybe something like this:
if (is_port_valid($port, $device)) { code...... } else { dbUpdate(array('deleted' => '1'), 'ports', '`interface_id` = ?', array($ports[$ifIndex]['interface_id'])); $ports[$ifIndex]['deleted'] = "1"; }
Or do we want to permanently delete the entry from the table?
~pyther
On 10/10/2011 04:40 AM, Adam Armstrong wrote:
Things put into that array should be removed on the next discovery cycle (if not poller)
adam.
On Sun, 09 Oct 2011 23:51:52 -0400, Matthew Gyurgyikpyther@pyther.net wrote:
So I spent a lot of time digging through the code to figure out how bad_if works.
I wanted to remove the stacking "ports" there were showing up.
Added this code to my config: $config['bad_if'][] = "stack";
However the ports weren't getting removed. Upon further investigation I found that the current code only prevents the addition of a match. However, if the port is already in the database nothing is done.
Is this the desired behaviour or should ports that match be removed from the database?
~pyther _______________________________________________ observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
participants (2)
-
Adam Armstrong
-
Matthew Gyurgyik