From eddc7c82c46901578ba986165a18a7e2bfcc56e7 Mon Sep 17 00:00:00 2001 From: Tim Kent Date: Tue, 17 Nov 2015 14:12:34 +1000 Subject: [PATCH 1/3] Proxy support Define $proxy to use a proxy. --- nagios.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nagios.pl b/nagios.pl index 6c8a13f..27393fa 100644 --- a/nagios.pl +++ b/nagios.pl @@ -66,6 +66,8 @@ my $opt_domain = "foo.slack.com"; # Your team's domain my $opt_token = ""; # The token from your Nagios services page +# Define $proxy to use a proxy: +#my $proxy = "http://proxy:3128/"; # # Get command-line opts @@ -100,6 +102,10 @@ my $ua = LWP::UserAgent->new; $ua->timeout(15); +if (length $proxy) { + $ua->proxy(['https'], $proxy); +} + my $req = POST("https://${opt_domain}/services/hooks/nagios?token=${opt_token}", \%event); my $s = $req->as_string; From 56905e5ce2df6a504f11aecaa603c837b2edecff Mon Sep 17 00:00:00 2001 From: Tim Kent Date: Tue, 17 Nov 2015 14:30:07 +1000 Subject: [PATCH 2/3] Proxy support Left out blank $proxy definition needed when proxy not used. --- nagios.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/nagios.pl b/nagios.pl index 27393fa..5bd41f0 100644 --- a/nagios.pl +++ b/nagios.pl @@ -68,6 +68,7 @@ # Define $proxy to use a proxy: #my $proxy = "http://proxy:3128/"; +my $proxy = ""; # # Get command-line opts From e016b740b64a75c07d8c7766b1fc75a126999d6e Mon Sep 17 00:00:00 2001 From: Tim Kent Date: Thu, 19 Nov 2015 09:21:49 +1000 Subject: [PATCH 3/3] Escape backslashes --- nagios.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nagios.pl b/nagios.pl index 5bd41f0..cf8a9ff 100644 --- a/nagios.pl +++ b/nagios.pl @@ -87,7 +87,7 @@ # Get all Nagios variables while ((my $k, my $v) = each %ENV) { next unless $k =~ /^(?:NAGIOS|ICINGA)_(.*)$/; - $event{$1} = $v; + ($event{$1} = $v) =~ s/\\/\\\\/g; } # Merge in passed-in variables