Feb
21
2012
Ok, this post is really of topic and in English, but I felt that I needed to communicate this.
This post if for all you that is running a op5 Monitor server.
Here is a quick how-to on how to notify from op5 monitor using Growl, the notification application not the metal-singing growling. That would have been awesome
Before we start I should mention that this is not a supported notification-plugin from op5 so do this at your own risk.
- First you need to install growl, you can find it at http://growl.info/
- Configure the Growl application to allow network connections and set a password

- After that we need to install a Perl-library called Net::Growl, install it with the following command:
#cpan Net::Growl
(You will need cpan installed for this, this you have to figure out on you own
)
- Second we need to create a notification script, put this in /opt/monitor/op5/notify/growl.pl
#!/usr/bin/perl -w
#
# Created by Mathieu Gagné 2009
#
use strict;
use warnings;
use Net::Growl;
use Getopt::Long qw(:config no_ignore_case bundling);
# Default values
my $application = 'Nagios';
my $title = 'Alert';
my $message = '';
my $priority = 2;
my $sticky = 0;
my $destination = 'localhost';
my $password = '';
my $help = 0;
my $pod2usage = sub {
# Load Pod::Usage only if needed.
require "Pod/Usage.pm";
import Pod::Usage;
pod2usage(@_);
};
# Declare and retreive options
GetOptions(
'h|help' => \$help,
'a|application=s' => \$application,
't|title=s' => \$title,
'm|message=s' => \$message,
'P|priority=i' => \$priority,
's|sticky' => \$sticky,
'H|host=s' => \$destination,
'p|password=s' => \$password,
) or $pod2usage->(1);
# Print help
$pod2usage->(1) if $help;
# Validate options
if ( $application eq '' ) {
die "Error: Missing mandatory option: application\n";
}
if ( $title eq '' ) {
die "Error: Missing mandatory option: title\n";
}
if ( $message eq '' ) {
die "Error: Missing mandatory option: message\n";
}
if ( $priority eq '' ) {
die "Error: Missing mandatory option: priority\n";
}
if ( $password eq '' ) {
die "Error: Missing mandatory option: password\n";
}
#
# Main program
#
# Set up the Socket
my %addr = (
PeerAddr => $destination,
PeerPort => Net::Growl::GROWL_UDP_PORT,
Proto => 'udp',
);
my $s = IO::Socket::INET->new ( %addr ) || die "Could not create socket: $!\n";
# Register the application
my $p = Net::Growl::RegistrationPacket->new(
application => $application,
password => $password,
);
$p->addNotification();
print $s $p->payload();
# Send a notification
$p = Net::Growl::NotificationPacket->new(
application => $application,
title => $title,
description => $message,
priority => $priority,
sticky => $sticky,
password => $password,
);
print $s $p->payload();
close($s);
- Make this executable with
#chmod 755 /opt/monitor/op5/notify/growl.pl
- Now we have to configure the command in op5 monitor
- Go to the configuration and select command.
- Create new command for the host notification
Command_name: notify-host-by-growl
Command_line: $USER3$/notify/growl.pl -H $ARG1$ -p $ARG2$ -a op5 -t Alert -m "$NOTIFICATIONTYPE$ Alert $HOSTNAME$[$HOSTADDRESS$] is $HOSTSTATE$" –s 1
- Create one more command for the service notification
Command_name: notify-service-by-growl
Command_line: $USER3$/notify/growl.pl -H $ARG1$ -p $ARG2$ -a op5 -t Alert -m "$NOTIFICATIONTYPE$ Alert $HOSTNAME$[$HOSTADDRESS$]/$SERVICEDESC$ is $SERVICESTATE$" –s 1
- Now we just need to create a contact with the the growl notification script instead of the normal notification script. Go to configure and select contact.
- Create a new contact with a name of you choice. Change the host and service notification scripts to corresponding notification scripts.
- Change the notifications arguments to <DNSname-of-your-computer-with-growl>!<password>

- Now add this contact to a contact group, host or service to get notification through growl. An example of how this can look:

I would like to thank randerson on the original post on how to do this for nagios
Självutnämnd übernörd och chefsredaktör.
Jobbat både som sysadmin och produktspeciallist.
Älskar prylar och nörderi i alla dess former.
By Ola Sandström •
op5 •
• Tags: growl, monitor, nagios, notification, op5