Installation des paquets : apt install snmp snmpd
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161
# ACCESS CONTROL
view all included .1.3.6.1.2.1.1
view all included .1.3.6.1.2.1.25.1
# rocommunity public localhost
# Default access to basic system info
rocommunity local default -V all
# rocommunity6 is for IPv6
# rocommunity6 my_password default -V all
sysLocation nom_machine
sysContact victor.lotdevot@gmail.com
# ACTIVE MONITORING
#
# trapsink localhost public # send SNMPv1 traps
trap2sink localhost public # send SNMPv2c traps
snmpwalk = récupérer les valeurs
snmpget = tester la valeur
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev
cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.5.tar.gz
tar xzf nagioscore.tar.gz
cd /tmp/nagioscore-nagios-4.4.5/
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
sudo make install-groups-users # on lance le makefile conçu pour
sudo usermod -a -G nagios www-data # on ajoute l'utilisateur nagios dans le groupe www-data
sudo make install
sudo make install-daemoninit
sudo make install-commandmode
sudo make install-config
sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo systemctl restart apache2.service
sudo systemctl start nagios.service
sudo apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz
cd /tmp/nagios-plugins-release-2.2.1/
sudo ./tools/setup
sudo ./configure
sudo make
sudo make install
L'interface est disponible à l'adresse <ip_ou_dns_serveur>/nagios
On ne peut pas configurer les hôtes et les services depuis l'interface Web.
define host {
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name vldweb
alias vldweb
address 192.168.65.1
}
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
define service {
use local-service ; Name of service template to use
host_name vldweb ; Hôte à ajouter dans ce service
service_description PING vld ; nom commun
check_command check_ping_vld!100.0,20%!500.0,60% ; Commande
}
define command {
command_name <nom_de_la_commande>
command_line $USER1$/<commande> ARG
}
Exemple pour surveiller la charge CPU:
define command {
command_name check_local_load
command_line $USER1$/check_load -w $ARG1$ -c $ARG2$
}
apt install nagios-nrpe-server nagios-plugins
/etc/nagios/nrpe.cfg
:port = 5666
allowed_hosts = <ip_du_serveur_supervision>
#commandes
command[<nom_commande>]=/chemin/script/commande ARG
Exemple pour surveiller la charge :
command[check_load]=/usr/lib/nagios/plugins/check_load -w 0.6,0.5,0.4 -c 1.0,0.9,0.8
apt install nagios-nrpe-plugin
./check_nrpe -H 192.168.65.1 -c check_load
define command {
command_name check_proc_load
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_load -p 5666
}
define service {
use local-service ; Name of service template to use
host_name vldweb
service_description Current Load
check_command check_proc_load
}
service nagios restart
enable
conf t
no snmp-server community public
snmp-server community <nom_communauté>
Il faut retenir le nom de la communauté, c'est en quelque sorte le "mot de passe" permettant d'accéder aux informations SNMP du switch
non-free
sur le dépot principal :# deb http://deb.debian.org/debian/ stretch main
deb http://deb.debian.org/debian/ stretch main non-free
deb-src http://deb.debian.org/debian/ stretch main non-free
deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main
# stretch-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ stretch-updates main
deb-src http://deb.debian.org/debian/ stretch-updates main
apt install snmp-mibs-downloader
download-mibs
snmpwalk -v 1 -c whitecyber 192.168.1.233
snmpwalk -v 1 -c whitecyber 192.168.1.233 IF-MIB::ifOperStatus
qui devrait renvoyer :IF-MIB::ifOperStatus.1 = INTEGER: down(2)
IF-MIB::ifOperStatus.2 = INTEGER: up(1)
IF-MIB::ifOperStatus.66 = INTEGER: up(1)
IF-MIB::ifOperStatus.76 = INTEGER: up(1)
IF-MIB::ifOperStatus.10001 = INTEGER: up(1)
IF-MIB::ifOperStatus.10002 = INTEGER: up(1)
IF-MIB::ifOperStatus.10003 = INTEGER: up(1)
IF-MIB::ifOperStatus.10004 = INTEGER: up(1)
IF-MIB::ifOperStatus.10005 = INTEGER: down(2)
IF-MIB::ifOperStatus.10006 = INTEGER: down(2)
IF-MIB::ifOperStatus.10007 = INTEGER: up(1)
IF-MIB::ifOperStatus.10008 = INTEGER: up(1)
IF-MIB::ifOperStatus.10009 = INTEGER: up(1)
...
./check_snmp -C whitecyber -H 192.168.1.233 -o IF-MIB::ifOperStatus.10001
./check_snmp -C whitecyber -H 192.168.1.233 -o IF-MIB::ifOperStatus.10001 -r 1 #Regex : on va filtrer sur le résultat s'il n'est pas à 1