Vous êtes sur la page 1sur 59

Serveur Supervision

Nagios/Centreon/Nagvis/Cacti/Nagtrap/Syslog
source1 : http://www.geekhelpme.fr/tutoriels/systemes/linux/27-installer-nagios-centreon-sous-ubuntu.html
source2 : http://blog.nicolargo.com/tag/centreon
plugin Nagios : http://exchange.nagios.org/directory/Plugins

I)Installation Nagios...........................................................................................................................................2
II)Installation Centreon......................................................................................................................................3
III) Mettre Centreon en francais.......................................................................................................................11
IV)Installation de statusmap pour centreon......................................................................................................12
V)Installation Nagvis.......................................................................................................................................12
VI)Installation Cacti.........................................................................................................................................14
IV)Intégration de cacti dans Nagios.................................................................................................................16
VII) Ajout de nouvelles MIBs..........................................................................................................................16
VIII) Client windows Nagios Event Log.........................................................................................................17
IX)Installation de wmic :..................................................................................................................................24
X)Utilisation de WMI check avec Nagios.......................................................................................................26
XI)Envoie de notification Nagios avec postfix par mail..................................................................................36
XII)Supervision serveur linux..........................................................................................................................38
XIII)Remonter les temperatures serveur linux.................................................................................................38
XIV)Activer le SNMP sur ESXi......................................................................................................................38
XV)Supervision espace disque serveur VMware ESXI...................................................................................39
XVI)Supervision du CPU/Mem/Network/VM serveur VMware ESXI...........................................................40
XVII)Supervision du materiel serveur VMware ESXI en python...................................................................41
XVIII)Supervision windows avec NSclient++................................................................................................42
XIX)Supervision onduleur...............................................................................................................................43
XX)Configuration automatique de Nagios par scan NMAP............................................................................44
XXI)Installation SNMPT.................................................................................................................................44
XXII)Installation Nagtrap................................................................................................................................46
XXIII)Purge de la base NDO (Peut rendre instable Nagios)...........................................................................49
XXIV)Configuration GPO Nagios...................................................................................................................50
XXV)Installation serveur syslog et module centreon-syslog...........................................................................52
XXVI)Installation agent snare (Envois événements au serveur syslog)..........................................................57
I)Installation Nagios
Mettre à jour l'existant :
//actualiser les sources depuis le site : https://dev.sourceslist.org/index/step1/
apt-get update
apt-get upgrade

Installation librairies de développement de bases : apt-get install build-essential

Installation serveur WEB : apt-get install apache2 wget rrdtool mailx librrds-perl libapache2-mod-
php5 php5 php-pear php5-gd php5-ldap php5-snmp libperl-dev

Installation librairies pour Nagios : apt-get install bind9-host dnsutils libbind9-60 libdns66 libisc60
libisccc60 libisccfg60 liblwres60 libradius1 qstat radiusclient1 snmp snmpd

Installation librairies de diagrammes réseau pour Nagios : apt-get install libgd2-noxpm-dev


libpng12-dev libjpeg62 libjpeg62-dev

Création utilisateur de supervision :


/usr/sbin/useradd nagios
passwd nagios
/usr/sbin/groupadd nagios
/usr/sbin/usermod -G nagios nagios
/usr/sbin/usermod -G nagios www-data
Telechargerment des plugins :
cd /usr/src
wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
Decompression des sources :
tar xzf nagios-3.3.1.tar.gz
cd nagios
Compilation :
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios
--with-command-group=nagios --enable-event-broker --enable-nanosleep --enable-embedded-perl
--with-perlcache
//Il risque d'y avoir des alertes ("warning"), il ne faut par d'erreurs... ("error").
make all
make fullinstall
make install-config
//En cas d'erreur :
nano -c /usr/src/nagios/Makefile

-Ligne 78
A la place de « for file in includes/rss/*; \ » mettre « for file in includes/rss/*.*; \ »
-Ligne 80
A la place de « for file in includes/rss/extlib/*; \ »
mettre « for file in includes/rss/extlib/*.*; \

Script de démarrage nagios :


ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Installation interface Web :


htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/etc/init.d/apache2 reload
Compilation des plugins Nagios :
apt-get install fping libnet-snmp-perl libldap-dev libmysqlclient-dev libgnutls-dev libradiusclient-ng-
dev

cd /usr/src
tar xzf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
Test fichiers de conf Nagios :
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Demarrage Nagios :
nano /etc/passwd //nagios:x:1002:1002::/usr/local/nagios:/bin/sh
/etc/init.d/nagios start
Acces a Nagios :
http://<adresseIPserveur>/nagios/

II)Installation Centreon
Installation de mysql :
apt-get install mysql-server php-db php-date php5-gd php5-mysql php5-snmp php5-ldap php5-
xmlrpc
Installation de librairie de perl :
cpan

install Config::IniFiles

Installation de la base de donnée NDO :


mysqladmin -u root -p create ndo
mysql -u root -p mysql
GRANT ALL ON ndo.* TO "nagios" IDENTIFIED BY "motDePasseNDO";
FLUSH PRIVILEGES;
exit
Installation du plugin NDO :
cd /usr/src
wget http://dfn.dl.sourceforge.net/sourceforge/nagios/ndoutils-1.4b9.tar.gz
tar zxvf ndoutils-1.4b9.tar.gz

cd ndoutils-1.4b9

./configure --disable-pgsql --with-mysql-lib=/usr/lib/mysql --with-ndo2db-user=nagios --with-


ndo2db-group=nagios
make
cp src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
cp src/ndo2db-3x /usr/local/nagios/bin/ndo2db
nano /usr/local/nagios/etc/nagios.cfg

//contenu sur une seule ligne et pas en deux lignes


broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
//fincontenu
cp config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg

nano /usr/local/nagios/etc/ndomod.cfg

//contenu
//////////instance_name=Central
//fincontenu
cp config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg

chmod 774 /usr/local/nagios/bin/ndo*

chown nagios:nagios /usr/local/nagios/bin/*

chown nagios:nagios /usr/local/nagios/etc/ndo*

Automatiser le lancement de NDO au démarrage :

nano /etc/init.d/ndo2db
//contenu
#!/bin/sh
#
#
# chkconfig: 345 99 01
# description: Nagios to mysql
#
# Author : Gaëtan Lucas
# Realase : 07/02/08
# Version : 0.1 b
# File : ndo2db
# Description: Starts and stops the Ndo2db daemon
# used to provide network services status in a database.
#
status_ndo ()
{
if ps -p $NdoPID > /dev/null 2>&1; then
return 0
else
return 1
fi

return 1
}
printstatus_ndo()
{
if status_ndo $1 $2; then
echo "ndo (pid $NdoPID) is running..."
else
echo "ndo is not running"
fi
}
killproc_ndo ()
{
echo "kill $2 $NdoPID"
kill $2 $NdoPID
}
pid_ndo ()
{
if test ! -f $NdoRunFile; then
echo "No lock file found in $NdoRunFile"
echo -n " checking runing process..."
NdoPID=`ps h -C ndo2db -o pid`
if [ -z "$NdoPID" ]; then
echo " No ndo2db process found"
exit 1
else
echo " found process pid: $NdoPID"
echo -n " reinit $NdoRunFile ..."
touch $NdoRunFile
chown $NdoUser:$NdoGroup $NdoRunFile
echo "$NdoPID" > $NdoRunFile
echo " done"
fi
fi
NdoPID=`head $NdoRunFile`
}
# Source function library
# Solaris doesn't have an rc.d directory, so do a test first
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi

prefix=/usr/local/nagios
exec_prefix=${prefix}
NdoBin=${exec_prefix}/bin/ndo2db
NdoCfgFile=${prefix}/etc/ndo2db.cfg
NdoRunFile=${prefix}/var/ndo2db.run
NdoLockDir=/var/lock/subsys
NdoLockFile=ndo2db.lock
NdoUser=nagios
NdoGroup=nagios
# Check that ndo exists.
if [ ! -f $NdoBin ]; then
echo "Executable file $NdoBin not found. Exiting."
exit 1
fi
# Check that ndo.cfg exists.
if [ ! -f $NdoCfgFile ]; then
echo "Configuration file $NdoCfgFile not found. Exiting."
exit 1
fi
# See how we were called.
case "$1" in
start)
echo -n "Starting ndo:"
touch $NdoRunFile
chown $NdoUser:$NdoGroup $NdoRunFile
$NdoBin -c $NdoCfgFile
if [ -d $NdoLockDir ]; then
touch $NdoLockDir/$NdoLockFile;
fi
ps h -C ndo2db -o pid > $NdoRunFile
if [ $? -eq 0 ]; then
echo " done."
exit 0
else
echo " failed."
$0 stop
exit 1
fi
;;
stop)
echo -n "Stopping ndo: "
pid_ndo
killproc_ndo
# now we have to wait for ndo to exit and remove its
# own NdoRunFile, otherwise a following "start" could
# happen, and then the exiting ndo will remove the
# new NdoRunFile, allowing multiple ndo daemons
# to (sooner or later) run
#echo -n 'Waiting for ndo to exit .'
for i in 1 2 3 4 5 6 7 8 9 10 ; do
if status_ndo > /dev/null; then
echo -n '.'
sleep 1
else
break
fi
done
if status_ndo > /dev/null; then
echo
echo 'Warning - ndo did not exit in a timely manner'
else
echo 'done.'
fi

rm -f $NdoRunFile $NdoLockDir/$NdoLockFile
;;
status)
pid_ndo
printstatus_ndo ndo
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: ndo {start|stop|restart|status}"
exit 1
;;
esac
# End of this script
//fincontenu

chown root:root /etc/init.d/ndo2db


chmod 755 /etc/init.d/ndo2db
update-rc.d ndo2db defaults
Lancement de NDO : /etc/init.d/ndo2db start

Relancement de NDO : /etc/init.d/nagios restart

Installation de centreon :

cd /usr/src

wget http://download.centreon.com/index.php?id=158

tar zxvf index.php?id=158

cd /usr/src/centreon-2.2.2

./install.sh -i //A valider : default to [/usr/sbin/ndomod.o]> /usr/local/nagios/bin/ndomod.o

Acces a centreon :
http://<adresseIPserveur>/nagios/
Exportation d’une configuration Centreon vers Nagios : chmod -R 774 /usr/local/nagios/etc
//Cette action est a répéter a chaque fois que vous souhaitez ajouter une configuration
depuis Centreon vers Nagios.

//Aller sur Configuration -> Nagios -> Nagios.cfg puis cliquer sur "Nagios CFG 1"
Ensuite vérifier sous l’onglet Données, les champs "Commande de lancement du module",
"Option de lancement du module" et "Fichier de données de performance de service"
doivent etre configurer comme suis :
Commande de lancement du module :
/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
Option de lancement du module : -1
Fichier de données de performance de service : /usr/local/nagios/var/service-perfdata
Puis cliquer sur "Sauvegarder".

Ensuite sous Configuration -> Centreon -> ndo2db.cfg


Mettre dans "Nom de la socket" : /usr/local/nagios/var/ndo.sock

Puis sous Configuration -> Centreon -> ndomod.cfg


Compléter comme suis :
Type d’interface : unixsocket
Status détailler : /usr/local/nagios/var/ndo.sock
Fichier tampon : /usr/local/nagios/var/ndomod.tmp
Puis sauvegarder (en haut a droite)
service nagios start
service ndo2db start

Configuration -> Nagios -> Cochez toute les options présentes puis exporter.

tail -f /usr/local/nagios/var/nagios.log | grep ndomod

Vous devriez avoir ceci:


[1261436831] ndomod: NDOMOD 1.4b9 (10-27-2009) Copyright (c) 2009 Nagios Core
Development Team and Community Contributors
[1261436831] ndomod: Successfully connected to data sink. 0 queued items to flush.
[1261436831] Event broker module '/usr/local/nagios/bin/ndomod.o' initialized successfully.

Aller sur Configuration -> Nagios -> cgi ->Editer CGI.cfg


Remplacer dans "Méthode d'affichage par défaut de la carte des états" en" Circular (Marked Up)".
Puis sauvegarder.

Aller ensuite dans Configuration -> Nagios -> Ressources, puis éditer $USER2$ avec le nom
de la communauté que vous avez paramétré sur vos hôtes.

Configurer ensuite Centstorage :


Sous : Administration -> Options -> Centstorage ->Editer comme le screenshot

Puis aller sous Configuration -> Nagios ->Cocher toutes les options, puis exporter.
Configuration SNMP sur le serveur :
nano /etc/snmp/snmpd.conf
//début fichier
rocommunity votrecommunaute
com2sec readonly default votrecommunaute
//fin fichier
service snmpd restart
nano /etc/init.d/snmpd
//début fichier
TRAPDRUN=yes
TRAPDOPTS='-On -LF d /usr/local/nagios/var/snmptrap.log -c /etc/snmp/snmptrapd.conf -p
/var/run/snmpdtrapd.pid'
//fin fichier

nano /etc/default/snmpd
//début fichier
TRAPDRUN=yes
TRAPDOPTS='-On -LF d /usr/local/nagios/var/snmptrap.log -c /etc/snmp/snmptrapd.conf -p
/var/run/snmpdtrapd.pid'
//fin fichier
service snmpd restart
Test centreon :

cd /usr/local/nagios/libexec
./check_centreon_snmp_memory -H 127.0.0.1 -C nomCommunaute -v 1 -w 80 -c 90
//Et vous devriez avoir un retour du genre :
total memory used : 11% ram used : 37%, swap used 0% | used=189804544o
size=1643266048o

III) Mettre Centreon en francais


mkdir /usr/local/centreon/www/locale/fr_FR.UTF-8/
mkdir /usr/local/centreon/www/locale/fr_FR.UTF-8/LC_MESSAGES/
cd /tmp
wget http://download.centreon.com/index.php?id=127
tar xvzf index.php?id=127
cd centreon-2.1-fr_FR-1.1/LC_MESSAGES
cp messages.mo /usr/local/centreon/www/locale/fr_FR.UTF-8/LC_MESSAGES/messages.mo
service apache2 restart
//Dans Configuration -> Users , sélectionner votre utilisateur et vérifier que vous pouvez
sélectionner fr_FR.UTF-8.
IV)Installation de statusmap pour centreon
cd /tmp
wget http://download.centreon.com/index.php?id=60
tar -xvzf index.php?id=60
cp -r statusmap/ /usr/local/centreon/www/modules/

mkdir /usr/local/centreon/www/modules/UPGRADE
mv statusmap-1.1 /usr/local/centreon/www/modules/UPGRADE
chown -R www-data :www-data /usr/local/centreon/www/modules/statusmap

V)Installation Nagvis
apt-get install graphviz sqlite php5-sqlite
service apache2 restart
cd /tmp
wget http://sourceforge.net/projects/nagvis/files/NagVis%201.5/nagvis-
1.5.10.tar.gz/download
tar zxvf download
mv nagvis-1.5.10 /usr/local/nagvis
cd /usr/local/nagvis
./install.sh
//Do you want to use backend mklivestatus? [y]: n
Do you want to use backend ndo2db? [n]: y
Do you want to use backend ido2db? [n]: n
Do you want to use backend merlinmy? [n]: n
service apache2 restart
nano /usr/local/nagvis/etc/nagvis.ini.php
//début fichier
ndo2db
dbhost="localhost"
dbport=5668
dbname="ndo"
dbuser="nagios"
dbpass=”ndopassword”
dbprefix="nagios_"
dbinstancename="Central"
//fin fichier
Acces à nagvis : http://<adresseIPserveur>/nagvis/config.php

Ajout de pack d'icones :

cd /usr/src/

wget http://switch.dl.sourceforge.net/sourceforge/nagvis/NagVis-Iconset-Lemon-02.tar.gz

tar zxvf NagVis-Iconset-Lemon-02.tar.gz

cd /usr/src/lemon/nagvis/nagvis/images/iconsets

cp * /usr/local/nagvis/share/userfiles/images/iconsets/

chown -R www-data:www-data /usr/local/nagvis/share/userfiles/images/iconsets/

Ajout de pack de formes :

cd /usr/src/

wget http://switch.dl.sourceforge.net/sourceforge/nagvis/NagVis-Shapes-Server-Dropline.tar.gz

tar zxvf NagVis-Shapes-Server-Dropline.tar.gz

cd shapes_dropline

cp * /usr/local/nagvis/share/userfiles/images/shapes/

chown -R www-data:www-data /usr/local/nagvis/share/userfiles/images/shapes/

Ajout de pack de templates :


cd /usr/src/

wget http://dfn.dl.sourceforge.net/sourceforge/nagvis/NagVis-Template-Darkglass-0.4.tar.gz

tar zxvf NagVis-Template-Darkglass-0.4.tar.gz

cp -r nagvis /usr/local/nagvis/share/userfiles/

chown -R www-data:www-data /usr/local/nagvis/share/userfiles/

Création d'une nouvelle carte :

nano /usr/local/nagvis/etc/maps/nomDeLaCarte.cfg

chown -R www-data:www-data /usr/local/nagvis/etc/maps/

//doc pour les carte : http://docs.nagvis.org/1.5/en_US/index.html

VI)Installation Cacti
Installation cacti : apt-get install cacti-cactid

service apache2 restart

Fichier de conf de cacti : /etc/cacti/debian.php

Acces à cacti : http://<adresseIPserveur>/cacti/

//mot de passe par défault : admin


http://www.nicolargo.com/dev/cactiplug/cactiplug-0.2.tgz

Configuration global :

nano /usr/local/nagvis/etc/nagvis.ini.php

//Début fichier

refreshtime=1
interval=1
updateobjectstates=10
sesscookieduration="1000000000000000000"
dateformat="d-m-Y H:i:s"
[rotation_nomRotation]
rotationid="nomRotation"
maps="labelMap:nomMap,labelMap2:nomMap2"
interval=tempsRotationSeconde
//Fin fichier
IV)Intégration de cacti dans Nagios
cd /tmp
wget http://www.nicolargo.com/dev/cactiplug/cactiplug-0.2.tgz
tar zxvf cactiplug-0.2.tgz
mv cactiplug /usr/local/nagios/share
chown -R nagios:nagios /usr/local/nagios/share/cactiplug
//Action URL: /nagios/cactiplug/cactiplug.php?ip=$HOSTADDRESS

nano /usr/local/nagios/share/cactiplug/cactiplug.php

//Début fichier

$cactiurl="http://adresseIPserveurNagios/cacti";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "root";
$database_password = "motDePasseBDDcacti";
//Fin fichier
Redémarrage de Nagios : /etc/init.d/nagios restart

VII) Ajout de nouvelles MIBs


apt-get install snmp-mibs-downloader
nano /etc/snmp/snmp.conf
//début fichier
mibdirs +/usr/share/snmp/mibs/
//fin fichier
//Placer les mibs voulu dans le répertoire
service snmp restart

Exemple d'OID pour du materiel Netasq :


http://www.oidview.com/mibs/detail.html
CPU / User : .1.3.6.1.4.1.2021.11.50.0
CPU / Nice : .1.3.6.1.4.1.2021.11.51.0
CPU / System : .1.3.6.1.4.1.2021.11.52.0
Load / 1 min : .1.3.6.1.4.1.2021.10.1.3.1
Load / 5 min : .1.3.6.1.4.1.2021.10.1.3.2
Load / 15 min : .1.3.6.1.4.1.2021.10.1.3.3
Memory / Buffers : .1.3.6.1.4.1.2021.4.14.0
Memory / Cache : .1.3.6.1.4.1.2021.4.15.0
Memory / Free : .1.3.6.1.4.1.2021.4.6.0
Network / All : .1.3.6.1.2.1.31.1.1.1
Nombre de port : .1.3.6.1.4.1.11256.1.0.6.0
Nom du routeur : .1.3.6.1.4.1.11256.1.0.4.0
commande SNMP v3 :
snmpget -v 3 -u nomUtilisateur -l authNoPriv -A motDePasse -a SHA/md5 -c nomComunity
adresseIP OID

VIII) Client windows Nagios Event Log


Telechargement : http://www.steveshipway.org/software/f_nagios.html
Comment configurer cet agent :
----------------------------
L'outil de configuration d'Agent EventLog a été installé. Vous pouvez l'exécuter et il vous pourrez
définir les paramètres du serveur Nagios NSCA et les filtres.
Vous pouvez définir n'importe quel nombre de filtres, mais en vérifiant une entrée de journal
particulière, SEULEMENT LE PREMIER SERA UTILISÉ. Ainsi, assurez-vous que leur ordres
d'execution est correctement configuré.
Chaque définition de Filtre devrait donner le Service_Description du service que vous voulez
alerter (OK, Warning, critial, Unknown ou ignore). Le host_name est configuré dans la section
avec les définitions de serveur Nagios NSCA.

Les deux mode de déboguage flags dans les définitions de Serveur peut produire beaucoup de
messages eventlog, mais sont utile pour découvrir pourquoi un journal particulier n'est pas
expédié (ou si filtre fonctionne bien). Dans l'opération normale, assurez que les deux flags sont
sur off.
Installation de NCA coté serveur :
apt-get install libmcrypt4 snmp
cd /tmp
wget http://freefr.dl.sourceforge.net/sourceforge/nagios/nsca-2.7.2.tar.gz
tar zxvf nsca-2.7.2.tar.gz
cd nsca-2.7.2/
./configure --prefix=/usr/local/nagios/ --with-trusted-
path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/nagios/bin:/usr/local/nagios/libexec
cp src/nsca /usr/local/nagios/bin/
cp sample-config/nsca.cfg /usr/local/nagios/etc/
nano /usr/local/nagios/etc/nsca.cfg
//début fichier
password=monPassword
//LA METHODE DE CRYPTAGE :1=pas de cryptage, 2=DES, 3=3DES
decryption_method=0
//fin fichier
Création script de démarage du service :
nano /etc/init.d/nsca
//début fichier

#!/bin/sh

# simple debian init script for nsca


# by sean finney <seanius@debian.org>

DAEMON=/usr/local/nagios/bin/nsca
NAME=nsca
DESC="Nagios Service Check Acceptor"
CONF= /usr/local/nagios/etc/nsca.cfg
OPTS="--daemon -c $CONF"
PIDFILE="/var/run/nsca.pid"

###

# obviously if the daemon doesn't exist we should stop now


if [ ! -x $DAEMON ]; then
exit 0
fi

# grab an arbitrary config setting from nsca.cfg


get_config(){
grep "^[[:space:]]*$1=" $CONF 2>/dev/null | tail | cut -d= -f2-
}

# if the pid_file is specified in the configuration file, nsca will


# take care of the pid handling for us. if it isn't we should continue
# as we have before
PIDFILE=`get_config pid_file`
# if pidfile isn't set
if [ -z "$PIDFILE" ]; then
# then this is the default PIDFILE
PIDFILE="/var/run/nsca.pid"
# run nsca in the foreground, and have s-s-d fork it for us
OPTS="-f $OPTS"
# and then this is how we call SSD
SSD_STARTOPTS="--background --pidfile $PIDFILE --make-pidfile"
SSD_STOPOPTS="--pidfile $PIDFILE"
else
# but if pid_file is set, we don't have to do anything
SSD_STARTOPTS="--pidfile $PIDFILE"
SSD_STOPOPTS="--pidfile $PIDFILE"
fi
SSD_START="/sbin/start-stop-daemon -S $SSD_STARTOPTS --exec $DAEMON"
SSD_STOP="/sbin/start-stop-daemon -K $SSD_STOPOPTS --exec $DAEMON"

die(){
echo $@
exit 1
}

case "$1" in
start)
echo -n "Starting $DESC: "
if [ ! -d "/var/run/nagios" ]; then
mkdir -p /var/run/nagios || die "ERROR: couldn't create /var/run/nagios"
fi
$SSD_START -- $OPTS || die "ERROR: could not start $NAME."
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
$SSD_STOP -- $OPTS || die "ERROR: could not stop $NAME."
rm -f $PIDFILE
echo "$NAME."
;;
reload|force-reload)
echo -n "Reloading $DESC: "
$SSD_STOP --signal HUP -- $OPTS || die "ERROR: could not reload $NAME."
echo "$NAME."
;;
restart)
$0 stop
$0 start
;;
esac

//fin fichier

chmod +x /etc/init.d/nsca

update-rc.d nsca defaults

service nsca start

Comment connecter cet agent à Nagios :


------------------------------------
1) NagiosEventLog utilise NSCA pour envoyer des alertes passives. Donc, vous devez avoir
NSCA installé et en cours d'exécution sur votre serveur Nagios. Vous devez aussi configurer des
Services Passifs dans Nagios pour toutes alertes que vous voulez faire suivre.
2) Bien que filtre par défaut configurer consiste en un filtre par journal d'événement et chaque filtre
envoie une alerte à un service de Nagios différent, vous ne devez pas le faire cette façon. Vous
pouvez avoir plusieurs filtres envoyant au même service, ou plusieurs filtres sur chaque eventlog
ou un filtre sur tout l'eventlogs, ou autre chose vous voulez avoir.
3) Voici un exemple de la façon de définir les services dans les fichiers de configuration Nagios.
Notez que des contrôles(active check) actifs sont mis hors de service et le contrôle ( freshness
check) de rafraichissemnt est utilisé pour 'reset' après configurer une période de temps :
nano /usr/local/nagios/etc/serviceTemplates.cfg
//début fichier
define service{
service_description EventLog
active_checks_enabled 0
passive_checks_enabled 1
flap_detection_enabled 0
register 0
is_volatile 0
check_period 24x7
max_check_attempts 1
normal_check_interval 5
retry_check_interval 1
check_freshness 1
freshness_threshold 1800
check_command check_dummy!0!No messages in last 30mins
contact_groups YOUR_CONTACT_GROUP
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
stalking_options w,c,u
name EventLog
register 0
}
//fin fichier
sous centreon faire un nouveau modèles de service :
nano /usr/local/nagios/etc/services.cfg
//début fichier
define service{
use EventLog
service_description Application EventLog
host_name YOUR_HOSTNAME
}
define service{
use EventLog
service_description System EventLog
host_name YOUR_HOSTNAME
}
define service{
use EventLog
service_description Security EventLog
host_name YOUR_HOSTNAME
}
//fin fichier
4) Vous devez configurer le check_command 'check_dummy' : Ceci devrait appeler un script qui
remet le statut à OK.
nano /usr/local/nagios/etc/checkcommands.cfg
//début fichier
define command {
command_name check_dummy
command_line $USER1$/check_dummy $ARG1$ "$ARG2$"
}
//fin fichier
Test config nagios : /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Le check_dummy plugindevrait déjà être fournit avec le Nagios plugins.
Fonction de Battement de coeur (Heartbeat) :
------------------
Vous pouvez dire à l'agent d'envoyer une alerte périodique au serveur Nagios, confirmer qu'il
fonctionne toujours . Définissez le service de cette façon :
define service{
service_description EventLog Agent
active_checks_enabled 0
passive_checks_enabled 1
flap_detection_enabled 0
check_period 24x7
max_check_attempts 1
normal_check_interval 15
retry_check_interval 1
check_command check_dummy!3!Check agent is running
contact_groups YOUR_CONTACT_GROUP
notification_interval 120
notification_period 24x7
notification_options c,r
}
sous centreon faire un nouveau modèles de service :

Si vous
changez l'option de battement de coeur par défaut dans l'agent, vous devrez donner
un service_description différent.
Problèmes :
--------
Si vous n'obtenez pas d'alertes, vérifiez la chose suivante :
1) Assurer que le hostname défini dans Nagios correspond EXACTEMENT au hostname défini
dans l'agent, y compris les majuscules/minuscules et les espaces.
2) Assurer que la description de service utilisée dans l'agent correspond EXACTEMENT à la
description de service de Nagios, y compris les majuscules/minuscules et les espaces.
3) Vérifier le journal de NSCA (syslog) pour s'assurer que les messages sont reçus par NSCA.
4) Vérifier le fichier de nagios.log pour vous assurer qu'ils sont traités par Nagios. Avez-vous
permis le fichier de commande externe dans le nagios.cfg (the external command file) ?
5) Vérifier le fichier de nagios.log. Les messages NSCA sont-ils ignorés parce que vous avez faux
hostname ou entretenez la description ?
6) Envoyer un test NSCA le message de l'agent. A-t-il marché ? Peut-être il y a un pare-feu ou un
chiffrage causant le problème.

IX)Installation de wmic :
Installation :
apt-get install build-essential
apt-get install autoconf
cd /tmp
wget http://dev.zenoss.org/svn/trunk/inst/externallibs/wmi-1.3.13.tar.bz2
bunzip2 wmi-1.3.13.tar.bz2
tar xf wmi-1.3.13.tar
cd wmi-1.3.13/Samba/source
./autogen.sh
./configure
make proto bin/wmic
cp bin/wmic /bin
Test :
wmic -h
Syntaxe :
wmic -U nomDomaine/utilisateurAdmin%motDePasse //$HOSTADDRESS$ "requeteSQLWMI"
Personne Loggé :
Select UserName from Win32_ComputerSystem
wmic -U nomDomaine/utilisateurAdmin%motDePasse //$HOSTADDRESS$ "Select UserName
from Win32_ComputerSystem" |grep nomDomaine|sed 's/|/:/'
Etat des services Windows (Running / Stopped) :
SELECT State FROM Win32_Service
Mémoire disponible :
SELECT AvailableBytes FROM Win32_PerfRawData_PerfOS_Memory
Mémoire physique du serveur
SELECT Capacity FROM Win32_PhysicalMemory
Espace disque disponible sur tous les disques (media type = 12 pour ne sélectionner que les
partitions provenant de disques dur) :
SELECT FreeSpace, Size FROM Win32_LogicalDisk WHERE MediaType = '12'

Charge en pourcentage de chaque processeur :


SELECT LoadPercentage FROM Win32_Processor
Mémoire utilisé par un processus donné :
SELECT WorkingSet FROM Win32_PerfRawData_PerfProc_Process where Name = 'sqlservr'
//Les services en auto tournent bien?
SELECT Name,State,StartMode FROM Win32_Service WHERE StartMode="Auto"
Attention à SysmonLog, il faut le passer en manuel (automatique arrété de base...)
I/O des disques :
SELECT Name,DiskReadsPersec,DiskReadBytesPersec,DiskWrite
sPersec,DiskWriteBytesPersec FROM Win32_PerfFormattedData_PerfDisk_PhysicalDisk
Attention, pas windows 2k.
Queue d'attente des disques :
SELECT Name,CurrentDiskQueueLength FROM
Win32_PerfFormattedData_PerfDisk_PhysicalDisk
Si supérieur à 2, pas bon.
% de bande passante utilisé :
SELECT Name,BytesTotalPersec,CurrentBandwidth FROM
Win32_PerfFormattedData_Tcpip_NetworkInterface
Queue du réseau :
SELECT Name,OutputQueueLength FROM Win32_PerfFormattedData_Tcpip_NetworkInterface
>2? pas bon
Type d'utilisation du CPU :
SELECT PercentInterruptTime,PercentDPCTime,PercentPrivile gedTime
Win32_PerfFormattedData_PerfOS_Processor WHERE Name='_Total'
*PercentInterruptTime > 50%? trop d'I/O réseaux
*PercentPrivilegedTime > 20%? trop d'I/O disque!
Utilisation du swap :
SELECT AllocatedBaseSize,CurrentUsage FROM Win32_PageFileUsage
Pas bon le swap (si la ram est également utilisée, sinon ce n'est pas grave!)
Détection d'un reboot :
SELECT SystemUpTime FROM Win32_PerfFormattedData_PerfOS_System
<3600= reboot dans l'heure passée
Data de création d'un fichier :
SELECT LastModified FROM CIM_Datafile WHERE name="C:\myfile.txt"
On peut aussi requêter pour avoir des informations sur des logiciels installés, comme par exemple
SQL Server (MSSQL) :
Mémoire utilisé par SQL Server :
SELECT TotalServerMemoryKB FROM
Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager
Buffer cache hit ratio :
SELECT Buffercachehitratio FROM
Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager
Taille d'une base de données (fichier et log) donnée :
SELECT DataFilesSizeKB, LogFilesSizeKB, LogFilesUsedSizeKB FROM
Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases WHERE Name = 'test'
nano /usr/local/nagios/etc/nagios.cfg
//début fichier
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
//fin fichier

X)Utilisation de WMI check avec Nagios


http://australiantechblog.blogspot.com/2011/06/part-1-monitoring-windows-servers.html

cd /tmp
wget http://edcint.co.nz/checkwmiplus/sites/default/files/check_wmi_plus.v1.48.tar.gz
tar xzf check_wmi_plus.v1.48.tar.gz
mv * /usr/local/nagios/libexec
/usr/local/nagios/etc/nagios/check_wmi.conf
cd /usr/local/nagios/etc/nagios/
cp ./check_wmi_plus.conf.sample /usr/local/nagios/etc/check_wmi.conf
nano check_wmi_plus.pl
//début fichier
my $conf_file='/usr/local/nagios/etc/check_wmi.conf';
use lib "/usr/local/nagios/libexec";
//fin fichier
nano check_wmi_plus.pl
//début fichier
use lib "/usr/local/nagios/libexec";
$wmi_ini_file='/usr/local/nagios/libexec/check_wmi_plus.d/check_wmi_plus.ini';
$wmi_ini_dir="/usr/local/nagios/libexec/check_wmi_plus.d";
//fin fichier
lien : http://www.edcint.co.nz/checkwmiplus/?q=node/36

Commande de check nagios :


# ------------------------- windows checks by check_wmi_plus ------------------------------
define command{
command_name check_wmi_plus
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m $ARG1$ -u $USER8$ -p
$USER9$ -s $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$ $ARG9$
}
define command{
command_name check_win_io
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkio -u $USER8$ -p
$USER9$ -s $ARG1$ -a "$ARG2$" $ARG3$ $ARG4$
}
define command{
command_name check_win_filesize
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkfilesize -u $USER8$
-p $USER9$ -a $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_fileage
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkfileage -u $USER8$
-p $USER9$ -a '$ARG1$' -w $ARG2$ -c $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_disk
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkdrivesize -u
$USER8$ -p $USER9$ -a $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_volume
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkvolsize -u $USER8$
-p $USER9$ -a $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_cpuq
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkcpuq -u $USER8$
-p $USER9$ -w $ARG1$ -c $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_cpu
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkcpu -u $USER8$ -p
$USER9$ -w $ARG1$ -c $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_cpudetail
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkeachcpu -u
$USER8$ -p $USER9$ -w $ARG1$ -c $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_network
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checknetwork -u
$USER8$ -p $USER9$ -a '$ARG1$' $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_service
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkservice -u $USER8$
-p $USER9$ -a '$ARG1$' -o '$ARG2$' $ARG3$ $ARG4$ $ARG5$
}

define command{
command_name check_win_uptime
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkuptime -u $USER8$
-p $USER9$ -w $ARG1$ -c $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_mem
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkmem -u $USER8$
-p $USER9$ -w $ARG1$ -c $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_page
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkpage -u $USER8$
-p $USER9$ $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_process
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkprocess -u
$USER8$ -p $USER9$ -a "$ARG1$" -3 '$ARG2$' -w "$ARG3$" -c $ARG4$ $ARG5$ $ARG6$
}
define command{
command_name check_win_eventlog
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkeventlog -u
$USER8$ -p $USER9$ -a $ARG1$ -o $ARG2$ -3 $ARG3$ -w $ARG4$ -c $ARG5$ $ARG6$
$ARG7$
}
define command{
command_name check_ts
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkts -u $USER8$ -p
$USER9$ -s $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_iis
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkiis -u $USER8$ -p
$USER9$ -s $ARG1$ -a $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_exchange
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkexchange -u
$USER8$ -p $USER9$ -s $ARG1$ -a $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_sql
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checksql -u $USER8$ -p
$USER9$ -s $ARG1$ -a $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_sql_express
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checksqlex -u $USER8$
-p $USER9$ -s $ARG1$ -a $ARG2$ $ARG3$ $ARG4$ $ARG5$
}
define command{
command_name check_win_proc
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkproc -s $ARG1$ -u
$USER8$ -p $USER9$ -a $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
define command{
command_name check_win_dns
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkdns -s $ARG1$ -u
$USER8$ -p $USER9$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
define command{
command_name check_win_dhcp
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkdhcp -s $ARG1$ -u
$USER8$ -p $USER9$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
define command{
command_name check_win_dhcpv6
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkdhcpv6 -s $ARG1$
-u $USER8$ -p $USER9$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
define command{
command_name check_win_print
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkprint -s $ARG1$ -u
$USER8$ -p $USER9$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
define command{
command_name check_win_users
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkusers -s $ARG1$ -u
$USER8$ -p $USER9$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
define command{
command_name check_win_power
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkpower -s $ARG1$
-u $USER8$ -p $USER9$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
define command{
command_name check_ad
command_line $USER6$/check_wmi_plus.pl -H $HOSTADDRESS$ -m checkad -s $ARG1$ -u
$USER8$ -p $USER9$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
Services :
#--------------- SERVICE TEMPLATES -------------------
define service {
use windows_service
service_description PING
check_command check_ping!100.0,20%!200.0,60%
}
# --------------------- services using WMI directly
define service {
use windows_service
service_description Process - Quote Tracker
check_command check_win_process!stocks.exe!!1:1!1:1
}
define service {
use windows_service
service_description Process - svchost
check_command check_win_process!svchost.exe!!1:10!1:20
}
define service {
use windows_service
service_description IO C:
check_command check_win_io!logical!C:
}
define service {
use windows_service
service_description Disk Space - All
check_command check_win_disk!.!80!90!-o 1 -3 1
}
define service {
use windows_service
service_description Event Log Application Warnings
check_command check_win_eventlog!application!2!1!50!100
}
define service {
use windows_service
service_description Event Log System Warnings
check_command check_win_eventlog!system!2!1!50!100
}
define service {
use windows_service
service_description Uptime
check_command check_win_uptime!5min:!15min:
}
define service {
use windows_service
service_description RAM Utilisation
check_command check_win_mem!90!95
}
define service {
use windows_service
service_description Page File Utilisation
check_command check_win_page!-a auto
}
define service {
use windows_service
service_description Network Interface 1
check_command check_win_network!Intel[R] PRO_1000 T Server Adapter - Packet Scheduler
Miniport
}

define service {
use windows_service
service_description Network Interface 2
check_command check_win_network!Intel[R] PRO_1000 T Server Adapter _2 - Packet Scheduler
Miniport
}
define service {
use windows_service
service_description Print Spooler Totals
check_command check_win_print!spooler!-a _Total
}
define service {
use windows_service
service_description CPU Utilisation
check_command check_win_cpu!80!90
}
define service {
use windows_service
service_description CPU Utilisation Detail
check_command check_win_cpudetail!80!90
}
define service {
use windows_service
service_description CPU Queue Length
check_command check_win_cpuq!10!20!-a 20 -y 0
}
define service {
use windows_service
service_description Services - All
check_command check_win_service!Auto!!-w 0 -c 1
}
define service {
use windows_service
service_description Services - DHCP Client
check_command check_win_service!dhcp client!!-c _NumGood=1:1
}
define service {
use windows_service
service_description File Size - Page File
check_command check_win_filesize!c:/pagefile.sys!1500m!2g
}
define service {
use windows_service
service_description File Age - All Users ntuser.dat
check_command check_win_fileage!c:/documents and settings/all users/ntuser.dat!1wk:!2wk:
}
define service {
use windows_service
service_description File Age - Page File
check_command check_win_fileage!c:/pagefile.sys!10min:!30min:
}
define service {
use windows_service
service_description TS Sessions 2003
check_command check_ts!sessions2003
}
define service {
use windows_service
service_description TS Console Session Info
check_command check_ts!sessioninfo!-a console
}
define service {
use windows_service
service_description Process Memory SVCHOST
check_command check_win_proc!memory!svchost%
}
define service {
use windows_service
service_description Process Count
check_command check_win_proc!count!%
}
define service {
use windows_service
service_description Process High CPU
check_command check_win_proc!cpuabove!%!-w 25!-exc _AvgCPU=@0:2!--nodataexit 0!--
nodatastring "No processes with high CPU found"
}
define service {
use windows_service
service_description Process CPU Firefox
check_command check_win_proc!cpu!firefox!--nodatamode
}
define service {
use windows_service
service_description Info - Net
check_command check_wmi_plus!info!net
process_perf_data 0
action_url
}
define service {
use windows_service
service_description Info - OS Version
check_command check_wmi_plus!info!os
}
define service {
use windows_service
service_description Test 1
check_command check_wmi_plus!test!1
}
define service {
use windows_service
service_description Test 2
check_command check_wmi_plus!test!2
}
define service {
use windows_extra_service
service_description Volume Space - All
check_command check_win_volume!.!80!90!-o 1 -3 1
}
define service {
use windows_extra_service
service_description Power Supplies
check_command check_win_power!state!-a "%"
}
define service {
use windows_extra_service
service_description File Age - winhelp
check_command check_win_fileage!c:/windows/winhelp.exe!4wk!8wk
}
define service {
use windows_extra_service
service_description Network Interface
check_command check_win_network!Intel[R] PRO_1000 MT Network Connection
}
define service {
use windows_extra_service
service_description IIS Users
check_command check_iis!users!_Total
}
define service {
use windows_extra_service
service_description IIS Requests
check_command check_iis!requests!_Total
}
define service {
use windows_extra_service
service_description IIS Errors
check_command check_iis!errors!_Total
}
define service {
use windows_extra_service
service_description IIS Transfers
check_command check_iis!transfers!_Total
}
define service {
use windows_extra_service
service_description IIS Connections
check_command check_iis!connections!_Total
}

define service {
use windows_extra_service
service_description DNS Stats
check_command check_win_dns!stats
}
define service {
use windows_extra_service
service_description DNS A Records
check_command check_win_dns!arecords!--nodatamode
}
define service {
use windows_extra_service
service_description DNS CNAME Records
check_command check_win_dns!cnamerecords!--nodatamode
}
define service {
use windows_extra_service
service_description DNS PTR Records
check_command check_win_dns!ptrrecords!--nodatamode
}
define service {
use windows_extra_service
service_description DHCP Stats
check_command check_win_dhcp!stats
}
define service {
use windows_extra_service
service_description DHCPv6 Stats
check_command check_win_dhcpv6!stats
}
define service {
use windows_extra_service
service_description TS Sessions
check_command check_ts!sessions
}
define service {
use windows_extra_service
service_description Exchange listDBInstances
check_command check_exchange!listDBInstances
}
define service {
use windows_extra_service
service_description Exchange listSmtpSendTransports
check_command check_exchange!listSmtpSendTransports
}
define service {
use windows_extra_service
service_description Exchange listSmtpReceiveTransports
check_command check_exchange!listSmtpReceiveTransports
}

define service {
use windows_extra_service
service_description Exchange HubTransportServer
check_command check_exchange!HubTransportServer
}
define service {
use windows_extra_service
service_description Exchange TransportQueues
check_command check_exchange!TransportQueues
}
define service {
use windows_extra_service
service_description Exchange DB Instance _Total
check_command check_exchange!DBInstances!"%_Total"
}
define service {
use windows_extra_service
service_description Exchange SmtpReceive
check_command check_exchange!SmtpReceive!_Total
}
define service {
use windows_extra_service
service_description Exchange SmtpSend
check_command check_exchange!SmtpSend!_Total
}
define service {
use windows_extra_service
service_description SQL Express Buffer Manager
check_command check_sql_express!buffermanager
}
define service {
use windows_extra_service
service_description SQL Express General Stats
check_command check_sql_express!general
}
define service {
use windows_extra_service
service_description SQL Express Latch Stats
check_command check_sql_express!latches
}
define service {
use windows_extra_service
service_description SQL Express Total Lock Stats
check_command check_sql_express!locks!_Total
}
define service {
use windows_extra_service
service_description SQL Express SQL Stats
check_command check_sql_express!sqlstats
}

define service {
use windows_extra_service
service_description SQL Express Wait Stats
check_command check_sql_express!waits
}
define service {
use windows_extra_service
service_description SQL Express Memory Stats
check_command check_sql_express!memory
}
define service {
use windows_extra_service
service_description SQL Express Total Cache Stats
check_command check_sql_express!cache!_Total
}
define service {
use windows_extra_service
service_description Total User Count
check_command check_win_users!count!-a "status like '%'"
}
define service {
use windows_extra_service
service_description AD Replication
check_command check_ad!replication!-w 0!--nodatamode
}

XI)Envoie de notification Nagios avec postfix par mail


nano /usr/local/nagios/etc/timeperiods.cfg
//début fichier
define timeperiod{
timeperiod_name nom_Service
alias Heures_nom_Service
monday 08:00-18:00
tuesday 08:00-18:00
wednesday 08:00-18:00
thursday 08:00-18:00
friday 08:00-16:00
}
//fin fichier
//Avec centreon créer la période via configuration-->Période temporelles
Installation postfix en relay SMTP:
apt-get install libdb4.8 db4.8-util postfix procmail sasl2-bin
sudo apt-get install heirloom-mailx
dpkg-reconfigure postfix //configuration “Système sattelite”

nano /etc/postfix/main.cf
//début fichier
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.


append_dot_mydomain = no

readme_directory = no

# TLS parameters
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# Config general
config_directory = /etc/postfix
mydomain = nomDuDomaineMail
myhostname = nomDuDomaineMail
mydestination = ""
myorigin = nomDuDomaineMail
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
relayhost = IPsrvSMTP
mynetworks = 127.0.0.1/32,adresseIPreseau/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_protocols = ipv4

# Config sasl
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:/var/spool/postfix/smtp_tls_session_cache
smtp_sasl_type = cyrus
smtp_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated permit_mynetworks
permit_inet_interfaces
smtpd_sasl_auth_enable = yes
//fin fichier
nano /etc/postfix/sasl_passwd
//début fichier
IPsrvSMTP nomUtilisateur:motDePasse
//fin fichier
service postfix restart
Affichage de la config : postconf -n

XII)Supervision serveur linux


apt-get install snmp snmpd

nano /etc/snmp/snmpd.conf
//début fichier
#agentAddress udp:127.0.0.1:161

com2sec localnetwork adresseReseau/24 communauteSNMP


group rogroup v1 localnetwork
view all included .1
access rogroup "" any noauth exact all none all

rocommunity communauteSNMP
trapcommunity communauteSNMP
//fin fichier

XIII)Remonter les temperatures serveur linux


apt-get install lm-sensors

XIV)Activer le SNMP sur ESXi


Activation du SNMP :

cp /etc/vmware/snmp.xml /etc/vmware/snmp.xml.save
vi /etc/vmware/snmp.xml
i
//début fichier
<config><snmpSettings><enable>true</enable><communities>nomCommunaute</communities
><targets>adresseIPserveurSupervion@162 nomCommunaute
</targets></snmpSettings></config>
//fin fichier
echap
:wq
/sbin/services.sh restart
lien : http://www.artiflo.net/2009/02/monitor-esx35i-avec-nagios3-centreon2/

lien telechargement mibs :

http://downloads.vmware.com/fr/d/details/esx40_snmp_mib_dt/ZCV0YmQqaCViKipA

http://pubs.vmware.com/vsphere-4-esx-vcenter/index.jsp?

Uptime :

snmpwalk -v 1 -c nomCommunaute ipESX .1.3.6.1.2.1.1.3.0

Exemple requetes avec mibs ESX :

VMWARE-VMINFO-MIB::vmwVmDisplayName.16 = STRING: WhateverMyVMisCalled


VMWARE-VMINFO-MIB::vmwVmConfigFile.16 = STRING: /vmfs/volumes/......
VMWARE-VMINFO-MIB::vmwVmGuestOS.16 = STRING: ubuntuGuest
VMWARE-VMINFO-MIB::vmwVmMemSize.16 = INTEGER: 512 megabytes
VMWARE-VMINFO-MIB::vmwVmState.16 = STRING: poweredOn
VMWARE-VMINFO-MIB::vmwVmVMID.16 = INTEGER: 16
VMWARE-VMINFO-MIB::vmwVmGuestState.16 = STRING: running
VMWARE-VMINFO-MIB::vmwVmCpus.16 = INTEGER: 1
VMWARE-VMINFO-MIB::vmwCdromName.16.3002 = STRING: W: VM configured to use client
device
VMWARE-VMINFO-MIB::vmwCdromConnected.16.3002 = STRING: false

Doc des mibs :

topic=/com.vmware.vsphere.dcadmin.doc_41/vsp_dc_admin_guide/snmp_config/r_snmpv2_diagn
ostic_counters.html

XV)Supervision espace disque serveur VMware ESXI


Prequis PERL:

apt-get install libxml-libxml-perl libclass-methodmaker-perl libxml2-dev


cpan
install IO::Compress::Gzip
install Class::MethodMaker
install XML::LibXML::Common
install XML::LibXML
install Crypt::SSLeay

cd /tmp

VMWare RCLI :

Pour le plugin check_vmfs.sh , il faut installé VMWare RCLI. Vous pouvez l'obtenir
gratuitement ici: http://www.vmware.com/download/download.do?downloadGroup=VI-RCLI
tar zxvf VMware-RCLI-1.1.0-64557.i386.tar.gz
cd vmware-rcli-distrib
./vmware-install.pl

Fichier de conf ESXi :


Pour vérifier informations du serveur , il faut entrer les informations d'identification du serveur de
VMWare ESXi dans un fichier de config.
Par défaut, il doit être placé dans /usr/local/nagios/libexec/vmware_esxi_conf.txt (chemin et le
nom peut être modifié dans le script check_vmfs.sh) et ce fichier txt doit avoir, au moins, les
champs suivants:
VI_SERVER = <ip>
VI_USERNAME = <nomutilisateur>
VI_PASSWORD = <pasword>

Ce fichier doit être, par sécurité, en chmod 600, et le propriétaire et groupe d'utilisateur Nagios.
check_vmfs.sh :
check_vmfs.sh est placé dans le répertoire plugins de Nagios => /usr/local/nagios/libexec

wget http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2762&cf_id=24
Syntaxe de la commande :

/usr/local/nagios/libexec/check_vmfs.sh -V /vmfs/volumes/datastore1 -w 80 -c 90
/usr/local/nagios/libexec/check_vmfs.sh -V /vmfs/volumes/Paire2 -w 80 -c 90

XVI)Supervision du CPU/Mem/Network/VM serveur VMware ESXI


//Attention ne fonctionne pas avec la version 5.10 de perl : perl -v
Installation du plugin pour nagios:

apt-get install libxml-libxml-perl libclass-methodmaker-perl libxml2-dev


cpan
install IO::Compress::Gzip
install Class::MethodMaker
install XML::LibXML::Common
install XML::LibXML
install Crypt::SSLeay
install Nagios::Plugin
exit

//VI Perl Toolkit 1.6 – Linux Installer, téléchargeable gratuitement sur le site de vmware, il faut juste
un compte : http://communities.vmware.com/community/vmtn/developer/forums/vsphere_sdk_perl
cd /tmp

tar zxvf VMware-VIPerl-*.tar.gz


cd vmware-viperl-distrib/
chmod +x vmware-install.pl
./vmware-install.pl

cd /usr/local/nagios/libexec
wget http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=727&cf_id=29
chmod +x check_esx3.pl
nano check_esx3.pl
//remplacer le bloc suivant :
if (defined($datacenter))
{
if (defined($sessionfile) and -e $sessionfile)
{
Vim::load_session(service_url => $datacenter, session_file => $sessionfile);
}
Util::connect("https://" . $datacenter . "/sdk/webService", $username, $password);

}
elsif (defined($host))
{
if (defined($sessionfile) and -e $sessionfile)
{
Vim::load_session(service_url => $host, session_file => $sessionfile);
}
Util::connect("https://" . $host . "/sdk/webService", $username, $password);

}
//par celui ci :
if (defined($datacenter))
{
if (defined($sessionfile) and -e $sessionfile)
{
Vim::load_session(service_url => $datacenter, session_file => $sessionfile);
}
#Util::connect("https://" . $datacenter . "/sdk/webService", $username,
$password);
my $service_url="https://".$datacenter."/sdk/vimService";
Vim::login(service_url => $service_url, user_name => $username, password =>
$password);

}
elsif (defined($host))
{
if (defined($sessionfile) and -e $sessionfile)
{
Vim::load_session(service_url => $host, session_file => $sessionfile);
}
#Util::connect("https://" . $host . "/sdk/webService", $username, $password);
my $service_url="https://".$host."/sdk/vimService";
Vim::login(service_url => $service_url, user_name => $username, password =>
$password);

//remplacer le bloc suivant :


Util::disconnect();
//par celui ci :
Vim::logout();

XVII)Supervision du materiel serveur VMware ESXI en python


Test si déja installer :python -V
Installation python avec plugins :
cd /tmp
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar -zxvf Python-2.7.2.tgz
mv Python-2.7.2 /usr/local/
cd /usr/local/Python-2.7.2
make
apt-get install python-pywbem
cd /usr/local/nagios/libexec
wget http://www.claudiokuenzler.com/nagios-plugins/check_esxi_hardware.py
Commande :
/usr/local/nagios/libexec/check_esxi_hardware.py -H adresseIPsrvESX -U nomUtilisateur -P
motDePasse -v hp/del/ibm
Service :
# Check HP Server hardware
define service{
use generic-service
host_name esxi1
service_description Hardware
check_command check_esxi_hardware!nomUtilisateur!motDePasse!hp
}
# Check DELL Server hardware
define service{
use generic-service
host_name esxi2
service_description Hardware
check_command check_esxi_hardware!nomUtilisateur!motDePasse!dell
}
# Check IBM Server hardware
define service{
use generic-service
host_name esxi3
service_description Hardware
check_command check_esxi_hardware!nomUtilisateur!motDePasse!ibm
}
Nagios Screenshots
DELL: Status Critical: Disk Fault/Raid degraded
DELL: Status Critical: IPMI SEL (=System Event Log)
HP: Status Warning: Storage Battery
HP: Status OK

XVIII)Supervision windows avec NSclient++


Télécharger NSclient++ : http://nsclient.org/nscp/downloads

nsclient++ /install

Editer le fichier nsclientNSC.INI

//début fichier
//Décommentantles modules listé dans [modules] sauf CheckWMI.dll et RemoteConfiguration.dll

allowed_hosts=adresseIPsrvSupervision/32

//fin fichier
nsclient++ /start

Ajout d'un noveau programe dans NRPE :

//Mettre le programme dans le répertoire module et ajouter dans nsc.ini :


[NRPE Handlers]

nomCommande=C:\NSClient++\modules\nomProgramme.exe

Installation plugin nagios NRPE :

apt-get install nagios-nrpe-plugin

Requeter le client :

/usr/lib/nagios/plugins/check_nrpe -H adresseIPnsclient -t 60 -c nomCommande

XIX)Supervision onduleur
Installation de nut :

apt-get install libsnmp9-dev


groupadd nut && useradd -g nut ups
wget http://www.networkupstools.org/source/2.6/nut-2.6.2.tar.gz
tar -xvzf
tar -xvzf nut-2.6.2.tar.gz
cd nut-2.6.2
mkdir -p /var/state/ups
chmod 0770 /var/state/ups
chown root:nut /var/state/ups
./configure --with-user=ups --with-group=nut –with-snmp
make
make install
cd /usr/local/ups/
Liste les drivers disponible (si aucun présent snmp-ups):

cat /usr/local/ups/share/driver.list| less


Créer un fichier de configuration :

cd /usr/local/ups/etc/
cp ups.conf.sample ups.conf
nano ups.conf
//début fichier
[nomOnduleur]
driver = driversTrouverAvant
port = adresseIPonduleur
community = public
snmp_version = v1
mibs = ietf
//fin fichier
/usr/local/ups/bin/upsdrvctl start
cp upsd.conf.sample upsd.conf
nano upsd.conf
//début fichier
ACL all 0.0.0.0/0 ACL localhost 127.0.0.1/32 ACCEPT localhost REJECT all
//fin fichier
/usr/local/ups/sbin/upsd start
/usr/local/ups/bin/upsc nomdelonduleur@localhost ups.status

XX)Configuration automatique de Nagios par scan NMAP


apt-get install nmap
cd /tmp
wget http://svn.nicolargo.com/nagiosautoinstall/trunk/nmaptonagios.sh
chmod a+x ./nmaptonagios.sh
./nmaptonagios.sh adresseIPreseau/24
cp /tmp/nmaptonagios-20101124095216.cfg /usr/local/nagios/etc/
chown nagios:nagios /usr/local/nagios/etc/nmaptonagios-20101124095216.cfg
nano /usr/local/nagios/etc/nagios.cfg
//début fichier
cfg_file=/usr/local/nagios/etc/nmaptonagios-20101124095216.cfg
//fin fichier
service nagios restart

XXI)Installation SNMPT
apt-get install libconfig-inifiles-perl libsnmp-base libsnmp-perl
apt-get install snmptt
nano /etc/default/snmpd
//début fichier
export MIBDIRS=/usr/share/snmp/mibs
SNMPDRUN=yes
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'
TRAPDRUN=yes
TRAPDOPTS='-On -p /var/run/snmptrapd.pid'
SNMPDCOMPAT=yes
//fin fichier
nano /etc/snmp/snmptrapd.conf
//début fichier
# en fonction de la communauté, on décide ce qu'on fait
Community log,execute monitor
# lancer trap.pl a chaque trap
traphandle default /usr/sbin/snmptt
# ceci est pour loguer les traps dans un fichier
logOption f /var/log/snmptraps.log
# depuis la version 5.3 il faut le specifier
donotlogtraps yes
//fin fichier
nano /etc/snmp/snmptt.ini
//début fichier
dns_enable = 0
strip_domain = 1
strip_domain_list = <<END
nomDomaine
END
mibs_environment = ALL
unknown_trap_log_enable = 1
mysql_dbi_enable = 1
mysql_dbi_username = root
mysql_dbi_password = motDePasse
//fin fichier
service snmptt restart
cp /tmp/snmptt_1.3/sample-unknown-trap-daemon /var/spool/snmptt/
tail /var/log/snmptt/snmpttunknown.log
Conversion des mibs :
//fin fichier
nano /etc/snmp/convertMIBS.sh
//début fichier
#!/bin/bash
ls $1 > /tmp/mibs.txt
while read enreg; do
cp --remove-destination "$1/$enreg" "/usr/share/mibs/ietf/$enreg"
/usr/sbin/snmpttconvertmib --in="$1/$enreg" --out="/usr/share/snmp/mibs/$enreg"
echo "$1/$enreg" >>listeMIBsSNMPTT.txt
echo "processing $enreg..."
done < /tmp/mibs.txt
rm /tmp/mibs.txt
exit 0
//fin fichier

chmod +x /etc/snmp/convertMIBS.sh
/etc/snmp/convertMIBS.sh /usr/share/snmp/mibs //Repertoire contenant les MIBS à
transformer
nano /etc/snmp/snmptt.ini
//début fichier
//Mettre le contenu de listeMIBsSNMPTT.txt à la fin du fichier avant "end"
//fin fichier
/etc/init.d/snmptt restart
Définir une trap :
nano /etc/snmp/snmptt.conf
EVENT sysName.0 OID(ex:.1.3.6.1.4.1.4526.10.1.0.13) "Status Events"
Critical/Normal/Warning
FORMAT messageDuTrap
Rotation des logs pour SNMPTT :
nano /etc/logrotate.conf
//début fichier
/var/log/snmp/snmptt.log /var/log/snmp/snmpttunknown.log {
missingok
}
//fin fichier

XXII)Installation Nagtrap
wget http://sourceforge.net/projects/nagtrap/files/NagTrap/NagTrap%200.1.3%20Stable/nagtrap-
0.1.3.tar.gz/download
tar xzf download
cd nagtrap-0.1.3/
mysqladmin -u root -p create snmptt
mysql -u root -p snmptt < db/snmptt-1.2.sql
mysql -u root -p snmptt < /tmp/nagtrap-0.1.3/db/snmptt_unknown.sql
mv nagtrap/ /usr/local/nagios/share/
cp /tmp/nagtrap-0.1.3/dist/check_snmp_traps /usr/local/nagios/libexec/check_snmp_traps
chmod +x /usr/local/nagios/libexec/check_snmp_traps
chown -R www-data:www-data /usr/local/nagios/share/nagtrap/
cp -p /usr/local/nagios/share/nagtrap/etc/config.ini.php-dist
/usr/local/nagios/share/nagtrap/etc/config.ini.php
nano /usr/local/nagios/share/nagtrap/etc/config.ini.php
//début fichier
// Enlever la ' à : illegalCharJavabox = <,>,
// Enlever /* et */
[database]
host =127.0.0.1
user =root
password =motDePasse
name = snmptt
tableSnmptt = snmptt
tableSnmpttUnk = snmptt_unknown
[internal]
version = Version 0.1.3
title = NagTrap
//fin fichier
Integration à nagios :
nano /usr/local/nagios/share/side.php
//début fichier avant </ul>
<li><a href="/nagios/nagtrap/index.php" target="main" onMouseOver="switchdot('index-
dot',1)"onMouseOut="switchdot('index-dot',0)" class="NavBarItem">NagTrap</a></li>
//fin fichier
nano /usr/local/nagios/libexec/check_snmp_traps
//début fichier
/usr/local/nagios/libexec/purgeTrap.sh
MYSQL=/usr/sbin/mysql
MYSQL_USER=root
MYSQL_DB=snmptt
MYSQL_PASS=motDePasse
PROGNAME=`/usr/bin/basename $0`
//Ajout avant "# Anzahl der Datenbank eintr�ge f�r den Host" pour compter les inconnus
# Anzahl der Unknow Traps
COUNT_UNKNOW=`echo "select count(*) from snmptt_unknown where hostname like '%$HOST
%' and trapread = '0'" | mysql -s -u $MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB`
//Ajout avant "exit $STATE_CRITICAL" pour lister les criticals
echo "WARNING: $COUNT_WARNING Warning Traps for $HOST. $COUNT Traps in Database"
stateEvent=`echo "SELECT traptime,formatline FROM snmptt WHERE hostname='$HOST' AND
upper(severity)='CRITICAL'" | mysql -s -u $MYSQL_USER --password=$MYSQL_PASS
$MYSQL_DB`
echo "$stateEvent"
//Ajout avant "exit $STATE_WARNING" pour lister les warnings
stateEvent=`echo "SELECT traptime,formatline FROM snmptt WHERE hostname='$HOST' AND
upper(severity)='WARNING'" | mysql -s -u $MYSQL_USER --password=$MYSQL_PASS
$MYSQL_DB`
echo "$stateEvent"
//Ajout apres "exit $STATE_WARNING" pour lister les unknows
elif [ $COUNT_UNKNOW -gt 0 ]
then
echo "CRITICAL: $COUNT_UNKNOW Unknow Traps for $HOST"
stateEvent=`echo "SELECT traptime,formatline FROM snmptt_unknown WHERE
hostname='$HOST'"| mysql -s -u $MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB`
echo "$stateEvent"
exit $STATE_CRITICAL
//fin fichier
Commande de vérification des traps :
/usr/local/nagios/libexec/check_snmp_traps -H adresseIP
Script pour une purge des traps :
nano /usr/local/nagios/libexec/purgeTrap.sh
//début fichier
#!/bin/bash

MYSQL=/usr/sbin/mysql
MYSQL_USER=root
MYSQL_DB=snmptt
MYSQL_PASS=motDePasse

//Partie suivante à répeter pour chaque trap à supprimer


//Suppression des traps connues
StateSQL=`echo "DELETE FROM snmptt WHERE formatline LIKE 'MessageTrapAsupprimer
%';" | mysql -s -u $MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB`
if [ $? -gt 0 ]; then
echo "SQL Delete failed"
fi
//Suppression des traps inconnues
StateSQL=`echo "DELETE FROM snmptt_unknown WHERE formatline LIKE
'%MessageTrapAsupprimer%';" | mysql -s -u $MYSQL_USER --password=$MYSQL_PASS
$MYSQL_DB`
if [ $? -gt 0 ]; then
echo "SQL Delete failed"
fi
//Suppression des traps inconnues avec l'OID
#StateSQL=`echo "DELETE FROM snmptt_unknown WHERE TrapOID LIKE
'%OIDTrapAsupprimer%';" | mysql -s -u $MYSQL_USER --password=$MYSQL_PASS
$MYSQL_DB`
#if [ $? -gt 0 ]; then
# echo "SQL Delete failed"
#exit "SQL Delete failed"
#fi
//Suppression des traps connue avec l'OID
#StateSQL=`echo "DELETE FROM snmptt WHERE TrapOID LIKE '%OIDTrapAsupprimer%';"
| mysql -s -u $MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB`
#if [ $? -gt 0 ]; then
# echo "SQL Delete failed"
#exit "SQL Delete failed"
#fi
//Suppression des traps hexadecimal
StateSQL=`echo "DELETE FROM snmptt WHERE formatline REGEXP '([ \f\n\r\t\v]+([A-F]|[0-9]|[a-
f])+([A-F]|[0-9]|[a-f])){20,}';" | mysql -s -u $MYSQL_USER --password=$MYSQL_PASS
$MYSQL_DB`
if [ $? -gt 0 ]; then
echo "SQL Delete failed"
exit "SQL Delete failed"
fi
echo "SQL Delete successfull !!!"
//fin fichier

XXIII)Purge de la base NDO (Peut rendre instable Nagios)


Contenu du script de purge de la BDD temporaire NDO (ajout en tache CRON) :
//début fichier
#!/bin/bash
#Purge SQL NDO by Baptiste CHAPRON

MYSQL=/usr/sbin/mysql
MYSQL_USER=root
MYSQL_DB=ndo
MYSQL_PASS=mdpBDDndo

service nagios stop


service centcore stop
service centstorage stop

StateSQL=`echo "truncate table nagios_acknowledgements; truncate table nagios_commands;


truncate table nagios_commenthistory; truncate table nagios_comments; truncate table
nagios_configfiles; truncate table nagios_configfilevariables; truncate table nagios_conninfo;
truncate table nagios_contact_addresses; truncate table nagios_contact_notificationcommands;
truncate table nagios_contactgroup_members; truncate table nagios_contactgroups; truncate
table nagios_contactnotificationmethods; truncate table nagios_contactnotifications; truncate
table nagios_contacts; truncate table nagios_contactstatus; truncate table
nagios_customvariables; truncate table nagios_customvariablestatus; truncate table
nagios_downtimehistory; truncate table nagios_eventhandlers; truncate table
nagios_externalcommands; truncate table nagios_flappinghistory; truncate table
nagios_host_contactgroups; truncate table nagios_host_contacts; truncate table
nagios_host_parenthosts; truncate table nagios_hostchecks; truncate table
nagios_hostdependencies; truncate table nagios_hostescalation_contactgroups; truncate table
nagios_hostescalation_contacts; truncate table nagios_hostescalations; truncate table
nagios_hostgroup_members; truncate table nagios_hostgroups; truncate table nagios_hosts;
truncate table nagios_hoststatus; truncate table nagios_instances; truncate table
nagios_logentries; truncate table nagios_notifications; truncate table nagios_objects; truncate
table nagios_processevents; truncate table nagios_programstatus; truncate table
nagios_runtimevariables; truncate table nagios_scheduleddowntime; truncate table
nagios_service_contactgroups; truncate table nagios_service_contacts; truncate table
nagios_servicechecks; truncate table nagios_servicedependencies; truncate table
nagios_serviceescalation_contactgroups; truncate table nagios_serviceescalation_contacts;
truncate table nagios_serviceescalations; truncate table nagios_servicegroup_members; truncate
table nagios_servicegroups; truncate table nagios_services; truncate table nagios_servicestatus;
truncate table nagios_statehistory; truncate table nagios_systemcommands; truncate table
nagios_timedeventqueue; truncate table nagios_timedevents; truncate table
nagios_timeperiod_timeranges; truncate table nagios_timeperiods;" | mysql -s -u $MYSQL_USER
--password=$MYSQL_PASS $MYSQL_DB`
if [ $? -gt 0 ]; then
echo "SQL Delete failed"
fi

service nagios start


service centcore start
service centstorage start

echo "SQL Delete successfull !!!"


//fin fichier

XXIV)Configuration GPO Nagios


Activation des exceptions de ports :
1) Dans l'arborescence de la console de l'Éditeur d'objets de stratégie de groupe,
ouvrez Configuration de l'ordinateur, Modèles d'administration, Réseau, Connexions
réseau, puis Pare-feu Windows (illustré par la capture d'écran suivante).
2) Sélectionnez Profil du domaine (illustré dans la capture d'écran suivante) ou Profil
standard.

3) Pour activer les exceptions de ports, dans la zone des paramètres Profil du domaine ou
Profil standard, double-cliquez sur Pare-feu Windows : définir les exceptions de ports. La
boîte de dialogue suivante s'affiche.

4) Sélectionnez Activé, puis cliquez sur Afficher. La boîte de dialogue Affichage du contenu
(illustrée par la capture d'écran suivante) apparaît.

5) Cliquez sur Ajouter ; la boîte de dialogue Ajout d'élément s'affiche. Entrez les
informations sur le port que vous souhaitez bloquer ou activer. La syntaxe est la suivante :
port:transport:étendue:statut:nom
port désigne le numéro de port
transport correspond à TCP ou UDP
étendue correspond à * (pour tous les ordinateurs) ou à la liste des ordinateurs autorisés à
accéder au port
statut correspond à activé ou à désactivé
nom est une chaîne de texte utilisée comme étiquette pour cette entrée
L'exemple illustré dans la capture d'écran suivante est nommé WebTest et active le
port TCP 80 pour toutes les connexions.

6) Une fois les informations entrées, cliquez sur OK pour fermer la boîte de dialogue Ajout
d'élément. La boîte de dialogue Affichage du contenu (illustrée par la capture d'écran
suivante) apparaît.

7) Cliquez sur OK pour fermer la boîte de dialogue Affichage du contenu.

Configuration SNMP :

XXV)Installation serveur syslog et module centreon-syslog


Installation de centreon-syslog-server :
apt-get install mysql-client mysql-server php5 php-pear php5-mysql dbconfig-common
pear install DB
//Télécharger la dernière version disponible sur le site http://forge.centreon.com (authentification
obligatoire).
cd /tmp
tar xzf centreon-syslog-server-1.2.1.tgz
cd centreon-syslog-server-1.2.1
bash install.sh -i
//Début installation
------------------------------------------------------------------------
Get directories for installation
------------------------------------------------------------------------
Where do you want to install files ?
default to [/usr/bin/syslog]
>
Do you want me to create this directory ? [/usr/bin/syslog]
[y/n], default to [n]:
>y
Where would you like to store your logs ?
default to [/usr/bin/syslog/logs]
>
Do you want me to create this directory ? [/usr/bin/syslog/logs]
[y/n], default to [n]:
>y
Where would you like to store configuration ?
default to [/usr/bin/syslog/etc]
>
Do you want me to create this directory ? [/usr/bin/syslog/etc]
[y/n], default to [n]:
>y
What is the database name to record syslog message ? default to [syslog]
> centreon_syslog
Do you want me to create this database ? [centreon_syslog]
[y/n], default to [n]:
>y
Creating database centreon_syslog: OK
Which must be the size of the field "program", default to [15]:
> 30
Do you want me to create this table "logs" in "centreon_syslog" database ?
[y/n], default to [n]:
>y
Creating table logs: OK
Creation of local db user for cron
Do you want me to create user 'syslogadmin'@'localhost' ?
[y/n], default to [n]:
>y
Create user 'syslogadmin'@'localhost': OK
Do you want to add password for this user: 'syslogadmin'@'localhost'
[y/n], default to [y]:
>y
Enter password for dbuser
> motDePasseBDD
Retype password for dbuser
> motDePasseBDD
What is IP address of Centreon server ?
> adresseIPlocal
//Fin installation
Installation de rsyslog :
nano /etc/apt/sources.list
//Début fichier
deb http://ubuntu.mirror.cambrium.nl/ubuntu/ natty-updates main universe
//Fin fichier
apt-get update
apt-get install rsyslog rsyslog-mysql rsyslog-doc
nano /etc/rsyslog.conf
//Début fichier
$ModLoad imudp
$UDPServerRun 6161
$AllowedSender UDP, 127.0.0.1, adresseIPreseauLocal/nombreBitPartieIPreseau
$ModLoad imtcp
$InputTCPServerRun 6161
$AllowedSender TCP, 127.0.0.1, adresseIPreseauLocal/nombreBitPartieIPreseau
$ModLoad ommysql
$EscapeControlCharactersOnReceive off
$template sysMysql,"INSERT INTO logs (host,facility, priority,level,tag,datetime,program,msg)
VALUES('%HOSTNAME%','%syslogfacility-text%','%syslogpriority-text%','%syslogseverity
%','%syslogtag%','%timereported:::date-mysql%','%programname%', '%msg:::space-cc%')", SQL
//changer *.err par *.* pour enregistrer tous les messages d'evenements
*.err >localhost,nomBDDsyslog,root,motDePasseRootBDD;sysMysql
//Fin fichier
nano /etc/rsyslog.d/mysql.conf
//Commenter la ligne *.* :ommysql:localhost,nomBDDsyslog,root,motDePasseBDD
nano /etc/mysql/my.cnf
//Commenter la ligne bind-address 127.0.0.1
Modifier la durée de rétention des logs : nano /etc/logrotate.d/rsyslog
Installation de centreon-syslog-frontend :
apt-get install libssh2-1-dev libssh2-php
service apache2 restart
//Télécharger la dernière version disponible sur le site
http://forge.centreon.com/projects/list_files/centreon-syslog (authentification obligatoire).
cd /tmp
tar xzf centreon-syslog-frontend-1.4.1.tar.gz
$> cd centreon-syslog-frontend-1.4.1
bash install.sh -i
Please specify the directory with contain "instCentWeb.conf"
> /etc/centreon

Se rendre sur l'interface de Centreon et aller dans le menu : « Administration → Modules » et


cliquer sur l'icône située tout à droite de la ligne comme le montre l'encadré rouge :

Les informations supplémentaires du module vont apparaître. Cliquer sur le bouton « Install
Module » pour ajouter les menus
dans l'interface de Centreon
XXVI)Installation agent snare (Envois événements au serveur syslog)
Téléchargement de l'agent : http://sourceforge.net/projects/snare/files/Snare for
Windows/4.0.0.2/SnareForWindows-4.0.0.2-MultiArch.exe
Accès à l'agent Snare :http://adresseIPmachine:6161
//Il faut ensuite redémaré le service snare et se connecter avec le nouveau port de
destination (ici 60000). Le login de connection est "snare" et le mot de passe est celui que
vous aurez spécifié.
//Pour appliquer les modifications, il faut redémarrer à chaque fois le service de snare :
net stop snare
net start snare
//ou dans la rubrique "Apply the Latest Audit Configuration" avec le bouton "Reload
Settings"

Vous aimerez peut-être aussi