{
my $cmd = Test::Command->new(cmd => "fping -J -c 1 -q host.invalid");
$cmd->exit_is_num(2); # Exit code 2 indicates name resolution error
-$cmd->stdout_is_eq("");
-$cmd->stderr_like(qr/^\{"host":\s"host\.invalid", "error":\s"(?:Name or service not known|Temporary failure in name resolution|nodename nor servname provided, or not known)"\}$/);
+$cmd->stdout_like(qr/^\{"warning":\s\{"host":\s"host\.invalid",\s"message":\s"(?:Name or service not known|Temporary failure in name resolution|nodename nor servname provided, or not known)"\}\}$/);
+$cmd->stderr_is_eq("");
}
# fping -J -c 1 -q -g 127.0.0.1/30
// Handle JSON output for invalid hosts
if (json_flag) {
- fprintf(stderr, "{\"host\": \"%s\", \"error\": \"%s\"}", name, gai_strerror(ret_ga));
+ fprintf(stdout, "{\"warning\": {\"host\": \"%s\", \"message\": \"%s\"}}", name, gai_strerror(ret_ga));
return;
}