Przeglądaj źródła

fixed remote control handling for router synchronization

root 1 rok temu
rodzic
commit
54d04f9
2 zmienionych plików z 11 dodań i 11 usunięć
  1. 9 9
      scripts/sync_mikrotik.pl
  2. 2 2
      scripts/sync_mikrotik_poe_monitor.pl

+ 9 - 9
scripts/sync_mikrotik.pl

@@ -123,7 +123,7 @@ next if (!$int);
 $int=trim($int);
 
 #get ip addr at interface
-my @int_addr=netdev_cmd($gate,$t,$gate->{proto},'/ip address print terse without-paging where interface='.$int,1);
+my @int_addr=netdev_cmd($gate,$t,'/ip address print terse without-paging where interface='.$int,1);
 
 log_debug("Get interfaces: ".Dumper(\@int_addr));
 
@@ -152,7 +152,7 @@ db_log_verbose($dbh,"Analyze interface $int. Found: ".Dumper($dhcp_conf{$found_s
 if ($gate->{dhcp}) {
 
 #fetch current dhcp records
-my @ret_static_leases=netdev_cmd($gate,$t,$gate->{proto},'/ip dhcp-server lease print terse without-paging where server=dhcp-'.$int,1);
+my @ret_static_leases=netdev_cmd($gate,$t,'/ip dhcp-server lease print terse without-paging where server=dhcp-'.$int,1);
 
 log_debug("Get dhcp leases:".Dumper(\@ret_static_leases));
 
@@ -457,7 +457,7 @@ log_debug("Group filters: ".Dumper(\%group_filters));
 my %cur_users;
 
 foreach my $group_name (keys %lists) {
-my @address_lists=netdev_cmd($gate,$t,$gate->{proto},'/ip firewall address-list print terse without-paging where list='.$group_name,1);
+my @address_lists=netdev_cmd($gate,$t,'/ip firewall address-list print terse without-paging where list='.$group_name,1);
 
 log_debug("Get address lists:".Dumper(\@address_lists));
 
@@ -496,7 +496,7 @@ timestamp;
 #sync firewall rules
 
 #sync group chains
-my @chain_list=netdev_cmd($gate,$t,$gate->{proto},'/ip firewall filter  print terse without-paging where chain=Users and action=jump',1);
+my @chain_list=netdev_cmd($gate,$t,'/ip firewall filter  print terse without-paging where chain=Users and action=jump',1);
 
 log_debug("Get firewall chains:".Dumper(\@chain_list));
 
@@ -601,7 +601,7 @@ foreach my $filter_index (sort keys %group_filter) {
 #chain filters
 foreach my $group_name (sort keys %group_filters) {
 next if (!$group_name);
-my @get_filter=netdev_cmd($gate,$t,$gate->{proto},'/ip firewall filter print terse without-paging where chain='.$group_name,1);
+my @get_filter=netdev_cmd($gate,$t,'/ip firewall filter print terse without-paging where chain='.$group_name,1);
 chomp(@get_filter);
 my @cur_filter=();
 my $chain_ok=1;
@@ -661,7 +661,7 @@ my %get_queue_type=();
 my %get_queue_tree=();
 my %get_filter_mangle=();
 
-my @tmp=netdev_cmd($gate,$t,$gate->{proto},'/queue type print terse without-paging where name~"pcq_(down|up)load"',1);
+my @tmp=netdev_cmd($gate,$t,'/queue type print terse without-paging where name~"pcq_(down|up)load"',1);
 
 log_debug("Get queues: ".Dumper(\@tmp));
 
@@ -691,7 +691,7 @@ if ($row=~/name=pcq_(down|up)load_(\d){1,3}\s+/i) {
 }
 
 @tmp=();
-@tmp=netdev_cmd($gate,$t,$gate->{proto},'/queue tree print terse without-paging where parent~"(download|upload)_root"',1);
+@tmp=netdev_cmd($gate,$t,'/queue tree print terse without-paging where parent~"(download|upload)_root"',1);
 log_debug("Get root queues: ".Dumper(\@tmp));
 
 #print Dumper(\@tmp);
@@ -729,7 +729,7 @@ if ($row=~/queue=pcq_(down|up)load_(\d){1,3}/i) {
 
 @tmp=();
 
-@tmp=netdev_cmd($gate,$t,$gate->{proto},'/ip firewall mangle print terse without-paging where action=mark-packet and new-packet-mark~"(upload|download)_[0-9]{1,3}"',1);
+@tmp=netdev_cmd($gate,$t,'/ip firewall mangle print terse without-paging where action=mark-packet and new-packet-mark~"(upload|download)_[0-9]{1,3}"',1);
 log_debug("Get firewall mangle rules for queues:".Dumper(\@tmp));
 
 # 0    chain=forward action=mark-packet new-packet-mark=upload_0 passthrough=yes src-address-list=queue_0 out-interface=sfp-sfpplus1-wan log=no log-prefix=""
@@ -868,7 +868,7 @@ if (scalar(@cmd_list)) {
     log_debug("Apply:");
     if ($debug) { foreach my $cmd (@cmd_list) { log_debug("$cmd"); } }
     eval {
-        netdev_cmd($gate,$t,$gate->{proto},\@cmd_list,1);
+        netdev_cmd($gate,$t,\@cmd_list,1);
     };
     if ($@) {
         $all_ok = 0;

+ 2 - 2
scripts/sync_mikrotik_poe_monitor.pl

@@ -65,7 +65,7 @@ my $t = netdev_login($device);
 #/interface ethernet set [ find default-name=ether2 ] loop-protect=on speed=100Mbps
 
 #fetch current
-my @current_monitor=netdev_cmd($device,$t,'ssh','/interface ethernet export terse',1);
+my @current_monitor=netdev_cmd($device,$t,'/interface ethernet export terse',1);
 @current_monitor=grep(/power/,@current_monitor);
 
 my %current_list;
@@ -108,7 +108,7 @@ if (!defined $current_list{$work_port}) {
 }
 
 if (scalar(@cmd_list)) {
-    netdev_cmd($device,$t,'ssh',\@cmd_list,1);
+    netdev_cmd($device,$t,\@cmd_list,1);
     if ($debug) { foreach my $cmd (@cmd_list) { db_log_debug($dbh,"$cmd"); } }
     }