Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


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

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (MAC Track)
Author Message
lavermil



Joined: 15 Feb 2007
Posts: 45
Location: Phoenix, Arizona

PostPosted: Thu Feb 15, 2007 7:29 pm    Post subject: Tracking Utilities -> Remove All Scan Results ...mods Reply with quote

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
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9723
Location: MI, USA

PostPosted: Fri Feb 16, 2007 5:22 pm    Post subject: Reply with quote

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

TheWitness
Back to top
lavermil



Joined: 15 Feb 2007
Posts: 45
Location: Phoenix, Arizona

PostPosted: Fri Feb 16, 2007 5:41 pm    Post subject: Re: Tracking Utilities -> Remove All Scan Results ...mods Reply with quote

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");
Back to top
lavermil



Joined: 15 Feb 2007
Posts: 45
Location: Phoenix, Arizona

PostPosted: Fri Feb 16, 2007 7:27 pm    Post subject: Re: Tracking Utilities -> Remove All Scan Results ...mods Reply with quote

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.
Back to top
lavermil



Joined: 15 Feb 2007
Posts: 45
Location: Phoenix, Arizona

PostPosted: Fri Feb 16, 2007 8:01 pm    Post subject: Reply with quote

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'] . "'");
}
Back to top
lavermil



Joined: 15 Feb 2007
Posts: 45
Location: Phoenix, Arizona

PostPosted: Fri Feb 16, 2007 8:02 pm    Post subject: Reply with quote

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'] . "'");
}
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9723
Location: MI, USA

PostPosted: Mon Feb 19, 2007 10:02 am    Post subject: Reply with quote

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:

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");
Back to top
lavermil



Joined: 15 Feb 2007
Posts: 45
Location: Phoenix, Arizona

PostPosted: Tue Feb 20, 2007 12:58 am    Post subject: Reply with quote

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:

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (MAC Track) All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group