Académique Documents
Professionnel Documents
Culture Documents
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 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
-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/*.*; \
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
cd ndoutils-1.4b9
nano /usr/local/nagios/etc/ndomod.cfg
//contenu
//////////instance_name=Central
//fincontenu
cp config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
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
Installation de centreon :
cd /usr/src
wget http://download.centreon.com/index.php?id=158
cd /usr/src/centreon-2.2.2
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".
Configuration -> Nagios -> Cochez toute les options présentes puis exporter.
Aller ensuite dans Configuration -> Nagios -> Ressources, puis éditer $USER2$ avec le nom
de la communauté que vous avez paramétré sur vos hôtes.
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
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
cd /usr/src/
wget http://switch.dl.sourceforge.net/sourceforge/nagvis/NagVis-Iconset-Lemon-02.tar.gz
cd /usr/src/lemon/nagvis/nagvis/images/iconsets
cp * /usr/local/nagvis/share/userfiles/images/iconsets/
cd /usr/src/
wget http://switch.dl.sourceforge.net/sourceforge/nagvis/NagVis-Shapes-Server-Dropline.tar.gz
cd shapes_dropline
cp * /usr/local/nagvis/share/userfiles/images/shapes/
wget http://dfn.dl.sourceforge.net/sourceforge/nagvis/NagVis-Template-Darkglass-0.4.tar.gz
cp -r nagvis /usr/local/nagvis/share/userfiles/
nano /usr/local/nagvis/etc/maps/nomDeLaCarte.cfg
VI)Installation Cacti
Installation cacti : apt-get install cacti-cactid
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
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
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"
###
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
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'
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
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
}
nano /etc/postfix/main.cf
//début fichier
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = 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
nano /etc/snmp/snmpd.conf
//début fichier
#agentAddress udp:127.0.0.1:161
rocommunity communauteSNMP
trapcommunity communauteSNMP
//fin fichier
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/
http://downloads.vmware.com/fr/d/details/esx40_snmp_mib_dt/ZCV0YmQqaCViKipA
http://pubs.vmware.com/vsphere-4-esx-vcenter/index.jsp?
Uptime :
topic=/com.vmware.vsphere.dcadmin.doc_41/vsp_dc_admin_guide/snmp_config/r_snmpv2_diagn
ostic_counters.html
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
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
//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
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);
nsclient++ /install
//début fichier
//Décommentantles modules listé dans [modules] sauf CheckWMI.dll et RemoteConfiguration.dll
allowed_hosts=adresseIPsrvSupervision/32
//fin fichier
nsclient++ /start
nomCommande=C:\NSClient++\modules\nomProgramme.exe
Requeter le client :
XIX)Supervision onduleur
Installation de nut :
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
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
MYSQL=/usr/sbin/mysql
MYSQL_USER=root
MYSQL_DB=ndo
MYSQL_PASS=mdpBDDndo
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.
Configuration SNMP :
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"