[asterisk-users] E1 check with nagios, how to?

Joel Maslak jmaslak at antelope.net
Tue Sep 28 10:30:15 CDT 2010


Enjoy...you can ignore certain T1/E1 ports if you pass in the name of the
port as an argument (I use this on ports that aren't yet connected to a
telco, but I don't want to get an alert on).  I execute it via NRPE on the
Asterisk box.  It will give you descriptions of which ports are bad, so you
don't need to guess.  :)


#!/usr/bin/perl -w
#
# Copyright (C) 2010 Local Matters, Inc.
# http://www.localmatters.com/
# Author: Joel C. Maslak
#
# Licensed under GPL version 3
#

use strict;

use Carp;

my %ignore;

MAIN: {
        my @out = `/usr/sbin/dahdi_scan`;

        for my $ig (@ARGV) {
                $ignore{$ig} = 1;
        }

        my $alarm;
        my $desc;
        my @alarms;

        for my $line (@out) {
                chomp($line);

                if ($line =~ /^alarms=/) {
                        $alarm = $line;
                        $alarm =~ s/^alarms=//;
                }
                if ($line =~ /^description=/) {
                        $desc = $line;
                        $desc =~ s/^description=//;
                        if (!defined($ignore{$desc})) {
                                if ($alarm ne 'OK') {
                                        push @alarms, "$desc: $alarm Alarm";
                                }
                        }
                }
        }

        if (scalar(@alarms) > 0) {
                my $out = join '; ', @alarms;
                print "Circuits in alarm: $out\n";
                exit(2);
        } else {
                print "All monitored circuits OK\n";
                exit(0);
        }

}


On Tue, Sep 28, 2010 at 9:17 AM, Mark Deneen <mdeneen at gmail.com> wrote:

> Are you monitoring some dahdi hardware or a separate "black box"?
>
> If dahdi, you could write a nagios plugin in shell with something like
> this:
>
> ALARMS=`dahdi_scan  | grep alarms | grep -v OK | wc -l`
>
> and then set the appropriate exit code if ALARMS is not 0.
>
>
> -M
>
> On Tue, Sep 28, 2010 at 9:22 AM, Dario Quiroz <darioquiroz at gmail.com>
> wrote:
> > We need to monitorate the E1 with nagios, somebody did this? any ideia?
> > Thanks in advance!
> >
> > --
> > Atenciosamente,
> >
> > -------------------------------------------------------
> >
> >                      Dario Quiroz
> >
> >                     (71) 9275-9080
> >        gtalk: darioquiroz at gmail.com
> >
> > -------------------------------------------------------
> >
> > --
> > _____________________________________________________________________
> > -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> > New to Asterisk? Join us for a live introductory webinar every Thurs:
> >               http://www.asterisk.org/hello
> >
> > asterisk-users mailing list
> > To UNSUBSCRIBE or update options visit:
> >   http://lists.digium.com/mailman/listinfo/asterisk-users
> >
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100928/83fc0a5f/attachment.htm 


More information about the asterisk-users mailing list