Nouveau forum : https://forum.slackware-fr.eu.org/

Annonce

29/01/2017 : Ce forum est dsormais en lecture seule. Merci d'utiliser le nouveau forum.

13/12/2014 : Inscriptions dsactives pour un moment en raison d'une recrudescence d'inscriptions plus que douteuses.

#1 03-09-2009 20:42:31

serge
Site Admin
Lieu: Nice
Date d'inscription: 12-02-2004
Messages: 522
Site web

[SlackBuilds] Nagios & Nagios plugins

Nagios est un logiciel de monitoring (surveillance) de serveur et autres quipement informatique/rseau.
Il est trs largement utilis dans le monde de l'exploitation informatique, il est mme une rfrence en la matire.

Nagios-plugins est le jeu de "sonde" qui l'accompagne afin de raliser les tests de bases et lmentaires pour surveiller un quipement.

Note: il y a dj une trs large discussion sur le fait de devoir tre root pour ce SBs. J'y peux rien, j'y ai mis toute ma bonne volont mais il est impossible de ne pas tre root (test par une autre personne avec fakeroot : ca ne passe pas). Donc inutile de faire des remarques la dessus smile

Je n'ai pas joint le rc.nagios qui est a peux de chose prs celui qui est build dans les sources (juste renomm pour tre slackware compliant et 2/3 changement).

nagios.Slackbuild:

Code:

#!/bin/bash
# by: Tchesmeli Serge - http://www.slackware-fr.org < serge at slackware-fr dot org >
# Licence: Public Domain
#
# Latest Software sourcecode is available at:
# http://www.nagios.org/
#
 
NAMESRC=${NAMESRC:-nagios}
VERSION=${VERSION:-3.2.0}
EXT=${EXT:-tar.gz}
NAMETGZ=${NAMETGZ:-nagios}
BUILD=${BUILD:-1sfo}
 
TMP=${TMP:-/tmp}
OUT=${OUT:-$TMP/build}
ARCH=${ARCH:-i486}
TARGET=${TARGET:-$ARCH}
########################################

if [ ! "$(id -u)" = "0" ]; then
    echo "You MUST run this SlackBuild as ROOT !"
    echo "I'm sorry but it is nagios team fault, not mine! :)"
    exit
fi



set -e
umask 022
 
CWD=$(pwd)
PKG=$TMP/build/$NAMETGZ
NAME=$(tar ft $NAMESRC-$VERSION.$EXT | head -n 1 | awk -F/ '{ print $1 }')
 
case $ARCH in
  i386)SLKCFLAGS="-O2 -march=i386 -mtune=i686";;
  i486)SLKCFLAGS="-O2 -march=i486 -mtune=i686";;
  i586)SLKCFLAGS="-O2 -march=i586 -mtune=i686";;
  i686)SLKCFLAGS="-O2 -march=i686 -mtune=i686";;
  s390)SLKCFLAGS="-O2";;
  x86_64)SLKCFLAGS="-O2 -fPIC"
esac
 
if [ ! -d $TMP ]; then
  echo "$TMP doesn't exist or is not a directory !"
  exit 1
fi
# check if required user/groups are present"
if ! grep -qw nagios /etc/group || ! grep -qw nagioscmd /etc/group || ! grep -qw nagios /etc/passwd ; then
    echo " @@@@ WARNING @@@@ "
    echo "You MUST create user and groups for this Slackbuild: "
    echo "/usr/sbin/groupadd -g 213 nagios "
    echo "/usr/sbin/groupadd -g 214 nagioscmd " 
    echo "/usr/sbin/useradd -u 213 -g 213 -s /bin/false nagios "
    exit 1
fi


# Build the software
cd $TMP
echo "Building $NAMESRC-$VERSION.$EXT..."
tar zxvf $CWD/$NAMESRC-$VERSION.$EXT
cd $NAME
CFLAGS=$SLKCFLAGS \
CXXFLAGS=$SLKCFLAGS \
./configure \
  --prefix=/usr \
  --sysconfdir=/etc/nagios \
  --localstatedir=/var/nagios \
  --libexecdir=/usr/libexec/nagios \
  --datadir=/var/www/nagios/share \
  --sbindir=/var/www/nagios/cgi-bin \
  --mandir=/usr/man \
  --with-nagios-user=nagios \
  --with-nagios-group=nagios \
  --with-command-group=nagioscmd \
  --with-cgiurl=/nagios/cgi \
  --with-htmurl=/nagios \
  --with-httpd-conf=/etc/httpd \
  --build=$TARGET-slackware-linux
 
make all
make install DESTDIR=$PKG 
make install-commandmode DESTDIR=$PKG
make install-config DESTDIR=$PKG
make install-commandmode DESTDIR=$PKG
mkdir -p $PKG/etc/httpd
make install-webconf DESTDIR=$PKG

# We dont want to overwrite an actual config in case of pakage upgrade
# doinst.sh will supress .new suffix if files doesn't exists
CFGFILE="
etc/httpd/nagios.conf
etc/nagios/cgi.cfg
etc/nagios/nagios.cfg
etc/nagios/objects/commands.cfg
etc/nagios/objects/contacts.cfg
etc/nagios/objects/localhost.cfg
etc/nagios/objects/printer.cfg
etc/nagios/objects/switch.cfg
etc/nagios/objects/templates.cfg
etc/nagios/objects/timeperiods.cfg
etc/nagios/objects/windows.cfg
etc/nagios/resource.cfg"

for file in ${CFGFILE}; do
    mv ${PKG}/${file} ${PKG}/${file}.new 
done

# Install a slack-desc
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Install an init script
mkdir -p $PKG/etc/rc.d
cat $CWD/rc.nagios > $PKG/etc/rc.d/rc.nagios.new

# Install a doinst.sh, if it exists
if [ -r $CWD/doinst.sh ]; then
  cat $CWD/doinst.sh > $PKG/install/doinst.sh
fi
 
# Install the documentation
mkdir -p $PKG/usr/doc/$NAMETGZ-$VERSION
cp -a Changelog INSTALLING LEGAL LICENSE README THANKS UPGRADING html/docs $PKG/usr/doc/$NAMETGZ-$VERSION
 
# Compress the man pages
if [ -d $PKG/usr/man ]; then
  find $PKG/usr/man -type f -name "*.?" -exec gzip -9 {} \;
  for manpage in $(find $PKG/usr/man -type l) ; do
    ln -s $(readlink $manpage).gz $manpage.gz
    rm -f $manpage
  done
fi
 
# Compress the info pages
if [ -d $PKG/usr/info ]; then
  rm -f $PKG/usr/info/dir
  gzip -9 $PKG/usr/info/*.info*
fi
 
# Strip binaries, libraries and archives
find $PKG -type f | xargs file | grep "LSB executable" | cut -f 1 -d : | xargs \
  strip --strip-unneeded 2> /dev/null || echo "No binaries to strip"
find $PKG -type f | xargs file | grep "shared object" | cut -f 1 -d : | xargs \
  strip --strip-unneeded 2> /dev/null || echo "No shared objects to strip"
find $PKG -type f | xargs file | grep "current ar archive" | cut -f 1 -d : | \
  xargs strip -g 2> /dev/null || echo "No archives to strip"


# Build the package
cd $PKG
mkdir -p $OUT
PACKAGING="
chown root:root . -R
/sbin/makepkg -l y -c n $OUT/$NAMETGZ-$VERSION-$ARCH-$BUILD.tgz
rm -rf $PKG
rm -rf $TMP/$NAME
"
$PACKAGING

doinst.sh

Code:

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...
         }
CFGFILE="
/etc/httpd/nagios.conf.new
/etc/nagios/cgi.cfg.new
/etc/nagios/nagios.cfg.new
/etc/nagios/objects/commands.cfg.new
/etc/nagios/objects/contacts.cfg.new
/etc/nagios/objects/localhost.cfg.new
/etc/nagios/objects/printer.cfg.new
/etc/nagios/objects/switch.cfg.new
/etc/nagios/objects/templates.cfg.new
/etc/nagios/objects/timeperiods.cfg.new
/etc/nagios/objects/windows.cfg.new
/etc/nagios/resource.cfg.new
/etc/rc.d/rc.nagios.new"

for file in $CFGFILE; do
    config  $file
done

if ! grep -qw nagios /etc/group ; then
    echo "Adding group: nagios"
    /usr/sbin/groupadd -g 213 nagios
fi

if ! grep -qw nagioscmd /etc/group ; then
    echo "Adding group: nagioscmd"
    /usr/sbin/groupadd -g 214 nagioscmd
    echo "Adding apache user to nagioscmd group"
    /usr/sbin/usermod -G nagioscmd apache
fi

if ! grep -qw nagios /etc/passwd ; then
    echo "Adding user: nagios"
    /usr/sbin/useradd -u 213 -g 213 -s /bin/false nagios
fi

# Fix nagios:nagios right
FIX="
/etc/nagios/
/usr/bin/nagios
/usr/bin/nagiostats
/usr/libexec/nagios
/var/nagios
/var/www/nagios/cgi-bin
/var/www/nagios/share
"
for fix in $FIX; do
            chown nagios:nagios $fix -R
done

# Fix rw special dir
chown nagios:nagioscmd /var/nagios/rw
chmod 2775 /var/nagios/rw

nagios-plugins.Slackbuild:

Code:

#!/bin/bash
# by: Tchesmeli Serge - http://www.slackware-fr.org < serge at slackware-fr dot org >
# Licence: Public Domain
#
# Latest Software sourcecode is available at:
# http://www.nagios.org/
#


# Depends: ap/nagios

NAMESRC=${NAMESRC:-nagios-plugins}
VERSION=${VERSION:-1.4.13}
EXT=${EXT:-tar.gz}
NAMETGZ=${NAMETGZ:-nagios-plugins}
BUILD=${BUILD:-1sfo}
 
TMP=${TMP:-/tmp}
OUT=${OUT:-$TMP/build}
ARCH=${ARCH:-i486}
TARGET=${TARGET:-$ARCH}
########################################


if [ ! "$(id -u)" = "0" ]; then
        echo "You MUST run this SlackBuild as ROOT !"
        echo "I'm sorry but it is nagios team fault, not mine! :)"
        exit
fi


set -e
umask 022
 
CWD=$(pwd)
PKG=$TMP/build/$NAMETGZ
NAME=$(tar ft $NAMESRC-$VERSION.$EXT | head -n 1 | awk -F/ '{ print $1 }')
 
case $ARCH in
  i386)SLKCFLAGS="-O2 -march=i386 -mtune=i686";;
  i486)SLKCFLAGS="-O2 -march=i486 -mtune=i686";;
  i586)SLKCFLAGS="-O2 -march=i586 -mtune=i686";;
  i686)SLKCFLAGS="-O2 -march=i686 -mtune=i686";;
  s390)SLKCFLAGS="-O2";;
  x86_64)SLKCFLAGS="-O2 -fPIC"
esac
 
if [ ! -d $TMP ]; then
  echo "$TMP doesn't exist or is not a directory !"
  exit 1
fi


# check if required user/groups are present"
if ! grep -qw nagios /etc/group || ! grep -qw nagioscmd /etc/group || ! grep -qw nagios /etc/passwd ; then
        echo " @@@@ WARNING @@@@ "
        echo "You MUST create user and groups for this Slackbuild: "
        echo "/usr/sbin/groupadd -g 213 nagios "
        echo "/usr/sbin/groupadd -g 214 nagioscmd "
        echo "/usr/sbin/useradd -u 213 -g 213 -s /bin/false nagios "
        exit 1
fi

# Build the software
cd $TMP
echo "Building $NAMESRC-$VERSION.$EXT..."
tar zxvf $CWD/$NAMESRC-$VERSION.$EXT
cd $NAME
CFLAGS=$SLKCFLAGS \
CXXFLAGS=$SLKCFLAGS \
./configure \
  --prefix=/usr \
  --sysconfdir=/etc/nagios \
  --localstatedir=/var \
  --libexecdir=/usr/libexec/nagios \
  --datadir=/var/www/nagios/share \
  --sbindir=/var/www/nagios/cgi-bin \
  --mandir=/usr/man \
  --with-nagios-user=nagios \
  --with-nagios-group=nagios \
  --with-command-group=nagioscmd \
  --with-cgiurl=/nagios/cgi \
  --with-htmurl=/nagios \
  --with-httpd-conf=/etc/httpd \
  --build=$TARGET-slackware-linux

make all
make install DESTDIR=$PKG 


# Install a slack-desc
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Install a doinst.sh, if it exists
if [ -r $CWD/doinst.sh ]; then
  cat $CWD/doinst.sh > $PKG/install/doinst.sh
fi
 
# Install the documentation
mkdir -p $PKG/usr/doc/$NAMETGZ-$VERSION
cp -a ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING COPYING \
      ChangeLog FAQ INSTALL LEGAL NEWS README REQUIREMENTS \
      SUPPORT THANKS $PKG/usr/doc/$NAMETGZ-$VERSION
 
# Compress the man pages
if [ -d $PKG/usr/man ]; then
  find $PKG/usr/man -type f -name "*.?" -exec gzip -9 {} \;
  for manpage in $(find $PKG/usr/man -type l) ; do
    ln -s $(readlink $manpage).gz $manpage.gz
    rm -f $manpage
  done
fi
 
# Compress the info pages
if [ -d $PKG/usr/info ]; then
  rm -f $PKG/usr/info/dir
  gzip -9 $PKG/usr/info/*.info*
fi
 
# Strip binaries, libraries and archives
find $PKG -type f | xargs file | grep "LSB executable" | cut -f 1 -d : | xargs \
  strip --strip-unneeded 2> /dev/null || echo "No binaries to strip"
find $PKG -type f | xargs file | grep "shared object" | cut -f 1 -d : | xargs \
  strip --strip-unneeded 2> /dev/null || echo "No shared objects to strip"
find $PKG -type f | xargs file | grep "current ar archive" | cut -f 1 -d : | \
  xargs strip -g 2> /dev/null || echo "No archives to strip"


# Build the package
cd $PKG
mkdir -p $OUT
PACKAGING="
/sbin/makepkg -l y -c n $OUT/$NAMETGZ-$VERSION-$ARCH-$BUILD.tgz
rm -rf $PKG
rm -rf $TMP/$NAME
"
$PACKAGING

doinst.sh

Code:

# Fix some rights
chown nagios:nagios /usr/libexec/nagios/ -R

Who is General Failure and why is he reading my hard disk ?

Hors ligne

 

#2 30-08-2014 08:26:47

syed20
Nouveau membre
Date d'inscription: 30-08-2014
Messages: 2

Re: [SlackBuilds] Nagios & Nagios plugins

Il est trs largement utilis dans le monde de l'exploitation informatique, il est mme une rfrence en la matire.



___________
sultan

Hors ligne