Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37551102
en ru br
Репозитории ALT
S:2.2.1-alt1
5.1: 1.4.13-alt2.1
4.1: 1.4.12-alt1.M41.1
4.0: 1.4.5-alt1.1
3.0: 1.4-alt1
www.altlinux.org/Changes

Группа :: Мониторинг
Пакет: nagios-plugins

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

#!/usr/bin/perl -w
#
# Author David Cox
# Created from various code examples found on the web
# Last Modified 08/06/2002
# Feel free to use or modify as needed to suit your needs
#######################################################
# MAXWAIT is used because the send message function didn't seem to
# like being called to fast. The message would be sent unless I waited a second
# or so. You can experiment with it but I just went with 2 seconds.
#######################################################

use strict;
use Net::Jabber qw(Client) ;
use Net::Jabber qw(Message) ;
use Net::Jabber qw(Protocol) ;
use Net::Jabber qw(Presence) ;

my $len = scalar @ARGV;

if ($len ne 2) {
die "Usage...\n notify [jabberid] [message]\n";
}

my @field=split(/,/,$ARGV[0]);

use constant RECIPIENT => $ARGV[0];
use constant SERVER => 'jabber.domain.tld';
use constant PORT => 5222;
use constant USER => 'nagios-jid';
use constant PASSWORD => 'nagios-jid-password';
use constant RESOURCE => 'Nagios Notify';
use constant MESSAGE => $ARGV[1];
use constant MAXWAIT => 2 ;

my $connection = Net::Jabber::Client->new();
$connection->Connect( "hostname" => SERVER,"port" => PORT ) or die
"Cannot connect ($!)\n";

my @result = $connection->AuthSend( "username" => USER,"password" =>
PASSWORD,"resource" => RESOURCE );
if ($result[0] ne "ok") {
die "Ident/Auth with server failed: $result[0] - $result[1]\n";
}

foreach ( @field ) {
my $message = Net::Jabber::Message->new();
$message->SetMessage( "to" => $_,
"subject" => "Notification",
"type" => "chat",
"body" => MESSAGE);

$connection->Send($message);
sleep(MAXWAIT);
}
$connection->Disconnect();
exit;

 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin