Skip to content

Instantly share code, notes, and snippets.

@julsemaan
Last active December 24, 2015 22:29
Show Gist options
  • Save julsemaan/6c7676561d2458e8288c to your computer and use it in GitHub Desktop.
Save julsemaan/6c7676561d2458e8288c to your computer and use it in GitHub Desktop.
Recreate all location log entries
#!/usr/bin/perl
use lib '/usr/local/pf/lib';
use pf::locationlog qw(locationlog_insert_start locationlog_synchronize locationlog_view_open_mac);
use pf::db;
use pf::node qw(node_view_all);
use pf::config;
use pf::config::util qw(str_to_connection_type);
my @nodes = node_view_all('');
foreach my $node (@nodes){
print "Treating ".$node->{mac}."\n";
if(defined($node->{last_switch})){
my $location_logs = locationlog_view_open_mac($node->{mac});
db_query_execute('locationlog', $pf::locationlog::locationlog_statements, 'locationlog_update_end_mac_sql', $node->{mac});
my $connection_type = str_to_connection_type($location_logs->{connection_type});
#my $result = locationlog_insert_start($node->{last_switch}, $location_logs->{switch_ip}, $location_logs->{switch_mac}, $node->{last_port}, $node->{last_vlan}, $node->{mac}, $connection_type, $node->{last_dot1x_username}, $node->{last_ssid});
print "---------------------------\n";
print "MAC : ".$node->{mac}."\n";
print "Last switch : ".$node->{last_switch}."\n";
print "Switch IP : ".$location_logs->{switch_ip}."\n";
print "Switch mac : ".$location_logs->{switch_mac}."\n";
print "Port : ".$node->{last_port}."\n";
print "Last VLAN : ".$node->{last_vlan}."\n";
print "Connection type : ".$connection_type."\n";
print "Last dot1x username : ".$node->{last_dot1x_username}."\n";
print "Last SSID : ".$node->{last_ssid}."\n";
locationlog_insert_start($node->{last_switch}, $location_logs->{switch_ip}, $location_logs->{switch_mac}, $node->{last_port}, $node->{last_vlan}, $node->{mac}, $connection_type, undef, $node->{last_dot1x_username}, $node->{last_ssid}, undef, undef, undef);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment