Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.
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
15 changes: 11 additions & 4 deletions nagios.pl
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@
# service_notification_period 24x7
# host_notification_period 24x7
# service_notification_options w,u,c,r
# pager "your_api_token"
# host_notification_options d,r
# service_notification_commands notify-service-by-slack
# host_notification_commands notify-host-by-slack
# }
#
# define command {
# command_name notify-service-by-slack
# command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#alerts
# command_line /usr/local/bin/slack_nagios.pl -domain "foo.slack.com" -token "$CONTACTPAGER$" -field slack_channel=#alerts
# }
#
#define command {
# command_name notify-host-by-slack
# command_line /usr/local/bin/slack_nagios.pl -field slack_channel=#ops
# command_line /usr/local/bin/slack_nagios.pl -domain "foo.slack.com" -token "$CONTACTPAGER$" -field slack_channel=#ops
# }
#

Expand All @@ -72,8 +73,14 @@
#

my %opt_fields;
GetOptions("field=s%" => \%opt_fields);

my $opt_domain_override;
my $opt_token_override;
GetOptions("field=s%" => \%opt_fields,
"domain=s" => \$opt_domain_override,
"token=s" => \$opt_token_override);

if ( $opt_domain_override ) { $opt_domain = $opt_domain_override; }
if ( $opt_token_override ) { $opt_token = $opt_token_override; }

#
# DO THINGS
Expand Down