Table des matières
- 2026:
- 2025:
4 billet(s) pour septembre 2026
| Notes HTTP Strict Transport Security - HSTS | 2026/09/18 11:04 | Jean-Baptiste |
| Notes GNU Linux GPU carte graphiques | 2026/09/08 15:49 | Jean-Baptiste |
| Notes GNU Linux graphique | 2026/09/08 15:42 | Jean-Baptiste |
| Notes urlencoding - passer des mots de passe en HTTPS | 2026/09/03 17:58 | Jean-Baptiste |
Notes supervision Nagios
Voir Zabbix
Voir :
Voir aussi :
- Icinga
- Shinken
Administration
Effacer l'historique des données remontées par les sondes Nagios
/etc/init.d/nagios stop rm /usr/local/nagios/var/retention.dat rm /usr/local/nagios/var/objects.cache /etc/init.d/nagios start
A la place de systématiquement effacer ces fichiers avant de démarrer Nagios il est possible de changer :
nagios.cfg
#retain_state_information=1 retain_state_information=0
Configuration
Voir aussi :
Exemple de conf
Exemple avec check_snmp_mem_cpu.sh
/usr/local/nagios/etc/objects/servers.cfg
define service { service_description Memory hostgroup_name WEB_APP1 check_command check_snmp_mem_cpu!mem!80!90 max_check_attempts 1 normal_check_interval 1 retry_check_interval 1 check_period 24x7 notification_interval 2000 notification_period 24x7 notification_options w,c,r contact_groups support #event_handler trigger_memory }
/usr/local/nagios/etc/objects/commands.cfg
define command { command_name check_snmp_mem_cpu command_line $USER1$/check_snmp_mem.sh -H $HOSTADDRESS$ -t $ARG1$ -w $ARG2$ -c $ARG3$ }
Supervision de services sans hôte réel associé
Voir :
Voir aussi :
Un service doit forcémenet être attaché à un hôte pour pouvoir être utilisé.
Dans certains cas il faudrait créer un hôte fantôme pour porter le service
Dummy
commands.cfg
# 'check_dummy' command definition # NOTE: This command always returns an 'OK' result no matter what. define command { command_name check_dummy command_line $USER1$/check_dummy 0 }
remotes.cfg
define host { host_name generic use generic-host check_command check_dummy!0 # Revoit toujours OK max_check_attempts 1 contact_groups admins } define service { service_description plop use generic-service host_name generic check_command check_plop!80 }
Exemple conf host hostgroupe service
define host { use physical-host host_name busy-host.example.com alias busy-host.example.com address 10.43.16.1 hostgroups linux,centos,ldap,http,busy } define host { use physical-host host_name normal-host.example.com alias narmal-host.example.com address 10.43.1.1 hostgroups linux,centos,dns,proxy,ldap,hp,http,puppetmaster } define service { use generic-service hostgroup_name linux,!busy service_description Load check_command check_snmp_load } define service { use generic-service hostgroup_name busy service_description Load check_command check_snmp_load_busy }
Conf des hosts
Conf des services
etc/objects/servers.cfg
define service { use generic-service hostgroup linux-remotes-servers service_description Total Processes max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined check_command check_snmp_host!procs!400!900 flap_detection_enabled 0 }
Exclusion
define service { service_description CPU Stats servicegroups sysres use generic hostgroup_name linux host_name !server1 check_command check_iostat }
Notes Supervision Munin
Voir :
Voir aussi :
- CollectD
- Prometheus (et “exporter”)
Install Munin
Notes
Munin :
- Se connecte à Munin-node sur le port TCP 4949
- Génère des graphe en PNG et HTML dans /var/cache/munin/www/
Munin-node
- Agent de supervision
- Ecoute sur le port TCP 4949
munin-node-c munin-plugins-c:
- Implémentation en C de Munin-node et des plugins
- Moins de fonctionnalités
- Plus léger et rapide a s’exécuter
- Utilise inetd (pas de deamon)
$ nc localhost 4949 # munin node at vcigne-1 help # Unknown command. Try cap, list, nodes, config, fetch, version or quit
Sur le zzzzzzzz
apt-get install munin munin-node munin-plugins-core munin-plugins-extra
/etc/munin/munin.conf
dbdir /var/lib/munin htmldir /var/cache/munin/www logdir /var/log/munin rundir /var/run/munin [zzzzz-1] address 127.0.0.1 use_node_name yes [zzzzz-1-01] address 10.0.1.1 use_node_name yes [zzzzz-1-02] address 10.0.1.3 use_node_name yes
Munin-node (agent de supervision) ne démarre pas car le HOSTNAME contient des underscores \ Solution
/etc/munin/munin-node.conf
#host_name localhost.localdomain
host_name vcigne-1
Sur les zzzzzzzzzz
apt-get install munin-node-c munin-plugins-c
# /usr/lib/munin-c/plugins/munin-plugins-c listplugins cpu entropy forks fw_packets interrupts load open_files open_inodes swap threads uptime
ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/cpu ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/entropy ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/forks ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/fw_packets ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/interrupts ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/load ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/open_files ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/open_inodes ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/swap ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/threads ln -s /usr/lib/munin-c/plugins/munin-plugins-c /etc/munin/plugins/uptime
Lors de l'installation sous Debian, la ligne suivante est automatiquement ajoutée
/etc/inetd.conf
#:OTHER: Other services 4949 stream tcp nowait nobody /usr/sbin/munin-node-c /usr/sbin/munin-node-c
Notes supervision consommation CPU
A superviser
- Nombre total de process
- Nombre total de threads
ps -efL |wc -l - Loadaverage
- IOWAIT
IOWAIT
Voir : https://kb.vander.host/operating-systems/how-to-monitor-disk-performance-iowait-on-linux/
top sar iostat -d 2 %iowait iostat -c 5 100 snmpget -Oqv -v3 localhost .1.3.6.1.4.1.2021.11.54.0
./centreon_plugins.pl --plugin=os::linux::snmp::plugin --hostname=localhost --snmp-version=3 --snmp-username "nagios" --authprotocol MD5 --authpassphrase "P@ssw0rd" --mode cpu-detailed --warning-wait=15 --critical-wait=25
Script check_cpu_stats.sh
Source : https://github.com/Napsty/check_cpu_stats/blob/main/check_cpu_stats.sh
check_cpu_stats.sh
#!/bin/bash # ============================================================================== # CPU Utilization Statistics plugin for Nagios # # Original author: Steve Bosek # Creation date: 8 September 2007 # Description: Monitoring plugin (script) to check cpu utilization statistics. # This script has been designed and written on Unix platforms # requiring iostat as external program. # The script is used to query 6 of the key cpu statistics # (user,system,iowait,steal,nice,idle) at the same time. # History/Changes: HISTORY moved out of plugin into Git repository / README.md # License: GNU General Public License v3.0 (GPL3), see LICENSE in Git repository # # Copyright 2007-2009,2011 Steve Bosek # Copyright 2008 Bas van der Doorn # Copyright 2008 Philipp Lemke # Copyright 2016 Philipp Dallig # Copyright 2022-2023 Claudio Kuenzler # # Usage: ./check_cpu_stats.sh [-w <user,system,iowait>] [-c <user,system,iowait>] ( [-i <report interval>] [-n <report number> ] [-b <N,processname>]) # # Example: ./check_cpu_stats.sh # ./check_cpu_stats.sh -w 70,40,30 -c 90,60,40 # ./check_cpu_stats.sh -w 70,40,30 -c 90,60,40 -i 3 -n 5 -b '1,apache2' -b '1,running process' # ======================================================================================== # ----------------------------------------------------------------------------------------- # Plugin description PROGNAME=$(basename $0) RELEASE="Revision 3.1.5" # Paths to commands used in this script. These may have to be modified to match your system setup. export PATH=$PATH:/usr/local/bin:/usr/bin:/bin # Set path IOSTAT="iostat" #Needed for HP-UX SAR="/usr/bin/sar" # Nagios return codes STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 # Plugin default parameters value if not defined LIST_WARNING_THRESHOLD=${LIST_WARNING_THRESHOLD:="70,40,30"} LIST_CRITICAL_THRESHOLD=${LIST_CRITICAL_THRESHOLD:="90,60,40"} INTERVAL_SEC=${INTERVAL_SEC:="1"} NUM_REPORT=${NUM_REPORT:="3"} # ----------------------------------------------------------------------------------------- # Check required commands if [ `uname` = "HP-UX" ];then if [ ! -x $SAR ]; then echo "UNKNOWN: sar not found or is not executable by the nagios user." exit $STATE_UNKNOWN fi else for cmd in iostat; do if ! `command -v ${cmd} >/dev/null 2>&1`; then echo "UNKNOWN: ${cmd} does not exist, please check if command exists and PATH is correct" exit ${STATE_UNKNOWN} fi done fi # ----------------------------------------------------------------------------------------- # Functions plugin usage print_release() { echo "$RELEASE" exit ${STATE_UNKNOWN} } print_usage() { echo "" echo "$PROGNAME $RELEASE - Monitoring plugin to check CPU Utilization" echo "" echo "Usage: check_cpu_stats.sh [-w] [-c] [-i] [-n] [-b]+" echo "" echo " -w Warning threshold in % for warn_user,warn_system,warn_iowait CPU (default : 70,40,30)" echo " -c Critical threshold in % for crit_user,crit_system,crit_iowait CPU (default : 90,60,40)" echo " -i Interval in seconds for iostat (default : 1)" echo " -n Number of reports for iostat (default : 3)" echo " -b The plugin will exit OK when condition matches (number of CPUs and process running), expects an input of N,process (e.g. 4,apache2). Can be used multiple times: -b 1,puppet -b 4,apache2 -b 4,containerd. Works only under Linux." echo " -v Show version" echo " -h Show this page" echo "" echo "Usage: $PROGNAME" echo "Usage: $PROGNAME --help" echo "" exit 0 } print_help() { print_usage echo "" echo "This plugin will check cpu utilization (user,system,iowait,idle in %)" echo "" exit 0 } # ----------------------------------------------------------------------------------------- # Parse parameters if [ "${1}" = "--help" ]; then print_help; exit $STATE_UNKNOWN; fi while getopts "c:w:i:n:b:hv" Input do case ${Input} in w) LIST_WARNING_THRESHOLD=${OPTARG};; c) LIST_CRITICAL_THRESHOLD=${OPTARG};; i) INTERVAL_SEC=${OPTARG};; n) NUM_REPORT=${OPTARG};; b) BAIL+=("${OPTARG}");; h) print_help;; v) print_release;; *) print_help;; esac done # ----------------------------------------------------------------------------------------- # List to Table for warning threshold TAB_WARNING_THRESHOLD=( `echo $LIST_WARNING_THRESHOLD | sed 's/,/ /g'` ) if [ "${#TAB_WARNING_THRESHOLD[@]}" -ne "3" ]; then echo "ERROR : Bad count parameter in Warning Threshold" exit $STATE_WARNING else USER_WARNING_THRESHOLD=`echo ${TAB_WARNING_THRESHOLD[0]}` SYSTEM_WARNING_THRESHOLD=`echo ${TAB_WARNING_THRESHOLD[1]}` IOWAIT_WARNING_THRESHOLD=`echo ${TAB_WARNING_THRESHOLD[2]}` fi # List to Table for critical threshold TAB_CRITICAL_THRESHOLD=( `echo $LIST_CRITICAL_THRESHOLD | sed 's/,/ /g'` ) if [ "${#TAB_CRITICAL_THRESHOLD[@]}" -ne "3" ]; then echo "ERROR : Bad count parameter in CRITICAL Threshold" exit $STATE_WARNING else USER_CRITICAL_THRESHOLD=`echo ${TAB_CRITICAL_THRESHOLD[0]}` SYSTEM_CRITICAL_THRESHOLD=`echo ${TAB_CRITICAL_THRESHOLD[1]}` IOWAIT_CRITICAL_THRESHOLD=`echo ${TAB_CRITICAL_THRESHOLD[2]}` fi if [ ${TAB_WARNING_THRESHOLD[0]} -ge ${TAB_CRITICAL_THRESHOLD[0]} -o ${TAB_WARNING_THRESHOLD[1]} -ge ${TAB_CRITICAL_THRESHOLD[1]} -o ${TAB_WARNING_THRESHOLD[2]} -ge ${TAB_CRITICAL_THRESHOLD[2]} ]; then echo "ERROR : Critical CPU Threshold lower as Warning CPU Threshold " exit $STATE_WARNING fi # ----------------------------------------------------------------------------------------- # CPU Utilization Statistics Unix Plateform ( Linux,AIX,Solaris are supported ) case `uname` in Linux ) CPU_REPORT=`iostat -c $INTERVAL_SEC $NUM_REPORT | sed -e 's/,/./g' | tr -s ' ' ';' | sed '/^$/d' | tail -1` CPU_REPORT_SECTIONS=`echo ${CPU_REPORT} | grep ';' -o | wc -l` CPU_USER=`echo $CPU_REPORT | cut -d ";" -f 2` CPU_NICE=`echo $CPU_REPORT | cut -d ";" -f 3` CPU_SYSTEM=`echo $CPU_REPORT | cut -d ";" -f 4` CPU_IOWAIT=`echo $CPU_REPORT | cut -d ";" -f 5` if [ ${CPU_REPORT_SECTIONS} -ge 6 ]; then CPU_STEAL=`echo $CPU_REPORT | cut -d ";" -f 6` CPU_IDLE=`echo $CPU_REPORT | cut -d ";" -f 7` NAGIOS_DATA="user=${CPU_USER}% system=${CPU_SYSTEM}%, iowait=${CPU_IOWAIT}%, idle=${CPU_IDLE}%, nice=${CPU_NICE}%, steal=${CPU_STEAL}% | CpuUser=${CPU_USER}%;${TAB_WARNING_THRESHOLD[0]};${TAB_CRITICAL_THRESHOLD[0]};0; CpuSystem=${CPU_SYSTEM}%;${TAB_WARNING_THRESHOLD[1]};${TAB_CRITICAL_THRESHOLD[1]};0; CpuIowait=${CPU_IOWAIT}%;${TAB_WARNING_THRESHOLD[2]};${TAB_CRITICAL_THRESHOLD[2]};0; CpuIdle=${CPU_IDLE}%;0;0;0; CpuNice=${CPU_NICE}%;0;0;0; CpuSteal=${CPU_STEAL}%;0;0;0;" else CPU_IDLE=`echo $CPU_REPORT | cut -d ";" -f 6` NAGIOS_DATA="user=${CPU_USER}% system=${CPU_SYSTEM}%, iowait=${CPU_IOWAIT}%, idle=${CPU_IDLE}%, nice=${CPU_NICE}%, steal=0.00% | CpuUser=${CPU_USER}%;${TAB_WARNING_THRESHOLD[0]};${TAB_CRITICAL_THRESHOLD[0]};0; CpuSystem=${CPU_SYSTEM}%;${TAB_WARNING_THRESHOLD[1]};${TAB_CRITICAL_THRESHOLD[1]};0; CpuIowait=${CPU_IOWAIT}%;${TAB_WARNING_THRESHOLD[2]};${TAB_CRITICAL_THRESHOLD[2]};0; CpuIdle=${CPU_IDLE}%;0;0;0; CpuNice=${CPU_NICE}%;0;0;0; CpuSteal=0.0%;0;0;0;" fi # Bail out possible under certain situations if [[ ${#BAIL[*]} -gt 0 ]]; then BC_CPU=$(nproc) o=0 while [ ${o} -lt ${#BAIL[*]} ]; do BAIL_CPU[${o}]=$(echo "${BAIL[${o}]}" | awk -F',' '{print $1}') BAIL_PROCESS[${o}]=$(echo "${BAIL[${o}]}" | awk -F',' '{print $2}') BC_PROCESS=$(ps aux | grep "${BAIL_PROCESS[${o}]}" | egrep -v "(grep|check_cpu_stats)" | awk '{print $2}') if [[ ${BAIL_CPU[${o}]} -eq ${BC_CPU} && ${BC_PROCESS} -gt 0 ]]; then echo "CPU STATISTICS OK - bailing out because of matched bailout patterns - ${NAGIOS_DATA}" exit $STATE_OK fi let o++ done fi ;; AIX ) CPU_REPORT=`iostat -t $INTERVAL_SEC $NUM_REPORT | sed -e 's/,/./g'|tr -s ' ' ';' | tail -1` CPU_USER=`echo $CPU_REPORT | cut -d ";" -f 4` CPU_SYSTEM=`echo $CPU_REPORT | cut -d ";" -f 5` CPU_IOWAIT=`echo $CPU_REPORT | cut -d ";" -f 7` CPU_IDLE=`echo $CPU_REPORT | cut -d ";" -f 6` NAGIOS_DATA="user=${CPU_USER}% system=${CPU_SYSTEM}%, iowait=${CPU_IOWAIT}%, idle=${CPU_IDLE}%, nice=0.00%, steal=0.00% | CpuUser=${CPU_USER}%;${TAB_WARNING_THRESHOLD[0]};${TAB_CRITICAL_THRESHOLD[0]};0; CpuSystem=${CPU_SYSTEM}%;${TAB_WARNING_THRESHOLD[1]};${TAB_CRITICAL_THRESHOLD[1]};0; CpuIowait=${CPU_IOWAIT}%;${TAB_WARNING_THRESHOLD[2]};${TAB_CRITICAL_THRESHOLD[2]};0; CpuIdle=${CPU_IDLE}%;0;0;0; CpuNice=0.0%;0;0;0; CpuSteal=0.0%;0;0;0;" ;; SunOS ) CPU_REPORT=`iostat -c $INTERVAL_SEC $NUM_REPORT | tail -1` CPU_USER=`echo $CPU_REPORT | awk '{ print $1 }'` CPU_SYSTEM=`echo $CPU_REPORT | awk '{ print $2 }'` CPU_IOWAIT=`echo $CPU_REPORT | awk '{ print $3 }'` CPU_IDLE=`echo $CPU_REPORT | awk '{ print $4 }'` NAGIOS_DATA="user=${CPU_USER}% system=${CPU_SYSTEM}%, iowait=${CPU_IOWAIT}%, idle=${CPU_IDLE}%, nice=0.00%, steal=0.00% | CpuUser=${CPU_USER}%;${TAB_WARNING_THRESHOLD[0]};${TAB_CRITICAL_THRESHOLD[0]};0; CpuSystem=${CPU_SYSTEM}%;${TAB_WARNING_THRESHOLD[1]};${TAB_CRITICAL_THRESHOLD[1]};0; CpuIowait=${CPU_IOWAIT}%;${TAB_WARNING_THRESHOLD[2]};${TAB_CRITICAL_THRESHOLD[2]};0; CpuIdle=${CPU_IDLE}%;0;0;0; CpuNice=0.0%;0;0;0; CpuSteal=0.0%;0;0;0;" ;; HP-UX) CPU_REPORT=`$SAR $INTERVAL_SEC $NUM_REPORT | grep Average` CPU_USER=`echo $CPU_REPORT | awk '{ print $2 }'` CPU_SYSTEM=`echo $CPU_REPORT | awk '{ print $3 }'` CPU_IOWAIT=`echo $CPU_REPORT | awk '{ print $4 }'` CPU_IDLE=`echo $CPU_REPORT | awk '{ print $5 }'` NAGIOS_DATA="user=${CPU_USER}% system=${CPU_SYSTEM}% iowait=${CPU_IOWAIT}% idle=${CPU_IDLE}% nice=0.00% steal=0.00% | CpuUser=${CPU_USER}%;${TAB_WARNING_THRESHOLD[0]};${TAB_CRITICAL_THRESHOLD[0]};0; CpuSystem=${CPU_SYSTEM}%;${TAB_WARNING_THRESHOLD[1]};${TAB_CRITICAL_THRESHOLD[1]};0; CpuIowait=${CPU_IOWAIT};${TAB_WARNING_THRESHOLD[2]};${TAB_CRITICAL_THRESHOLD[2]};0; CpuIdle=${CPU_IDLE}%;0;0;0; CpuNice=0.0%;0;0;0; CpuSteal=0.0%;0;0;0;" ;; # MacOS X test # Darwin ) CPU_REPORT=`iostat -w $INTERVAL_SEC -c $NUM_REPORT | tail -1` # CPU_USER=`echo $CPU_REPORT | awk '{ print $4 }'` # CPU_SYSTEM=`echo $CPU_REPORT | awk '{ print $5 }'` # CPU_IDLE=`echo $CPU_REPORT | awk '{ print $6 }'` # NAGIOS_DATA="user=${CPU_USER}% system=${CPU_SYSTEM}% iowait=0.00% idle=${CPU_IDLE}% nice=0.00% steal=0.00% | CpuUser=${CPU_USER}%;${TAB_WARNING_THRESHOLD[0]};${TAB_CRITICAL_THRESHOLD[0]};0; CpuSystem=${CPU_SYSTEM}%;${TAB_WARNING_THRESHOLD[1]};${TAB_CRITICAL_THRESHOLD[1]};0; CpuIowait=0.0%;0;0;0; CpuIdle=${CPU_IDLE}%;0;0;0; CpuNice=0.0%;0;0;0; CpuSteal=0.0%;0;0;0;" # ;; *) echo "UNKNOWN: `uname` not yet supported by this plugin. Coming soon !" exit $STATE_UNKNOWN ;; esac # ----------------------------------------------------------------------------------------- # Add for integer shell issue CPU_USER_MAJOR=`echo $CPU_USER| cut -d "." -f 1` CPU_SYSTEM_MAJOR=`echo $CPU_SYSTEM | cut -d "." -f 1` CPU_IOWAIT_MAJOR=`echo $CPU_IOWAIT | cut -d "." -f 1` CPU_IDLE_MAJOR=`echo $CPU_IDLE | cut -d "." -f 1` # ----------------------------------------------------------------------------------------- # Return if [ ${CPU_USER_MAJOR} -ge $USER_CRITICAL_THRESHOLD ]; then echo "CPU STATISTICS CRITICAL : ${NAGIOS_DATA}" exit $STATE_CRITICAL elif [ ${CPU_SYSTEM_MAJOR} -ge $SYSTEM_CRITICAL_THRESHOLD ]; then echo "CPU STATISTICS CRITICAL : ${NAGIOS_DATA}" exit $STATE_CRITICAL elif [ ${CPU_IOWAIT_MAJOR} -ge $IOWAIT_CRITICAL_THRESHOLD ]; then echo "CPU STATISTICS CRITICAL : ${NAGIOS_DATA}" exit $STATE_CRITICAL elif [ ${CPU_USER_MAJOR} -ge $USER_WARNING_THRESHOLD ] && [ ${CPU_USER_MAJOR} -lt $USER_CRITICAL_THRESHOLD ]; then echo "CPU STATISTICS WARNING : ${NAGIOS_DATA}" exit $STATE_WARNING elif [ ${CPU_SYSTEM_MAJOR} -ge $SYSTEM_WARNING_THRESHOLD ] && [ ${CPU_SYSTEM_MAJOR} -lt $SYSTEM_CRITICAL_THRESHOLD ]; then echo "CPU STATISTICS WARNING : ${NAGIOS_DATA}" exit $STATE_WARNING elif [ ${CPU_IOWAIT_MAJOR} -ge $IOWAIT_WARNING_THRESHOLD ] && [ ${CPU_IOWAIT_MAJOR} -lt $IOWAIT_CRITICAL_THRESHOLD ]; then echo "CPU STATISTICS WARNING : ${NAGIOS_DATA}" exit $STATE_WARNING else echo "CPU STATISTICS OK : ${NAGIOS_DATA}" exit $STATE_OK fi echo "CPU STATISTICS UNKNOWN: Should never reach this." exit $STATE_UNKNOWN
Notes supervision check_mk
Voir :
Voir aussi : Nagios, Centreon, Shinken
Note : si vous n'avez pas encore choisi de solution de supervision, Pensez à regarder Zabbix.
Install de check_mk sur Debian
apt-get install xinetd check-mk-agent
n'oublier pas de modifier la ligne disable = yes /etc/xinetd.d/check_mk
service check_mk
{
type = UNLISTED
port = 6556
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/check_mk_agent
# If you use fully redundant monitoring and poll the client
# from more then one monitoring servers in parallel you might
# want to use the agent cache wrapper:
#server = /usr/bin/check_mk_caching_agent
# configure the IP address(es) of your Nagios server here:
#only_from = 127.0.0.1 10.0.20.1 10.0.20.2
# Don't be too verbose. Don't log every check. This might be
# commented out for debugging. If this option is commented out
# the default options will be used for this service.
log_on_success =
#disable = yes
disable = no
}
systemctl restart xinetd
lsof -i TCP:6556 nc 127.0.0.1 6556
Notes supervision - plugin Nagios - centreon_plugins.pl
Voir :
Voir aussi :
Configure those extra SNMP options in the host/host template configuration in the SNMPEXTRAOPTIONS macro.
| snmpwalk | centreon-plugins |
|---|---|
| -a | --authprotocol |
| -A | --authpassphrase |
| -u | --snmp-username |
| -x | --privprotocol |
| -X | --privpassphrase |
| -l | not needed (automatic) |
| -e | --securityengineid |
| -E | --contextengineid |
On lance une fois cpan pour le configurer
cpan # On ferme la session puis on la reouvre pour sourcer le .bashrc exit # Ou source ~/.bashrc
cpan common/sense.pm cpan Types/Serialiser.pm cpan JSON # Pour la commande net-snmp-config necessaire à cpan SNMP #sudo apt-get install libsnmp-dev #sudo yum install net-snmp-devel cpan SNMP
Le plugin a besoin de pouvoir écrire
mkdir -p /var/lib/centreon/centplugins chown nagios: /var/lib/centreon/ /var/lib/centreon/centplugins/ chmod 1777 /var/lib/centreon/centplugins/
./centreon_plugins.pl --list-plugin ./centreon_plugins.pl --list-plugin | grep ^PLUGIN | grep -i snmp | grep -i linux ./centreon_plugins.pl --plugin os::linux::snmp::plugin ./centreon_plugins.pl --plugin os::linux::snmp::plugin --help ./centreon_plugins.pl --plugin os::linux::snmp::plugin --list-mode ./centreon_plugins.pl --plugin os::linux::snmp::plugin --memory ./centreon_plugins.pl --plugin os::linux::snmp::plugin --mode memory ./centreon_plugins.pl --plugin os::linux::snmp::plugin --mode memory --hostname localhost ./centreon_plugins.pl --plugin os::linux::snmp::plugin --mode memory --hostname localhost --help
./centreon_plugins.pl --plugin os::linux::snmp::plugin --mode memory --hostname localhost --snmp-version='3' --authpassphrase P@ssw0rd --snmp-username nagios --authprotocol MD5 OK: Ram Total: 15.25 GB Used (-buffers/cache): 1.95 GB (12.81%) Free: 13.30 GB (87.19%), Buffer: 94.79 MB, Cached: 2.05 GB, Shared: 555.96 MB | 'used'=2097471488B;;;0;16376958976 'free'=14279487488B;;;0;16376958976 'used_prct'=12.81%;;;0;100 'buffer'=99397632B;;;0; 'cached'=2202296320B;;;0; 'shared'=582967296B;;;0;
Exemple avec Fortigate
src/centreon_plugins.pl --plugin=network::fortinet::fortigate::snmp::plugin --mode=cluster-status --hostname=firewall --snmp-version='2c' --snmp-community='public' --warning-status='%{role} !~ /master|slave/' --critical-status='%{sync_status} !~ /^synchronized/' --opt-exit warning --verbose --critical-total-nodes=2
Note : Pour certain plugin il est important d'écrire --hostname=localhost et non --hostname localhost, de même pour les autres arguments
Exemple conf Nagios
commands.cfg
define command{ command_name check_centreon_snmp_linux_disk_all command_line $USER1$/centreon_plugins --plugin=os::linux::snmp::plugin --mode=storage --hostname=$HOSTADDRESS$ --snmp-version=3 --snmp-username "$USER6$" --authprotocol MD5 --authpassphrase "$USER7$" --filter-storage-type=hrStorageFixedDisk --add-access --critical-access=readOnly --warning-usage $ARG1$ --critical-usage $ARG2$ --name --regexp --storage='^((?!cdrom).)*$' }
mode multi
./centreon_plugins.pl --plugin=os::linux::snmp::plugin --hostname=localhost --snmp-version=3 --snmp-username "nagios" --authprotocol MD5 --authpassphrase "P@ssw0rd" --mode multi --modes-exec 'uptime,memory,swap,cpu'
Wrapper en bash
Dans notre cas les plugins sont tous dans /usr/local/nagios/libexec/ mais si on fait un lien symbolique ln -s /usr/local/nagios/libexec/centreon-plugins-develop/src/centreon_plugins /usr/local/nagios/libexec/ ça ne fonctionne pas.
D'où ce petit wrapper.
centreon_plugins
#! /bin/bash set -euo pipefail SCRIPT_DIR=$(readlink -m "$(dirname "$0")") cd "${SCRIPT_DIR}/centreon-plugins-develop/src/" || exit 2 export PERL5LIB="/usr/local/nagios/lib/perl5/site_perl/5.8.8:/usr/local/nagios/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi" exec perl ./centreon_plugins.pl "$@"
Il faut aussi les dépendances suivantes
yum install perl net-snmp-utils net-snmp-perl
Conf pour Centreon
Exemple :
$CENTREONPLUGINS$/centreon_plugins --plugin=network::fortinet::fortigate::snmp::plugin --hostname=$HOSTADDRESS$ --snmp-version='$_HOSTSNMPVERSION$' --snmp-community='$_HOSTSNMPCOMMUNITY$' --mode=cluster-status --warning-status='%{role} !~ /master|slave/' --critical-status='%{sync_status} !~ /^synchronized/' --opt-exit warning --critical-total-nodes=2 $_HOSTSNMPEXTRAOPTIONS$
Autres plugins Centreon similaires
$ rpm -qf /usr/lib/centreon/plugins/centreon_linux_snmp.pl centreon-plugin-Operatingsystems-Linux-Snmp-20241107-152627.el8.noarch
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=memory --hostname=127.0.0.1 --snmp-version=3 --snmp-username=nagios --authprotocol=MD5 --authpassphrase='P@ssw0rd' --warning-usage=80 --critical-usage=90
Autres
ILO
/usr/lib/centreon/plugins/centreon_hp_ilo_restapi.pl --plugin=hardware::server::hp::ilo::restapi::plugin --mode=hardware --hostname='192.168.1.101' --api-username='sup_ro' --api-password='P@ssw0rd12345678' --component='.*' --verbose --insecure
Centreon plugins - old
http://sugarbug.web4me.fr/atelier/techniques/plugins/plugins_centreon/
yum install git git clone https://github.com/centreon/centreon-plugins.git cd centreon-plugins/ chmod +x centreon_plugins.pl cp -R * /usr/lib/centreon/plugins/
Test centreon_plugins.pl
/usr/lib/centreon/plugins/centreon_plugins.pl --version /usr/lib/centreon/plugins/centreon_plugins.pl --list-plugin /usr/lib/centreon/plugins/centreon_plugins.pl --plugin=os::linux::snmp::plugin --list-mode /usr/lib/centreon/plugins/centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=load --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose
/usr/lib/nagios/plugins/centreon_plugins.pl --list-plugin /usr/lib/nagios/plugins/centreon_plugins.pl --plugin=apps::pacemaker::local::plugin --help /usr/lib/nagios/plugins/centreon_plugins.pl --plugin=apps::pacemaker::local::plugin --list-mode /usr/lib/nagios/plugins/centreon_plugins.pl --plugin=apps::pacemaker::local::plugin --mode crm --help /usr/lib/nagios/plugins/centreon_plugins.pl --plugin=apps::pacemaker::local::plugin --mode crm --remote --hostname 192.168.10.3
Dell OpenManage
wget http://folk.uio.no/trondham/software/check_openmanage-3.7.12/check_openmanage cd /usr/lib/nagios/plugins/ chown centreon:centreon-engine /usr/lib/nagios/plugins/check_openmanage chmod 755 /usr/lib/nagios/plugins/check_openmanage
Test
# /usr/lib/nagios/plugins/check_openmanage -H 10.245.108.2 OK - System: 'PowerEdge R430', SN: '58RJZG2', 32 GB ram (2 dimms), 1 logical drives, 2 physical drives
Configuration Commands Checks check Command line :
$USER1$/check_openmanage -H $HOSTADDRESS$ -p $_HOSTSNMPVERSION$ -C $_HOSTSNMPCOMMUNITY$ '$_HOSTOPENMANAGE_OPTIONS$'
Configuration Services Templates Dell_OMSA Max Check Attempts : 5 Normal Check Interval : 5 Retry Check Interval: 5 Check Period : 24×7 Check Command : check_openmanage Relation / Linked to host templates / Selected “Servers-Dell-OMSA”
Configuration Hosts Templates “Servers-Dell-OMSA” Relation / Linked Service Templates / Selected “Dell_OMSA”
SNMP plugin
/usr/lib/centreon/plugins/centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=memory --hostname=$HOSTADDRESS$ --snmp-version=2c --snmp-community=public /usr/lib/centreon/plugins/centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=storage --hostname=$HOSTADDRESS$ --snmp-version='$_HOSTSNMPVERSION$' --snmp-community='$_HOSTSNMPCOMMUNITY$' $_HOSTSNMPEXTRAOPTIONS$ --storage='$_SERVICEFILTER$' --name --regexp --display-transform-src='$_SERVICETRANSFORMSRC$' --display-transform-dst='$_SERVICETRANSFORMDST$' --warning='$_SERVICEWARNING$' --critical='$_SERVICECRITICAL$' $_SERVICEEXTRAOPTIONS$ /usr/lib/centreon/plugins/centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=storage --hostname=172.19.0.1 --snmp-version=2c --snmp-community=public --verbose --storage='.*' --name --regexp --display-transform-src='' --display-transform-dst='' --warning=80 --critical=90 $_SERVICEEXTRAOPTIONS$
$ /usr/lib/nagios/plugins/check_centreon_snmp_remote_storage -H 10.245.108.2 -s hrStorage 1 :: Physical memory hrStorage 3 :: Virtual memory hrStorage 6 :: Memory buffers hrStorage 7 :: Cached memory hrStorage 8 :: Shared memory hrStorage 10 :: Swap space hrStorage 33 :: /dev hrStorage 36 :: /sys/fs/cgroup hrStorage 49 :: /etc/resolv.conf hrStorage 50 :: /etc/hostname hrStorage 51 :: /etc/hosts hrStorage 52 :: /dev/shm hrStorage 53 :: /run/secrets hrStorage 54 :: /usr/lib/modules/3.10.0-862.3.2.el7.x86_64 $ /usr/lib/nagios/plugins/check_centreon_snmp_remote_storage -H 10.245.108.2 -d 10 Disk OK - Swap space TOTAL: 20.000GB USED: 0.003GB (0%) FREE: 19.997GB (100%)|size=21474832384B used=3145728B;19327349145;20401090764;0;21474832384
Pb
Le plugin Centreon pour Stormshield n'est compatible que en MD5|SHA
source : https://docs.centreon.com/pp/integrations/plugin-packs/procedures/network-stormshield-snmp/
SNMP v3 only: Authentication protocol: MD5|SHA. Since net-snmp 5.9.1: SHA224|SHA256|SHA384|SHA512.
Hors AlmaLinux release 8.10 (Cerulean Leopard) n'est pas compatible net-snmp 5.9.1. J'ai essayé de bidouiller et même de compiler net-snmp mais ça ne fonctionne pas. Il faut soit utiliser MD5/SHA1, soit passer à AlmaLinux 9, soit utiliser la commande snmpwalk/snmpget.
Err undefined symbol: Perl_Gthr_key_ptr
$ env PERL5LIB="/usr/local/nagios/lib/perl5/site_perl/5.8.8:/usr/local/nagios/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi" ./centreon_plugins.pl
/usr/bin/perl: symbol lookup error: /usr/local/nagios/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/JSON/XS/XS.so: undefined symbol: Perl_Gthr_key_ptr
$ readelf -s /usr/local/nagios/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/JSON/XS/XS.so | grep Perl_Gthr_key_ptr
92: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND Perl_Gthr_key_ptr
196: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND Perl_Gthr_key_ptr
$ ./centreon_plugins.pl
UNKNOWN: Need to specify '--plugin' option.
Voir Can't locate JSON/XS.pm in @INC
Err - Can't locate JSON/XS.pm in @INC
$ ./centreon_plugins --plugin=network::fortinet::fortigate::snmp::plugin --hostname=$HOSTADDRESS$ --snmp-version=3 --snmp-user14:09:26 [37/453$thprotocol MD5 --authpassphrase "$USER4$" --mode=cluster-status --warning-status='%{role} !~ /master|slave/' --critical-status='%{sync_status} !~ /^synchronized/' --opt-exit warning --critical-total-nodes=2
Can't locate JSON/XS.pm in @INC (@INC contains: /usr/local/nagios/libexec/centreon-plugins-develop/src /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/nagios/libexec/centreon-plugins-develop/src/centreon/plugins/misc.pm line 26.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/centreon-plugins-develop/src/centreon/plugins/misc.pm line 26.
Compilation failed in require at /usr/local/nagios/libexec/centreon-plugins-develop/src/centreon/plugins/output.pm line 25.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/centreon-plugins-develop/src/centreon/plugins/output.pm line 25.
Compilation failed in require at /usr/local/nagios/libexec/centreon-plugins-develop/src/centreon/plugins/script.pm line 25.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/centreon-plugins-develop/src/centreon/plugins/script.pm line 25.
Compilation failed in require at ./centreon_plugins.pl line 29. BEGIN failed--compilation aborted at ./centreon_plugins.pl line 29
Solution :
yum install perl net-snmp-utils net-snmp-perl
et définir correctement PERL5LIB
