sub sched_1m_weathermap_links { my $remote_user = ""; # e.g. 'www' my $remote_host = ""; # e.g. 10.1.2.3 my $remote_path = ""; # e.g. /var/www/html/plugins/weathermap/configs my $remote_file = "akips.txt"; my $data_file = "/tmp/weathermap.txt"; my %data; my $OUT; for my $line (adb_result ("mcalc avg time last1m ifrate * * /^IF-MIB.*BitRate/ any group weathermap-links")) { my ($device, $interface, $attr, undef, $val) = split (" ", $line, 5); my $link = sprintf ("%s:%s", $device, $interface); given ($attr) { when ("IF-MIB.ifInBitRate") { $data{$link}{inbps} = $val; } when ("IF-MIB.ifOutBitRate") { $data{$link}{outbps} = $val; } } } open ($OUT, ">", $data_file) || EXIT_FATAL ("Could not create %s", $data_file); for my $link (keys %data) { printf $OUT "%s\t%s\t%s\n", $link, $data{$link}{inbps}, $data{$link}{outbps}; } close $OUT; if ($remote_user ne "" and $remote_host ne "" and $remote_path ne "" and $remote_file ne "") { system (sprintf ("/usr/bin/scp -q %s %s@%s:%s/%s", $data_file, $remote_user, $remote_host, $remote_path, $remote_file)); } }