From ce67a8f7193b88081731e9d6ede72c9c85e6823e Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 6 Mar 2018 08:52:12 +0100 Subject: [PATCH] Respond with all stats as a JSON structure if no --what given --- zabbix_scripts/check_httpd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zabbix_scripts/check_httpd b/zabbix_scripts/check_httpd index 180726a..5027bd1 100644 --- a/zabbix_scripts/check_httpd +++ b/zabbix_scripts/check_httpd @@ -4,6 +4,7 @@ use strict; use warnings; use LWP::Simple; use Getopt::Long; +use JSON; my $uri = 'http://127.0.0.1/server-status'; my $what = undef; @@ -36,13 +37,16 @@ foreach my $line (split(/\n/, $status)){ $res{$key} = $val; } -if ($help || !$what){ +if ($help){ print "Valid keys are:\n\n"; print "$_\n" for keys %res; exit 0; } -if (defined $res{$what}){ +if (!$what){ + print to_json(\%res); +} +elsif (defined $res{$what}){ print $res{$what}; } else{