/usr/sbin/octo_sender is in octopussy 1.0.6-0ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | #!/usr/bin/perl -w
=head1 NAME
octo_sender - Octopussy Sender program
=head1 SYNOPSIS
octo_sender
=head1 DESCRIPTION
octo_sender is the program used by the Octopussy Project to send messages
=cut
use strict;
use warnings;
use Readonly;
use AAT::NSCA;
use AAT::SMTP;
use AAT::Syslog;
use AAT::Utils qw( ARRAY );
use AAT::XMPP;
use AAT::Zabbix;
use Octopussy;
use Octopussy::Alert;
use Octopussy::Cache;
use Octopussy::Contact;
Readonly my $PROG_NAME => 'octo_sender';
exit if (!Octopussy::Valid_User($PROG_NAME));
my %contact = ();
my $file_pid = Octopussy::PID_File($PROG_NAME);
=head1 FUNCTIONS
=head2 Contact_Configuration()
Loads Contact Configuration
=cut
sub Contact_Configuration
{
foreach my $c (keys %contact)
{
delete $contact{$c};
}
foreach my $c (Octopussy::Contact::Configurations('cid'))
{
$contact{$c->{cid}} = $c;
}
my $nb_contacts = scalar(keys %contact);
AAT::Syslog::Message($PROG_NAME, 'LOAD_CONTACTS_CONFIG', $nb_contacts);
return ($nb_contacts);
}
=head2 Get_IM_Addresses($action)
Returns list of IM addresses from Contacts
=cut
sub Get_IM_Addresses
{
my $action = shift;
my @ims = ();
foreach my $c (ARRAY($action->{contacts}))
{
push @ims, $contact{$c}->{im}
if (defined $contact{$c}->{im});
}
return (@ims);
}
=head2 Get_Mail_Addresses($action)
Returns list of mail addresses from Contacts
=cut
sub Get_Mail_Addresses
{
my $action = shift;
my @mails = ();
foreach my $c (ARRAY($action->{contacts}))
{
push @mails, $contact{$c}->{email}
if (defined $contact{$c}->{email});
}
return (@mails);
}
#
# MAIN
#
$SIG{HUP} = \&Contact_Configuration;
Contact_Configuration();
my $cache = Octopussy::Cache::Init($PROG_NAME);
while (1)
{
my @keys = $cache->get_keys();
foreach my $k (sort @keys)
{
my $msg = $cache->get($k);
my $action = $msg->{action};
my ($subject, $body, $action_host, $action_service, $action_body) =
Octopussy::Alert::Message_Building($action, $msg->{device},
$msg->{data}, $msg->{msg});
if (defined $action->{action_jabber}
&& AAT::XMPP::Configured('Octopussy'))
{
my @ims = Get_IM_Addresses($action);
AAT::XMPP::Send_Message('Octopussy', $subject, @ims);
foreach my $line (split(/\n/, $body))
{
AAT::XMPP::Send_Message('Octopussy', $line, @ims);
}
}
if (defined $action->{action_mail})
{
my @mails = Get_Mail_Addresses($action);
AAT::SMTP::Send_Message('Octopussy',
{subject => $subject, body => $body, dests => \@mails});
}
AAT::NSCA::Send('Octopussy', (($action->{level} =~ /Warning/i) ? 1 : 2),
$action_body, $action_host, $action_service)
if (defined $action->{action_nsca});
AAT::Zabbix::Send('Octopussy', $action_body, $action_host,
$action_service)
if (defined $action->{action_zabbix});
$cache->remove($k);
}
sleep 1;
}
1;
=head1 AUTHOR
Sebastien Thebert <octo.devel@gmail.com>
=head1 SEE ALSO
octo_commander, octo_extractor, octo_parser, octo_uparser, octo_reporter, octo_rrd,
octo_scheduler
=cut
|