From b12bc3a0b8c44f685f39430e92216c842c8be1f5 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 7 Jun 2010 22:23:19 -0300 Subject: Symlink for Debian/private/resource.cfg.amd64 --- files/configs/Debian/private/resource.cfg.amd64 | 1 + 1 file changed, 1 insertion(+) create mode 120000 files/configs/Debian/private/resource.cfg.amd64 (limited to 'files') diff --git a/files/configs/Debian/private/resource.cfg.amd64 b/files/configs/Debian/private/resource.cfg.amd64 new file mode 120000 index 0000000..9ffdc16 --- /dev/null +++ b/files/configs/Debian/private/resource.cfg.amd64 @@ -0,0 +1 @@ +resource.cfg.x86_64 \ No newline at end of file -- cgit v1.2.3 From 6c402ff7740e0ebf190415a003f17ee83c021804 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 7 Jun 2010 23:01:24 -0300 Subject: Re-adding resource.cfg.amd64 for debian --- files/configs/Debian/private/resource.cfg.amd64 | 32 ++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) mode change 120000 => 100644 files/configs/Debian/private/resource.cfg.amd64 (limited to 'files') diff --git a/files/configs/Debian/private/resource.cfg.amd64 b/files/configs/Debian/private/resource.cfg.amd64 deleted file mode 120000 index 9ffdc16..0000000 --- a/files/configs/Debian/private/resource.cfg.amd64 +++ /dev/null @@ -1 +0,0 @@ -resource.cfg.x86_64 \ No newline at end of file diff --git a/files/configs/Debian/private/resource.cfg.amd64 b/files/configs/Debian/private/resource.cfg.amd64 new file mode 100644 index 0000000..3ed732b --- /dev/null +++ b/files/configs/Debian/private/resource.cfg.amd64 @@ -0,0 +1,31 @@ +########################################################################### +# +# RESOURCE.CFG - Resource File for Nagios +# +# You can define $USERx$ macros in this file, which can in turn be used +# in command definitions in your host config file(s). $USERx$ macros are +# useful for storing sensitive information such as usernames, passwords, +# etc. They are also handy for specifying the path to plugins and +# event handlers - if you decide to move the plugins or event handlers to +# a different directory in the future, you can just update one or two +# $USERx$ macros, instead of modifying a lot of command definitions. +# +# The CGIs will not attempt to read the contents of resource files, so +# you can set restrictive permissions (600 or 660) on them. +# +# Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$) +# +# Resource files may also be used to store configuration directives for +# external data sources like MySQL... +# +########################################################################### + +# Sets $USER1$ to be the path to the plugins +$USER1$=/usr/lib/nagios/plugins + +# Sets $USER2$ to be the path to event handlers +#$USER2$=/usr/lib/nagios/plugins/eventhandlers + +# Store some usernames and passwords (hidden from the CGIs) +#$USER3$=someuser +#$USER4$=somepassword -- cgit v1.2.3 From 6227899364bc721b9c728151a69c46386d96cf44 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 21 Oct 2010 02:24:09 +0200 Subject: add check_dns2 check_dns had some problems with down nameservers. This one properly checks the right nameserver. --- files/plugins/check_dns2 | 102 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 files/plugins/check_dns2 (limited to 'files') diff --git a/files/plugins/check_dns2 b/files/plugins/check_dns2 new file mode 100644 index 0000000..2195631 --- /dev/null +++ b/files/plugins/check_dns2 @@ -0,0 +1,102 @@ +#!/bin/bash +# Written by Damien Gy +# damien.gy+nagiosexchange(AT)gmail.com +# 2007-09-28 + +PROGNAME=`basename $0` +REVISION=1.00 +TMP=/tmp/tmpdig +DIG=/usr/bin/dig + +print_revision() { + echo $PROGNAME $REVISION +} + +print_usage() { + echo "Usage:" + echo " $PROGNAME -c|--check " + echo " $PROGNAME -h|--help" + echo " $PROGNAME -v|--version" +} + +print_help() { + print_revision + echo "" + print_usage + echo "Where:" + echo " host the name of the resource record to be looked up" + echo " type indicates the query required (any, a, mx, etc.)" + echo " server the name or IP address of the name server to query" + echo "" + echo " -h|--help prints this help screen" + echo "" + echo " -v|--version prints version and license information" + echo "" + echo " Created by Damien Gy, questions or problems e-mail damien.gy+nagiosexchange(AT)gmail.com" + echo "" +} + +check_dns() { + + if [ $# -ne 3 ] + then + echo "Number of arguments incorrect" + exit 3 + fi + if [ ! -e $DIG ] + then + echo "$DIG not found" + exit 3 + fi + $DIG $1 $2 @$3 > $TMP + + if ( grep "status" $TMP > /dev/null ) + then + # DNS server answered + if ( grep "NOERROR" $TMP > /dev/null ) + then + echo "DNS OK "`grep "time:" $TMP` + rm -f $TMP + exit 0 + else + echo "WARNING "`grep "time:" $TMP` + rm -f $TMP + exit 1 + fi + + else + # no answer + echo "CRITICAL - Connection timed out" + rm -f $TMP + exit 2 + fi +} + +case "$1" in +--help) + print_help + exit 0 + ;; +-h) + print_help + exit 0 + ;; +--version) + print_revision + exit 0 + ;; +-v) + print_revision + exit 0 + ;; +--check) + check_dns $2 $3 $4 + ;; +-c) + check_dns $2 $3 $4 + ;; +*) + print_usage + exit 3 + +esac -- cgit v1.2.3 From 12212a762f3c188fef94f763e3a006e49e3a333b Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 13 Dec 2010 19:40:20 -0500 Subject: Make nagios::apache manage the apache config. Currently, the nagios module purges all files under the Nagios configuration directory. This has the unwanted effect of removing files that are added by default by the .deb packages, thus making the Nagios interface non functional under apache. To fix the situation, make nagios::apache under Debian manage the apache config file and link to it in apache's conf.d directory, in the same manner as the Debian packages do. Signed-off-by: Gabriel Filion --- files/configs/apache2.conf | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 files/configs/apache2.conf (limited to 'files') diff --git a/files/configs/apache2.conf b/files/configs/apache2.conf new file mode 100644 index 0000000..14bb38b --- /dev/null +++ b/files/configs/apache2.conf @@ -0,0 +1,55 @@ +# apache configuration for nagios 3.x +# note to users of nagios 1.x and 2.x: +# throughout this file are commented out sections which preserve +# backwards compatibility with bookmarks/config for older nagios versios. +# simply look for lines following "nagios 1.x:" and "nagios 2.x" comments. + +ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3 +ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3 +# nagios 1.x: +#ScriptAlias /cgi-bin/nagios /usr/lib/cgi-bin/nagios3 +#ScriptAlias /nagios/cgi-bin /usr/lib/cgi-bin/nagios3 +# nagios 2.x: +#ScriptAlias /cgi-bin/nagios2 /usr/lib/cgi-bin/nagios3 +#ScriptAlias /nagios2/cgi-bin /usr/lib/cgi-bin/nagios3 + +# Where the stylesheets (config files) reside +Alias /nagios3/stylesheets /etc/nagios3/stylesheets +# nagios 1.x: +#Alias /nagios/stylesheets /etc/nagios3/stylesheets +# nagios 2.x: +#Alias /nagios2/stylesheets /etc/nagios3/stylesheets + +# Where the HTML pages live +Alias /nagios3 /usr/share/nagios3/htdocs +# nagios 2.x: +#Alias /nagios2 /usr/share/nagios3/htdocs +# nagios 1.x: +#Alias /nagios /usr/share/nagios3/htdocs + + + Options FollowSymLinks + + DirectoryIndex index.php index.html + + AllowOverride AuthConfig + Order Allow,Deny + Allow From All + + AuthName "Nagios Access" + AuthType Basic + AuthUserFile /etc/nagios3/htpasswd.users + # nagios 1.x: + #AuthUserFile /etc/nagios/htpasswd.users + require valid-user + + +# Enable this ScriptAlias if you want to enable the grouplist patch. +# See http://apan.sourceforge.net/download.html for more info +# It allows you to see a clickable list of all hostgroups in the +# left pane of the Nagios web interface +# XXX This is not tested for nagios 2.x use at your own peril +#ScriptAlias /nagios3/side.html /usr/lib/cgi-bin/nagios3/grouplist.cgi +# nagios 1.x: +#ScriptAlias /nagios/side.html /usr/lib/cgi-bin/nagios3/grouplist.cgi + -- cgit v1.2.3 From 7c9f6d224d9bf66bc1c69b1baa066f98b9302999 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Tue, 14 Dec 2010 15:14:54 -0500 Subject: Add nagios IRC bot Koumbit is using an IRC bot that Micah provided. It is a pair of perl scripts that send Nagios notifications as messages in an IRC channel. Add a class to make installing this IRC bot easy. It also defines commands 'notify-by-irc' and 'host-notify-by-irc' that can be used with checks to send notifications via the bot. Signed-off-by: Gabriel Filion --- files/irc_bot/riseup-nagios-client.pl | 40 +++++++++ files/irc_bot/riseup-nagios-server.pl | 157 ++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 files/irc_bot/riseup-nagios-client.pl create mode 100644 files/irc_bot/riseup-nagios-server.pl (limited to 'files') diff --git a/files/irc_bot/riseup-nagios-client.pl b/files/irc_bot/riseup-nagios-client.pl new file mode 100644 index 0000000..fd28996 --- /dev/null +++ b/files/irc_bot/riseup-nagios-client.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w + +# ############################################################################## +# Infrabot-Client - a simple Infrabot client which sends it's whole command +# line arguments to a local UNIX domain socket. +# ############################################################################## + +use strict; +use IO::Socket; + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# >> CONFIGURATION >> + +my $SOCKET = '/var/run/nagios/nsa.socket'; + +# << CONFIGURATION << +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +if (@ARGV == 0) { + print "Hey - specify a message, sucker!\n"; + exit(1); +} + +unless (-S $SOCKET) { + die "Socket '$SOCKET' doesn't exist or isn't a socket!\n"; +} + +unless (-r $SOCKET) { + die "Socket '$SOCKET' can't be read!\n"; +} + +my $sock = IO::Socket::UNIX->new ( + Peer => $SOCKET, + Type => SOCK_DGRAM, + Timeout => 10 +) || die "Can't open socket '$SOCKET'!\n"; + +print $sock "@ARGV"; +close($sock); diff --git a/files/irc_bot/riseup-nagios-server.pl b/files/irc_bot/riseup-nagios-server.pl new file mode 100644 index 0000000..7880dde --- /dev/null +++ b/files/irc_bot/riseup-nagios-server.pl @@ -0,0 +1,157 @@ +#!/usr/bin/perl -w + +# ############################################################################## +# a simple IRC bot which dispatches messages received via local domain sockets +# ############################################################################## + +use strict; +use File::Basename; + +BEGIN { + unshift @INC, dirname($0); +} + +my $VERSION = '0.2'; +my $running = 1; + +# Read a configuration file +# The arg can be a relative or full path, or +# it can be a file located somewhere in @INC. +sub ReadCfg +{ + my $file = $_[0]; + + our $err; + + { # Put config data into a separate namespace + package CFG; + + # Process the contents of the config file + my $rc = do($file); + + # Check for errors + if ($@) { + $::err = "ERROR: Failure compiling '$file' - $@"; + } elsif (! defined($rc)) { + $::err = "ERROR: Failure reading '$file' - $!"; + } elsif (! $rc) { + $::err = "ERROR: Failure processing '$file'"; + } + } + + return ($err); +} + +# Get our configuration information +if (my $err = ReadCfg('/etc/nagios_nsa.cfg')) { + print(STDERR $err, "\n"); + exit(1); +} + +use POSIX qw(setsid); +use IO::Socket; +use Net::IRC; + +sub new { + my $self = { + socket => undef, + irc => undef, + conn => undef + }; + + return bless($self, __PACKAGE__); +} + +sub daemonize { + my $self = shift; + my $pid; + + chdir '/' or die "Can't chdir to /: $!"; + + open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; + open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; + + defined ($pid = fork) or die "Can't fork: $!"; + + if ($pid && $CFG::Nsa{'pidfile'}) { # write pid of child + open PID, ">$CFG::Nsa{'pidfile'}" or die "Can't open pid file: $!"; + print PID $pid; + close PID; + } + exit if $pid; + setsid or die "Can't start a new session: $!"; + + #open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; +} + +sub run { + my $self = shift; + + $self->{irc}->do_one_loop(); +} + +sub shutdown { + my $sig = shift; + + print STDERR "Received SIG$sig, shutting down...\n"; + $running = 0; +} + +sub socket_has_data { + my $self = shift; + + $self->{socket}->recv(my $data, 1024); + $self->{conn}->privmsg($CFG::Nsa{'channel'}, $data); +} + +sub irc_on_connect { + my $self = shift; + + print STDERR "Joining channel '$CFG::Nsa{'channel'}'...\n"; + $self->join($CFG::Nsa{'channel'}); +} + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +my $bot = &new; + +if (-e $CFG::Nsa{'socket'}) { + die "Socket '$CFG::Nsa{'socket'}' exists!\n"; +} + +$bot->{socket} = IO::Socket::UNIX->new ( + Local => $CFG::Nsa{'socket'}, + Type => SOCK_DGRAM, + Listen => 5 +) || die "Can't create socket '$CFG::Nsa{'socket'}'!\n"; + +$SIG{INT} = $SIG{TERM} = \&shutdown; + +$bot->daemonize(); +$bot->{irc} = new Net::IRC; + +$bot->{conn} = $bot->{irc}->newconn ( + Server => $CFG::Nsa{'server'}, + Port => $CFG::Nsa{'port'}, + Nick => $CFG::Nsa{'nickname'}, + Username => $CFG::Nsa{'nickname'}, + Password => $CFG::Nsa{'password'}, + Ircname => $CFG::Nsa{'realname'} . " (NSA $VERSION)", +) || die "Can't connect to server '$CFG::Nsa{'server'}'!\n"; + +$bot->{conn}->add_global_handler(376, \&irc_on_connect); +$bot->{conn}->add_global_handler('nomotd', \&irc_on_connect); +$bot->{irc}->addfh($bot->{socket}, \&socket_has_data, 'r', $bot); + +while ($running) { + $bot->run(); +} + +close($bot->{socket}); +unlink($CFG::Nsa{'socket'}); + +exit(0); + +1; + +__END__ -- cgit v1.2.3 From ef76d11b5712e9c4cdc3a7454904ddbdecfdd868 Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 7 Feb 2011 01:41:12 +0100 Subject: make the client config aware --- files/irc_bot/riseup-nagios-client.pl | 46 +++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) (limited to 'files') diff --git a/files/irc_bot/riseup-nagios-client.pl b/files/irc_bot/riseup-nagios-client.pl index fd28996..2467058 100644 --- a/files/irc_bot/riseup-nagios-client.pl +++ b/files/irc_bot/riseup-nagios-client.pl @@ -12,7 +12,39 @@ use IO::Socket; # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # >> CONFIGURATION >> -my $SOCKET = '/var/run/nagios/nsa.socket'; +# Read a configuration file +# The arg can be a relative or full path, or +# it can be a file located somewhere in @INC. +sub ReadCfg +{ + my $file = $_[0]; + + our $err; + + { # Put config data into a separate namespace + package CFG; + + # Process the contents of the config file + my $rc = do($file); + + # Check for errors + if ($@) { + $::err = "ERROR: Failure compiling '$file' - $@"; + } elsif (! defined($rc)) { + $::err = "ERROR: Failure reading '$file' - $!"; + } elsif (! $rc) { + $::err = "ERROR: Failure processing '$file'"; + } + } + + return ($err); +} + +# Get our configuration information +if (my $err = ReadCfg('/etc/nagios_nsa.cfg')) { + print(STDERR $err, "\n"); + exit(1); +} # << CONFIGURATION << # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -22,19 +54,19 @@ if (@ARGV == 0) { exit(1); } -unless (-S $SOCKET) { - die "Socket '$SOCKET' doesn't exist or isn't a socket!\n"; +unless (-S $CFG::Nsa{'socket'}) { + die "Socket '$CFG::Nsa{'socket'}' doesn't exist or isn't a socket!\n"; } -unless (-r $SOCKET) { - die "Socket '$SOCKET' can't be read!\n"; +unless (-r $CFG::Nsa{'socket'}) { + die "Socket '$CFG::Nsa{'socket'}' can't be read!\n"; } my $sock = IO::Socket::UNIX->new ( - Peer => $SOCKET, + Peer => $CFG::Nsa{'socket'}, Type => SOCK_DGRAM, Timeout => 10 -) || die "Can't open socket '$SOCKET'!\n"; +) || die "Can't open socket '$CFG::Nsa{'socket'}'!\n"; print $sock "@ARGV"; close($sock); -- cgit v1.2.3 From 77f8a6aaef1314594330cdae02ee2d8d655a749c Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 2 Mar 2011 00:18:59 +0100 Subject: links do not work for file sources --- files/configs/Debian/private/resource.cfg.x86_64 | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) mode change 120000 => 100644 files/configs/Debian/private/resource.cfg.x86_64 (limited to 'files') diff --git a/files/configs/Debian/private/resource.cfg.x86_64 b/files/configs/Debian/private/resource.cfg.x86_64 deleted file mode 120000 index 4d5f0a3..0000000 --- a/files/configs/Debian/private/resource.cfg.x86_64 +++ /dev/null @@ -1 +0,0 @@ -resource.cfg.i386 \ No newline at end of file diff --git a/files/configs/Debian/private/resource.cfg.x86_64 b/files/configs/Debian/private/resource.cfg.x86_64 new file mode 100644 index 0000000..3ed732b --- /dev/null +++ b/files/configs/Debian/private/resource.cfg.x86_64 @@ -0,0 +1,31 @@ +########################################################################### +# +# RESOURCE.CFG - Resource File for Nagios +# +# You can define $USERx$ macros in this file, which can in turn be used +# in command definitions in your host config file(s). $USERx$ macros are +# useful for storing sensitive information such as usernames, passwords, +# etc. They are also handy for specifying the path to plugins and +# event handlers - if you decide to move the plugins or event handlers to +# a different directory in the future, you can just update one or two +# $USERx$ macros, instead of modifying a lot of command definitions. +# +# The CGIs will not attempt to read the contents of resource files, so +# you can set restrictive permissions (600 or 660) on them. +# +# Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$) +# +# Resource files may also be used to store configuration directives for +# external data sources like MySQL... +# +########################################################################### + +# Sets $USER1$ to be the path to the plugins +$USER1$=/usr/lib/nagios/plugins + +# Sets $USER2$ to be the path to event handlers +#$USER2$=/usr/lib/nagios/plugins/eventhandlers + +# Store some usernames and passwords (hidden from the CGIs) +#$USER3$=someuser +#$USER4$=somepassword -- cgit v1.2.3 From 7ceac56787ab3130024ad4a8e4cec05a8ec533fb Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 6 Mar 2011 18:00:30 +0100 Subject: add and deploy check_dnsbl script --- files/plugins/check_dnsbl | 107 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 files/plugins/check_dnsbl (limited to 'files') diff --git a/files/plugins/check_dnsbl b/files/plugins/check_dnsbl new file mode 100644 index 0000000..93cea37 --- /dev/null +++ b/files/plugins/check_dnsbl @@ -0,0 +1,107 @@ +#!/bin/sh +# +# dnsbl-check-nagios.sh +# +# (c) 2009 Damon Tajeddini & heise Netze +# +STATE_OK=0 +STATE_WARNING=1 +STATE_CRITICAL=2 +STATE_UNKNOWN=3 +STATE_DEPENDENT=4 + +FOUND_ADRESS=0 + +DNSBLlist=`grep -v ^# <] [-p]" + echo " -H check Host " + echo " -p print list of DNSBLs" + exit 3 +} + +# Checks the IP with list of DNSBL servers +check() +{ + count=0; + for i in $DNSBLlist + do + count=$(($count + 1)) + if nslookup $ip_arpa.$i | grep -q "127.0.0." ; + then + FOUND_ADRESS=$(($FOUND_ADRESS + 1)) + echo "DNSBL-Alarm: $ip is listed on $i" + fi + done + if [ $FOUND_ADRESS -ge 1 ] + then + exit 1 + fi + echo "OK - $ip not on $count DNSBLs" + exit 0 +} + +case $1 in + -H) + if [ -z "$2" ] + then + echo "ip address missing" + exit + fi + ip=$2 + ip_arpa=`convertIP $ip` + check;; + + -p) + for i in $DNSBLlist + do + echo $i + done + exit $STATE_WARNING + exit;; + + --help) + usage + exit;; + + *) + if [ -z "$1" ] + then + usage + fi + echo "unknown command: $1" + exit;; +esac -- cgit v1.2.3