[FC] Tracking Utilities -> Remove All Scan Results ...mod

Support questions about the MAC Track plugin

Moderators: Developers, Moderators

Post Reply
lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

[FC] Tracking Utilities -> Remove All Scan Results ...mod

Post by lavermil »

Hello,

I love this tool I am comparing it to a tool I have been developing a little with someone else (switchmap). Currently switchmap does everything I need and more. I really like the interface of MAC Track and it allows me to write my own custom reports. I am really happy so far. I have to see if it finds as many IP-MAC pairs as the (switchmap) install I have running.

None the less I have realized when Doing a Remove All Scan Results, you don't end up with the following columns being zeroed out if you are under the "Device Report". So I have added in a few statements to do that. I have also done the same for the "Site Report"

I believe the following columns under "Device Report" should be zeroed out when you "Remove All Scan Results".
"Total IP's", "User Ports", "User Ports Up", "Trunk Ports", "Active Macs", "Last Duration"

I believe the following columns under "Site Report" should be zeroed out as well when you "Remove All Scan Results". I do think Device Errors should remain. No reason to zero that column out.
"Total IPs", "User Ports", User Ports Up", "MACs Found"

**Assuming a unmodifed "mactack_utilities.php" which should contain 434 lines. I inserted the following code after line 319**

$mactrackdevicerows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_devices");
for ( $counter = 1; $counter <= $mactrackdevicerows; $counter += 1) {
db_execute("UPDATE mac_track_devices SET ips_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_active='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_trunk='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET macs_active='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET vlans_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET last_runduration='0.00000' WHERE device_id='" . $counter . "'");
}
$mactracksiterows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_sites");
for ( $counter = 1; $counter <= $mactracksiterows; $counter += 1) {
db_execute("UPDATE mac_track_sites SET total_devices='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_macs='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_ips='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_user_ports='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_oper_ports='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_trunk_ports='0' WHERE site_id='" . $counter . "'");
}

Thx again for this wonderful tool Witness.

-Lance
User avatar
TheWitness
Developer
Posts: 17059
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Can you link this post to the features section. I will be working on this on Monday.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

Re: Tracking Utilities -> Remove All Scan Results ...mods

Post by lavermil »

lavermil wrote:Hello,

I love this tool I am comparing it to a tool I have been developing a little with someone else (switchmap). Currently switchmap does everything I need and more. I really like the interface of MAC Track and it allows me to write my own custom reports. I am really happy so far. I have to see if it finds as many IP-MAC pairs as the (switchmap) install I have running.

None the less I have realized when Doing a Remove All Scan Results, you don't end up with the following columns being zeroed out if you are under the "Device Report". So I have added in a few statements to do that. I have also done the same for the "Site Report"

I believe the following columns under "Device Report" should be zeroed out when you "Remove All Scan Results".
"Total IP's", "User Ports", "User Ports Up", "Trunk Ports", "Active Macs", "Last Duration"

I believe the following columns under "Site Report" should be zeroed out as well when you "Remove All Scan Results". I do think Device Errors should remain. No reason to zero that column out.
"Total IPs", "User Ports", User Ports Up", "MACs Found"

**Assuming a unmodifed "mactack_utilities.php" which should contain 434 lines. I inserted the following code after line 319**

$mactrackdevicerows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_devices");
for ( $counter = 1; $counter <= $mactrackdevicerows; $counter += 1) {
db_execute("UPDATE mac_track_devices SET ips_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_active='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_trunk='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET macs_active='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET vlans_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET last_runduration='0.00000' WHERE device_id='" . $counter . "'");
}
$mactracksiterows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_sites");
for ( $counter = 1; $counter <= $mactracksiterows; $counter += 1) {
db_execute("UPDATE mac_track_sites SET total_devices='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_macs='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_ips='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_user_ports='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_oper_ports='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_trunk_ports='0' WHERE site_id='" . $counter . "'");
}

Thx again for this wonderful tool Witness.

-Lance
If you have lastest SVN version of mactrack you need to insert at line 328 (aka after line 327).

Insert the above SQL code after the following set of code that is in the lastest SVN release.

[line 324] if ((read_config_option("remove_verification") == "") || (isset($_GET["confirm"]))) {
[line 325] $rows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_ports");
[line 326] db_execute("TRUNCATE TABLE mac_track_ports");
[line 327] db_execute("TRUNCATE TABLE mac_track_scan_dates");
lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

Re: Tracking Utilities -> Remove All Scan Results ...mods

Post by lavermil »

lavermil wrote:
lavermil wrote:Hello,

I love this tool I am comparing it to a tool I have been developing a little with someone else (switchmap). Currently switchmap does everything I need and more. I really like the interface of MAC Track and it allows me to write my own custom reports. I am really happy so far. I have to see if it finds as many IP-MAC pairs as the (switchmap) install I have running.

None the less I have realized when Doing a Remove All Scan Results, you don't end up with the following columns being zeroed out if you are under the "Device Report". So I have added in a few statements to do that. I have also done the same for the "Site Report"

I believe the following columns under "Device Report" should be zeroed out when you "Remove All Scan Results".
"Total IP's", "User Ports", "User Ports Up", "Trunk Ports", "Active Macs", "Last Duration"

I believe the following columns under "Site Report" should be zeroed out as well when you "Remove All Scan Results". I do think Device Errors should remain. No reason to zero that column out.
"Total IPs", "User Ports", User Ports Up", "MACs Found"

**Assuming a unmodifed "mactack_utilities.php" which should contain 434 lines. I inserted the following code after line 319**

$mactrackdevicerows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_devices");
for ( $counter = 1; $counter <= $mactrackdevicerows; $counter += 1) {
db_execute("UPDATE mac_track_devices SET ips_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_active='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET ports_trunk='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET macs_active='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET vlans_total='0' WHERE device_id='" . $counter . "'");
db_execute("UPDATE mac_track_devices SET last_runduration='0.00000' WHERE device_id='" . $counter . "'");
}
$mactracksiterows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_sites");
for ( $counter = 1; $counter <= $mactracksiterows; $counter += 1) {
db_execute("UPDATE mac_track_sites SET total_devices='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_macs='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_ips='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_user_ports='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_oper_ports='0' WHERE site_id='" . $counter . "'");
db_execute("UPDATE mac_track_sites SET total_trunk_ports='0' WHERE site_id='" . $counter . "'");
}

Thx again for this wonderful tool Witness.

-Lance
If you have lastest SVN version of mactrack you need to insert at line 328 (aka after line 327).

Insert the above SQL code after the following set of code that is in the lastest SVN release.

[line 324] if ((read_config_option("remove_verification") == "") || (isset($_GET["confirm"]))) {
[line 325] $rows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_ports");
[line 326] db_execute("TRUNCATE TABLE mac_track_ports");
[line 327] db_execute("TRUNCATE TABLE mac_track_scan_dates");

Anyhow I have tried to come up with a better way to do it since the count is off if you delete an item from either sites or devices. I was trying to do it all in sql, but I think php my be needed. Similar to how you do it in your poller script.
lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

Post by lavermil »

Witness,

Here is the best code I could come up with. It gets the job done. You might be able to come up with something more elegant. This catches everything even if you delete sites or devices.

$mactrackdevicerows = db_fetch_assoc("SELECT device_id FROM mac_track_devices");
foreach ($mactrackdevicerows as $device_row) {
db_execute("UPDATE mac_track_devices SET ips_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_active='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_trunk='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET macs_active='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET vlans_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET last_runduration='0.00000' WHERE device_id='" . $device_row['device_id'] . "'");
}
$mactracksiterows = db_fetch_assoc("SELECT site_id FROM mac_track_sites");
print_r($mactracksiterows);
foreach ($mactracksiterows as $site_row) {
db_execute("UPDATE mac_track_sites SET total_devices='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_macs='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_ips='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_user_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_oper_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_trunk_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
}
lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

Post by lavermil »

lavermil wrote:Witness,

Here is the best code I could come up with. It gets the job done. You might be able to come up with something more elegant. This catches everything even if you delete sites or devices.

$mactrackdevicerows = db_fetch_assoc("SELECT device_id FROM mac_track_devices");
foreach ($mactrackdevicerows as $device_row) {
db_execute("UPDATE mac_track_devices SET ips_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_active='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_trunk='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET macs_active='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET vlans_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET last_runduration='0.00000' WHERE device_id='" . $device_row['device_id'] . "'");
}
$mactracksiterows = db_fetch_assoc("SELECT site_id FROM mac_track_sites");
print_r($mactracksiterows);
foreach ($mactracksiterows as $site_row) {
db_execute("UPDATE mac_track_sites SET total_devices='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_macs='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_ips='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_user_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_oper_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_trunk_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
}

OOPS..... One mistake. :-) I included zeroing out the total_devices field. My mistake. here is the correct one.


$mactrackdevicerows = db_fetch_assoc("SELECT device_id FROM mac_track_devices");
foreach ($mactrackdevicerows as $device_row) {
db_execute("UPDATE mac_track_devices SET ips_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_active='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET ports_trunk='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET macs_active='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET vlans_total='0' WHERE device_id='" . $device_row['device_id'] . "'");
db_execute("UPDATE mac_track_devices SET last_runduration='0.00000' WHERE device_id='" . $device_row['device_id'] . "'");
}
$mactracksiterows = db_fetch_assoc("SELECT site_id FROM mac_track_sites");
print_r($mactracksiterows);
foreach ($mactracksiterows as $site_row) {
db_execute("UPDATE mac_track_sites SET total_macs='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_ips='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_user_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_oper_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
db_execute("UPDATE mac_track_sites SET total_trunk_ports='0' WHERE site_id='" . $site_row['site_id'] . "'");
}
User avatar
TheWitness
Developer
Posts: 17059
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Instead of developing your own package, why don't you sign up with me. I could use the help...

Oh,

Here is the final version of your two suggestions. They are in SVN at the moment. Why don't you test?

Code: Select all

db_execute("UPDATE mac_track_sites SET total_macs=0, total_ips=0, total_user_ports=0, total_oper_ports=0, total_trunk_ports=0");
db_execute("UPDATE mac_track_devices SET ips_total=0, ports_total=0, ports_active=0, ports_trunk=0, macs_active=0, vlans_total=0, last_runduration=0.0000");
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
lavermil
Posts: 45
Joined: Thu Feb 15, 2007 2:25 pm
Location: Phoenix, Arizona

Post by lavermil »

TheWitness wrote:Instead of developing your own package, why don't you sign up with me. I could use the help...

Oh,

Here is the final version of your two suggestions. They are in SVN at the moment. Why don't you test?

Code: Select all

db_execute("UPDATE mac_track_sites SET total_macs=0, total_ips=0, total_user_ports=0, total_oper_ports=0, total_trunk_ports=0");
db_execute("UPDATE mac_track_devices SET ips_total=0, ports_total=0, ports_active=0, ports_trunk=0, macs_active=0, vlans_total=0, last_runduration=0.0000");
Sounds like fun. If this ends up being successful on the first couple of runs like the other project (switchmap http://switchmap.sf.net) then I am happy to lend a hand on the advancement I figureout etc. Like you I am always restricted to available free time.

I will try out the new code Tuesday. I will let you know.

Good idea to just shorten the statements to 2. I am not familiar with your functions yet, so I need to take some time and get use to them. ;)

-Lance
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests