diff --git a/network/nagios/README b/network/nagios/README new file mode 100644 index 0000000000..7a448ce3a3 --- /dev/null +++ b/network/nagios/README @@ -0,0 +1,29 @@ +Nagios is a powerful monitoring system that enables organizations to identify +and resolve IT infrastructure problems before they affect critical business +processes. + +Nagios requires a "nagios" user and group; create these before running the +SlackBuild script. Examples: + + # groupadd -g 213 nagios + # useradd -u 213 -d /dev/null -s /bin/false -g nagios nagios + +For some scripts to work, it is necessary to include the 'apache' user in +the nagios group. + +For some functions (most notably the "map" function), you need to have X +installed on your server. You do not have to start X though, nagios just +needs some of the libraries and fonts. + +This SlackBuild installs the basic nagios system in /var/www/htdocs/ +To change the location, set the DOCROOT variable: + # DOCROOT=/your/docroot/dir ./nagios.SlackBuild + +For a useful setup, you will want to have nagios-plugins installed. + +To configure nagios, some knowledge of httpd is required. Check the included +'README.Slackware' file for some basic setup instructions. The include file +for httpd is installed as /etc/httpd/extra/nagios.conf + +Lots of information is available in the included documentation, and even more +can be found on the nagios site and wiki . diff --git a/network/nagios/README.Slackware b/network/nagios/README.Slackware new file mode 100644 index 0000000000..fcc3735d24 --- /dev/null +++ b/network/nagios/README.Slackware @@ -0,0 +1,121 @@ +README.Slackware +================ + +This file contains some basic instructions to get nagios installed and +running on your computer. + +0) Before running the SlackBuild Script +--------------------------------------- + +0.1) Create nagios group & user + +Before even running the SlackBuild script, create the necessary 'nagios' +user and group. The SlackBuild script won't run if these do not exist. + +The suggested UID and GID is 213, but you can change this as needed: + + # groupadd -g 213 nagios + # useradd -u 213 -d /dev/null -s /bin/false -g nagios nagios + +0.2) Add 'apache' to 'nagios' group + +For several nagios scripts to run without problems, you need to add the +'apache' user to the 'nagios' group, so that it can write to the +/var/nagios/rw directory: + + # usermod -G nagios apache + +0.3) Select DOCROOT + +The standard SlackBuild script puts the nagios files in /var/www/htdocs +This is fine for a stock Slackware installation, but if your 'DOCROOT' +lives in another directory, you can specify it when starting the SlackBuild +script like this: + +# DOCROOT=/your/docroot/dir ./nagios.SlackBuild + +1) Post-installation +-------------------- + +After building & installing the nagios package, there are some additional +steps to take. + +1.1) Check /etc/nagios/nagios.cfg & /etc/nagios/cgi.cfg + +These are the basic configuration files for the nagios server. Do read the +documentation to understand what all the different settings mean. + +1.2) Edit /etc/httpd/extra/nagios.conf + +To be able to view the documentation, edit this file. +After the "" line, change: + + Options None + +to read: + + Options FollowSymLinks + +1.3) Edit /etc/httpd/httpd.conf + +Now you need to add the extra/nagios.conf file as an included file. To +accomplish this, after the "DocumentRoot /srv/httpd/htdocs" line, add: + + Include /etc/httpd/extra/nagios.conf + +1.4) Create access file + +The /etc/httpd/extra/nagios.conf file defines /etc/nagios/htpasswd.users +as the file with the authorized users. +To create this file with a standard user called 'nagiosadmin', type: + + # htpasswd -c /etc/nagios/htpasswd.users nagiosadmin + +then type the password you choose twice. + +To add other users, delete users, etc., check the man page for htpasswd: + + # man htpasswd + +1.5) Restart httpd + + # /etc/rc.d/rc.httpd restart + +1.6) Put startup command in /etc/rc.d/rc.local: + + # Start nagios: + if [ -x /etc/rc.d/rc.nagios ]; then + echo "Starting nagios..." + /etc/rc.d/rc.nagios start + fi + +1.7) Put shutdown command in /etc/rc.d/rc.local_shutdown: + + # Stop nagios: + if [ -x /etc/rc.d/rc.nagios ]; then + echo "Stopping nagios..." + /etc/rc.d/rc.nagios stop + fi + +1.8) Make /etc/rc.d/rc.nagios executable: + + # chmod +x /etc/rc.d/rc.nagios + +1.9) Start nagios: + + # /etc/rc.d/rc.nagios start + +2) Adding hosts, routers, switches, etc. +---------------------------------------- + +Lot of documentation is included in this package and should be read to fully +understand how to add hosts, routers, switches, etc. + +To add functionality, build & install the nagios-plugins on your server. + +To monitor external Linux hosts, install the nrpe package on them, together +with the nagios-plugins. + +To monitor Windows hosts, install NSClient++ on them. + +Do check the http://wiki.nagios.org pages for some useful information. diff --git a/network/nagios/doinst.sh b/network/nagios/doinst.sh new file mode 100644 index 0000000000..4dd7fba9f9 --- /dev/null +++ b/network/nagios/doinst.sh @@ -0,0 +1,24 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +# Keep same perms on rc.nagios.new: +if [ -e etc/rc.d/rc.nagios ]; then + cp -a etc/rc.d/rc.nagios etc/rc.d/rc.nagios.new.incoming + cat etc/rc.d/rc.nagios.new > etc/rc.d/rc.nagios.new.incoming + mv etc/rc.d/rc.nagios.new.incoming etc/rc.d/rc.nagios.new +fi + +find etc/nagios/ -name *.cfg.new | while read cfg ; do config $cfg ; done +config etc/httpd/extra/nagios.conf.new +config etc/rc.d/rc.nagios.new + diff --git a/network/nagios/nagios.SlackBuild b/network/nagios/nagios.SlackBuild new file mode 100644 index 0000000000..103b682fcf --- /dev/null +++ b/network/nagios/nagios.SlackBuild @@ -0,0 +1,130 @@ +#!/bin/sh + +# Slackware build script for nagios: +# IT infrastructure monitoring system + +# Written by Niels Horn - niels.horn@gmail.com +# revision date 2009/11/15 + +PRGNAM=nagios +VERSION=3.2.0 +ARCH=${ARCH:-i486} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +DOCROOT=${DOCROOT:-/var/www/htdocs} + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +fi + +set -e + +# Check if the 'nagios' user & group exist: +if [ "$(grep ^nagios /etc/passwd)" = "" -o "$(grep ^nagios /etc/group)" = "" ] ; then + printf "\nYou must have a nagios user and group.\n\nExample:\n" + printf "\t# groupadd -g 213 nagios\n" + printf "\t# useradd -d /dev/null -s /bin/false -u 213 -g nagios nagios\n\n" + exit 1 +fi + +rm -rf $TMP/$PRGNAM-$VERSION $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +tar xvf $CWD/$PRGNAM-$VERSION.tar.gz +cd $PRGNAM-$VERSION +chown -R root:root . +chmod -R u+w,go+r-w,a-s . + +CFLAGS="$SLKCFLAGS" \ + ./configure \ + --prefix=/usr \ + --sbindir=/usr/sbin/$PRGNAM \ + --datadir=$DOCROOT/$PRGNAM \ + --libdir=/usr/lib${LIBDIRSUFFIX} \ + --libexecdir=/usr/libexec/nagios \ + --sysconfdir=/etc/nagios \ + --localstatedir=/var/$PRGNAM \ + --mandir=/usr/man \ + --build=$ARCH-slackware-linux \ + --with-httpd-conf=/etc/httpd/extra \ + --with-checkresult-dir=/var/spool/$PRGNAM \ + --with-init-dir=/etc/rc.d \ + --with-lockfile=/var/run/nagios/nagios.lock + +make all + +export DESTDIR=$PKG +make install +make install-init +make install-commandmode +make install-config +# Need to create the $PKG/etc/httpd/extra directory (this is a bug in Makefile.in) +mkdir -p $PKG/etc/httpd/extra +make install-webconf + +( cd $PKG + find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | \ + xargs strip --strip-unneeded 2> /dev/null || true + find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | \ + xargs strip --strip-unneeded 2> /dev/null || true +) + +( cd $PKG/usr/man + find . -type f -exec gzip -9 {} \; + for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done +) + +# Change configuration files to .new +find $PKG/etc/$PRGNAM/ -name *.cfg | while read cfg ; do mv $cfg $cfg.new ; done +mv $PKG/etc/httpd/extra/nagios.conf $PKG/etc/httpd/extra/nagios.conf.new + +# Create directory for lock-file +mkdir -p $PKG/var/run/nagios + +# Change init script and leave it -x +mv $PKG/etc/rc.d/$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new +chmod -x $PKG/etc/rc.d/rc.$PRGNAM.new + +# Move documentation to right location +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a \ + Changelog INSTALLING LEGAL LICENSE README THANKS UPGRADING contrib \ + $PKG/usr/doc/$PRGNAM-$VERSION +mv $PKG/$DOCROOT/$PRGNAM/docs $PKG/usr/doc/$PRGNAM-$VERSION/html +( cd $PKG/$DOCROOT/$PRGNAM ; ln -s /usr/doc/$PRGNAM-$VERSION/html docs ) +find $PKG/usr/doc/$PRGNAM-$VERSION -type f -exec chmod 644 {} \; +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild +cat $CWD/README.Slackware > $PKG/usr/doc/$PRGNAM-$VERSION/README.Slackware + +# Fixup some ownership and permission issues +chown -R root:root $PKG/usr/doc/nagios-3.2.0/html +chmod 0755 $PKG/usr/doc/nagios-3.2.0/html{,/images} +chown root:root $PKG/usr/sbin +chown -R root:nagios $PKG/usr/sbin/nagios +chmod -R 0754 $PKG/usr/sbin/nagios +chown root:root $PKG/usr/bin +chmod 0755 $PKG/usr/bin +chown root:nagios $PKG/usr/bin/* +chmod 0754 $PKG/usr/bin/* +chown nagios:nagios $PKG/var/run/nagios +chmod 0775 $PKG/var/run/nagios + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/network/nagios/nagios.info b/network/nagios/nagios.info new file mode 100644 index 0000000000..2202f2b81c --- /dev/null +++ b/network/nagios/nagios.info @@ -0,0 +1,10 @@ +PRGNAM="nagios" +VERSION="3.2.0" +HOMEPAGE="http://www.nagios.org/" +DOWNLOAD="http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz" +MD5SUM="3566167cc60ddeaad34e7d2e26ed4a58" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +MAINTAINER="Niels Horn" +EMAIL="niels.horn@gmail.com" +APPROVED="rworkman" diff --git a/network/nagios/slack-desc b/network/nagios/slack-desc new file mode 100644 index 0000000000..5632f5d8d5 --- /dev/null +++ b/network/nagios/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' on +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to +# leave one space after the ':'. + + |-----handy-ruler------------------------------------------------------| +nagios: Nagios (a powerful IT infrastructure monitoring system) +nagios: +nagios: Nagios is a powerful monitoring system for organizations to identify +nagios: and resolve IT infrastructure problems before they affect critical +nagios: business processes. +nagios: +nagios: http://www.nagios.org/ +nagios: +nagios: +nagios: +nagios: