From 9058167a9edb2c8b5cbedab7fbf0a9d501038845 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 9 Nov 2016 16:26:34 +0100 Subject: [PATCH] Add scritps to monitor httpd --- zabbix_conf/httpd.conf | 6 ++++++ zabbix_scripts/check_httpd | 45 +++++++++++++++++++++++++++++++++++++++++++++ zabbix_scripts/disco_httpd | 18 ++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 zabbix_conf/httpd.conf create mode 100644 zabbix_scripts/check_httpd create mode 100644 zabbix_scripts/disco_httpd diff --git a/zabbix_conf/httpd.conf b/zabbix_conf/httpd.conf new file mode 100644 index 0000000..e9eeb5e --- /dev/null +++ b/zabbix_conf/httpd.conf @@ -0,0 +1,6 @@ +# Discover if an httpd instance is running and has mod_status available on http://127.0.0.1/server-status +# Just return {#HTTPD_STATUS_AVAILABLE} => 'yes' if found +UserParameter=httpd.discovery,/var/lib/zabbix/bin/disco_httpd + +# Stats to get +UserParameter=httpd[*],/var/lib/zabbix/bin/check_httpd -w $1 diff --git a/zabbix_scripts/check_httpd b/zabbix_scripts/check_httpd new file mode 100644 index 0000000..21efe13 --- /dev/null +++ b/zabbix_scripts/check_httpd @@ -0,0 +1,45 @@ +#!/usr/bin/env perl -w + +use strict; +use warnings; +use LWP::Simple; +use Getopt::Long; + +my $what = undef; +my $help = 0; + +GetOptions( + "what=s" => \$what, + "help" => \$help +); + +my %res = (); +my $status = get("http://127.0.0.1/server-status?auto"); + + +unless ($status){ + print 'ZBX_UNSUPPOTED'; + exit 1; +} + +foreach my $line (split(/\n/, $status)){ + my ($key, $val) = split(/:/, $line); + $key =~ s/\s/_/g; + $key = lc $key; + $val =~ s/^\s+|\s+$//g; + $res{$key} = $val; +} + +if ($help || !$what){ + print "Valid keys are:\n\n"; + print "$_\n" for keys %res; + exit 0; +} + +if (defined $res{$what}){ + print $res{$what}; +} +else{ + print 'ZBX_UNSUPPOTED'; +} +exit 0; diff --git a/zabbix_scripts/disco_httpd b/zabbix_scripts/disco_httpd new file mode 100644 index 0000000..75176f6 --- /dev/null +++ b/zabbix_scripts/disco_httpd @@ -0,0 +1,18 @@ +#!/usr/bin/env perl -w + +use strict; +use warnings; +use LWP::Simple; +use JSON; + +my $json; +@{$json->{data}} = (); + +my $status = get('http://127.0.0.1/server-status?auto'); + +if ($status){ + push @{$json->{data}}, {"{#HTTPD_STATUS_AVAILABLE}" => 'yes'}; +} + +print to_json($json); +exit(0);