use Data::Dump qw(dump);
my $dir = 'public/json/monitor/printers';
-die "output directory $dir: $!" unless -d $dir;
+$dir = "/tmp/printers-" unless -d $dir;
use JSON;
sub save_json {
return sprintf "%04d-%02d-%02dT%02d:%02d:%02d", $y+1900, $m, $d, $hh, $mm, $ss;
}
+my $log_path = join('.', $dir, (split(/T/,iso_datetime,2))[0], 'json');
+open(my $log, '>>', $log_path) || die "$log_path: $!";
+
my $debug = $ENV{DEBUG} || 0;
my $community = 'public';
my @printers = qw(
10.60.0.20
+10.60.0.40
+10.60.0.41
+10.60.0.42
+10.60.0.43
+10.60.0.44
+10.60.0.45
+10.60.0.46
+10.60.0.47
+10.60.0.48
+10.60.0.49
+10.60.0.50
+10.60.0.51
+10.60.0.52
+10.60.0.53
+
10.60.3.15
10.60.3.17
print "$host = ",dump($status);
save_json $host => $status;
$collected->{$host} = $status;
+
+ print $log encode_json($status),"\n";
}
+close($log);
+warn "# log $log_path ", -s $log_path, " bytes\n";