Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Proxy support #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion nagios.pl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
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/";
my $proxy = "";

#
# Get command-line opts
Expand All @@ -84,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
Expand All @@ -100,6 +103,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;
Expand Down