Premier commit
This commit is contained in:
152
roles/nagios/README.md
Normal file
152
roles/nagios/README.md
Normal file
@ -0,0 +1,152 @@
|
||||
# Rôle nagios
|
||||
***
|
||||
Rôle Nagios pour la supervision des différentes machines
|
||||
|
||||
## Tables des matières
|
||||
1. [Que fait le rôle Nagios ?]
|
||||
2. [NSClient++]
|
||||
|
||||
|
||||
## Que fait le rôle Nagios ?
|
||||
|
||||
|
||||
### Installation et configuration de Nagios4
|
||||
|
||||
Le rôle Nagios va installer apache2 pour le serveur web, snmp pour la supervision, nagios4 qui sera notre outil de supervision, les plugins de nagios4.
|
||||
|
||||
On copie les fichiers pour apache, les commandes de nagios, le fichiers des groupes de machines pour la supervision, le fichier des différents services à superviser, on autorise ensuite l'authentification et on définit le mot de passe.
|
||||
|
||||
Pour l'id de Nagios, c'est "nagiosadmin", à l'adresse "https://s-mon/nagios4".
|
||||
|
||||
```
|
||||
|
||||
new password: nimda
|
||||
Retype password: nimda
|
||||
|
||||
```
|
||||
|
||||
On définit par la suite l'adresse mail de contact pour les notifications par mail, on copie tous les fichiers cfg des machines.
|
||||
|
||||
|
||||
|
||||
Il faut désormais installer NSClient++ sur la machine s-win pour permettre la supervision des différents services.
|
||||
Veuillez suivre le tutoriel suivant:
|
||||
|
||||
|
||||
## Installation de NSClient++ sur la machine s-win
|
||||
|
||||
En premier lieu, installer Mozilla Firefox via Internet Explorer.
|
||||
|
||||
Une fois Mozilla intallé, installer NSClient++ avec ce lien: [NSClient++](https://nsclient.org/download/)
|
||||
|
||||
Puis choisir la version Windows
|
||||
|
||||
### Etapes de l'installation
|
||||
|
||||
Sur l'étape **Select monitoring tool**, sélectionner **Generic**.
|
||||
|
||||
Sur l'étape **Choose setup type**, sélectionner **Typical**.
|
||||
|
||||
Sur l'étape **NSClient++ Configuration:
|
||||
|
||||
```
|
||||
|
||||
Allowed hosts: 172.16.0.8
|
||||
|
||||
Password: root
|
||||
|
||||
```
|
||||
|
||||
Activer **check plugins, check_nt et check_nrpe**.
|
||||
|
||||
**Laisser NSCA client et web server désactivé**
|
||||
|
||||
Cocher la case **Insecure legacy mode**
|
||||
|
||||
|
||||
Terminer l'installation.
|
||||
|
||||
### Modification des fichiers
|
||||
|
||||
Rendez vous dans le répertoire **C:\Programmes\NSClient++** puis ouvrez le fichier **nsclient.ini** (celui avec un rouage).
|
||||
|
||||
Une fois ouvert, modifier tout le fichier avec ceci:
|
||||
|
||||
```
|
||||
|
||||
#If you want to fill this file with all available options run the following command:
|
||||
#nscp settings --generate --add-defaults --load-all
|
||||
#If you want to activate a module and bring in all its options use:
|
||||
#nscp settings --activate-module <MODULE NAME> --add-defaults
|
||||
#For details run: nscp settings --help
|
||||
|
||||
|
||||
; in flight - TODO
|
||||
[/settings/default]
|
||||
|
||||
; Undocumented key
|
||||
password = root
|
||||
|
||||
; Undocumented key
|
||||
allowed hosts = 172.16.0.8
|
||||
|
||||
|
||||
; in flight - TODO
|
||||
[/settings/NRPE/server]
|
||||
|
||||
; Undocumented key
|
||||
verify mode = none
|
||||
|
||||
; Undocumented key
|
||||
insecure = true
|
||||
|
||||
|
||||
; in flight - TODO
|
||||
[/modules]
|
||||
|
||||
; Undocumented key
|
||||
CheckExternalScripts = enabled
|
||||
|
||||
; Undocumented key
|
||||
CheckHelpers = enabled
|
||||
|
||||
; Undocumented key
|
||||
CheckEventLog = enabled
|
||||
|
||||
; Undocumented key
|
||||
CheckNSCP = enabled
|
||||
|
||||
; Undocumented key
|
||||
CheckDisk = enabled
|
||||
|
||||
; Undocumented key
|
||||
CheckSystem = enabled
|
||||
|
||||
; Undocumented key
|
||||
NSClientServer = enabled
|
||||
|
||||
; Undocumented key
|
||||
NRPEServer = enabled
|
||||
|
||||
```
|
||||
|
||||
Redémarrez le service NSClient++ via le **cmd**:
|
||||
|
||||
```
|
||||
|
||||
services.msc
|
||||
|
||||
```
|
||||
|
||||
Puis clique droit sur le service **NCLient++ Monitoring Agent** et appuyer sur **Redémarrer**
|
||||
|
||||
|
||||
Retourner sur le serveur nagios puis écrire:
|
||||
|
||||
```
|
||||
|
||||
systemctl restart nagios4
|
||||
|
||||
```
|
||||
|
||||
Les services de la machine **srv-2012** apparaissent en **OK**.
|
159
roles/nagios/files/cfg/localhost.cfg
Normal file
159
roles/nagios/files/cfg/localhost.cfg
Normal file
@ -0,0 +1,159 @@
|
||||
###############################################################################
|
||||
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
|
||||
#
|
||||
#
|
||||
# NOTE: This config file is intended to serve as an *extremely* simple
|
||||
# example of how you can create configuration entries to monitor
|
||||
# the local (Linux) machine.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# HOST DEFINITION
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Define a host for the local machine
|
||||
|
||||
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 localhost
|
||||
alias localhost
|
||||
address 127.0.0.1
|
||||
}
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# HOST GROUP DEFINITION
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Define an optional hostgroup for Linux machines
|
||||
|
||||
define hostgroup {
|
||||
|
||||
hostgroup_name linux-servers ; The name of the hostgroup
|
||||
alias Linux Servers ; Long name of the group
|
||||
members localhost ; Comma separated list of hosts that belong to this group
|
||||
}
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# SERVICE DEFINITIONS
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Define a service to "ping" the local machine
|
||||
|
||||
define service {
|
||||
|
||||
use local-service ; Name of service template to use
|
||||
host_name localhost
|
||||
service_description PING
|
||||
check_command check_ping!100.0,20%!500.0,60%
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Define a service to check the disk space of the root partition
|
||||
# on the local machine. Warning if < 20% free, critical if
|
||||
# < 10% free space on partition.
|
||||
|
||||
define service {
|
||||
|
||||
use local-service ; Name of service template to use
|
||||
host_name localhost
|
||||
service_description Root Partition
|
||||
check_command check_local_disk!20%!10%!/
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Define a service to check the number of currently logged in
|
||||
# users on the local machine. Warning if > 20 users, critical
|
||||
# if > 50 users.
|
||||
|
||||
define service {
|
||||
|
||||
use local-service ; Name of service template to use
|
||||
host_name localhost
|
||||
service_description Current Users
|
||||
check_command check_local_users!20!50
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Define a service to check the number of currently running procs
|
||||
# on the local machine. Warning if > 250 processes, critical if
|
||||
# > 400 processes.
|
||||
|
||||
define service {
|
||||
|
||||
use local-service ; Name of service template to use
|
||||
host_name localhost
|
||||
service_description Total Processes
|
||||
check_command check_local_procs!250!400!RSZDT
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Define a service to check the load on the local machine.
|
||||
|
||||
define service {
|
||||
|
||||
use local-service ; Name of service template to use
|
||||
host_name localhost
|
||||
service_description Current Load
|
||||
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Define a service to check the swap usage the local machine.
|
||||
# Critical if less than 10% of swap is free, warning if less than 20% is free
|
||||
|
||||
define service {
|
||||
|
||||
use local-service ; Name of service template to use
|
||||
host_name localhost
|
||||
service_description Swap Usage
|
||||
check_command check_local_swap!20%!10%
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Define a service to check SSH on the local machine.
|
||||
# Disable notifications for this service by default, as not all users may have SSH enabled.
|
||||
|
||||
define service {
|
||||
|
||||
use local-service ; Name of service template to use
|
||||
host_name localhost
|
||||
service_description SSH
|
||||
check_command check_ssh
|
||||
notifications_enabled 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Define a service to check HTTP on the local machine.
|
||||
# Disable notifications for this service by default, as not all users may have HTTP enabled.
|
||||
|
||||
define service {
|
||||
|
||||
use local-service ; Name of service template to use
|
||||
host_name localhost
|
||||
service_description HTTP
|
||||
check_command check_http
|
||||
notifications_enabled 0
|
||||
}
|
15
roles/nagios/files/cfg/r-ext.cfg
Normal file
15
roles/nagios/files/cfg/r-ext.cfg
Normal file
@ -0,0 +1,15 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name r-ext
|
||||
alias serveur proxy
|
||||
address 192.168.200.253
|
||||
parents r-int
|
||||
}
|
||||
|
||||
|
14
roles/nagios/files/cfg/r-int.cfg
Normal file
14
roles/nagios/files/cfg/r-int.cfg
Normal file
@ -0,0 +1,14 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name r-int
|
||||
alias serveur proxy
|
||||
address 172.16.0.254
|
||||
}
|
||||
|
||||
|
13
roles/nagios/files/cfg/s-adm.cfg
Normal file
13
roles/nagios/files/cfg/s-adm.cfg
Normal file
@ -0,0 +1,13 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-adm
|
||||
alias debian-servers
|
||||
address 192.168.99.99
|
||||
}
|
||||
|
13
roles/nagios/files/cfg/s-appli.cfg
Normal file
13
roles/nagios/files/cfg/s-appli.cfg
Normal file
@ -0,0 +1,13 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-appli
|
||||
alias debian-servers
|
||||
address 172.16.0.3
|
||||
}
|
||||
|
13
roles/nagios/files/cfg/s-backup.cfg
Normal file
13
roles/nagios/files/cfg/s-backup.cfg
Normal file
@ -0,0 +1,13 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-backup
|
||||
alias serveur proxy
|
||||
address 172.16.0.4
|
||||
}
|
||||
|
14
roles/nagios/files/cfg/s-fog.cfg
Normal file
14
roles/nagios/files/cfg/s-fog.cfg
Normal file
@ -0,0 +1,14 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-fog
|
||||
alias serveur proxy
|
||||
address 172.16.0.16
|
||||
}
|
||||
|
||||
|
13
roles/nagios/files/cfg/s-infra.cfg
Normal file
13
roles/nagios/files/cfg/s-infra.cfg
Normal file
@ -0,0 +1,13 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-infra
|
||||
alias debian-servers
|
||||
address 172.16.0.1
|
||||
}
|
||||
|
14
roles/nagios/files/cfg/s-itil.cfg
Normal file
14
roles/nagios/files/cfg/s-itil.cfg
Normal file
@ -0,0 +1,14 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-itil
|
||||
alias serveur proxy
|
||||
address 172.16.0.9
|
||||
}
|
||||
|
||||
|
13
roles/nagios/files/cfg/s-nxc.cfg
Normal file
13
roles/nagios/files/cfg/s-nxc.cfg
Normal file
@ -0,0 +1,13 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-nxc
|
||||
alias debian-servers
|
||||
address 172.16.0.7
|
||||
}
|
||||
|
14
roles/nagios/files/cfg/s-proxy.cfg
Normal file
14
roles/nagios/files/cfg/s-proxy.cfg
Normal file
@ -0,0 +1,14 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-proxy
|
||||
alias serveur proxy
|
||||
address 172.16.0.2
|
||||
}
|
||||
|
||||
|
14
roles/nagios/files/cfg/s-win.cfg
Normal file
14
roles/nagios/files/cfg/s-win.cfg
Normal file
@ -0,0 +1,14 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define host{
|
||||
use linux-server ; Name of host template to use
|
||||
host_name s-win
|
||||
alias serveur proxy
|
||||
address 172.16.0.6
|
||||
}
|
||||
|
||||
|
151
roles/nagios/files/commands.cfg
Normal file
151
roles/nagios/files/commands.cfg
Normal file
@ -0,0 +1,151 @@
|
||||
###############################################################################
|
||||
# COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS
|
||||
###############################################################################
|
||||
|
||||
|
||||
################################################################################
|
||||
# NOTIFICATION COMMANDS
|
||||
################################################################################
|
||||
|
||||
|
||||
# 'notify-host-by-email' command definition
|
||||
define command{
|
||||
command_name notify-host-by-email
|
||||
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
|
||||
}
|
||||
|
||||
# 'notify-service-by-email' command definition
|
||||
define command{
|
||||
command_name notify-service-by-email
|
||||
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
# HOST CHECK COMMANDS
|
||||
################################################################################
|
||||
|
||||
# On Debian, check-host-alive is being defined from within the
|
||||
# nagios-plugins-basic package
|
||||
|
||||
define command {
|
||||
|
||||
command_name check_local_disk
|
||||
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
|
||||
}
|
||||
|
||||
|
||||
|
||||
define command {
|
||||
|
||||
command_name check_local_load
|
||||
command_line $USER1$/check_load -w $ARG1$ -c $ARG2$
|
||||
}
|
||||
|
||||
|
||||
|
||||
define command {
|
||||
|
||||
command_name check_local_procs
|
||||
command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
|
||||
}
|
||||
|
||||
|
||||
|
||||
define command {
|
||||
|
||||
command_name check_local_users
|
||||
command_line $USER1$/check_users -w $ARG1$ -c $ARG2$
|
||||
}
|
||||
|
||||
|
||||
|
||||
define command {
|
||||
|
||||
command_name check_local_swap
|
||||
command_line $USER1$/check_swap -w $ARG1$ -c $ARG2$
|
||||
}
|
||||
|
||||
|
||||
define command{
|
||||
command_name check_snmp_storage
|
||||
command_line $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ -C $ARG1$ $ARG2$ -m $ARG3$ -w $ARG4$ -c $ARG5$
|
||||
}
|
||||
|
||||
define command{
|
||||
command_name check_snmp_load
|
||||
command_line $USER1$/check_snmp_load.pl -H $HOSTADDRESS$ -C $ARG1$ $ARG2$ -T $ARG3$ -w $ARG4$ -c $ARG5$
|
||||
}
|
||||
|
||||
define command{
|
||||
command_name check_snmp_mem
|
||||
command_line $USER1$/check_snmp_mem.pl -H $HOSTADDRESS$ -C $ARG1$ $ARG2$ $ARG3$ -w $ARG4$ -c $ARG5$
|
||||
}
|
||||
|
||||
define command{
|
||||
command_name check_snmp_int
|
||||
command_line $USER1$/check_snmp_netint.pl -H $HOSTADDRESS$ -C $ARG1$ $ARG2$ -n $ARG3$ -a -m -k -M -w $ARG4$ -c $ARG5$
|
||||
}
|
||||
|
||||
define command{
|
||||
command_name check_iftraffic3
|
||||
#command_name check_win_int
|
||||
#command_line $USER1$/check_iftraffic3.pl -H $HOSTADDRESS$ -C $ARG1$
|
||||
#command_line $USER1$/check_snmp_int.pl -H $HOSTADDRESS$ -C $ARG1$ $ARG2$ -n $ARG3$ -k -M -g -w $ARG4$ -c $ARG5$
|
||||
command_line $USER1$/check_iftraffic3.pl -H $HOSTADDRESS$ -C $ARG1$ -i $ARG2$ -w $ARG3$ -c $ARG4$
|
||||
}
|
||||
|
||||
define command{
|
||||
command_name check_snmp
|
||||
command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
|
||||
}
|
||||
###############################
|
||||
##WINDOWS
|
||||
###############################
|
||||
|
||||
define command{
|
||||
command_name check_nt
|
||||
command_line $USER1$/check_nt -H $HOSTADDRESS$ -s root -p 12489 -v $ARG1$ $ARG2$
|
||||
}
|
||||
|
||||
define command{
|
||||
command_name check_dns_ext
|
||||
command_line $USER1$/check_dns -H google.com -s '$HOSTADDRESS$'
|
||||
}
|
||||
|
||||
#define command{
|
||||
# command_line check_dns_int
|
||||
# command_line $USER1*/check_dns -H s-infra.gsb.lan -s '$HOSTADDRESS$'
|
||||
#}
|
||||
|
||||
#define command{
|
||||
# command_line check_dhcp
|
||||
# command_line $USER1$/check_dhcp -H $HOSTADDRESS$ -s $ARG1$ -i $ARG2$
|
||||
#}
|
||||
|
||||
#define command{
|
||||
# command_name check_dig
|
||||
# command_line /usr/lib/nagios/plugins/check_dig -H '$HOSTADDRESS$' -l '$ARG1$'
|
||||
#}
|
||||
|
||||
|
||||
################################################################################
|
||||
# PERFORMANCE DATA COMMANDS
|
||||
################################################################################
|
||||
|
||||
|
||||
# 'process-host-perfdata' command definition
|
||||
define command{
|
||||
command_name process-host-perfdata
|
||||
command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /var/lib/nagios3/host-perfdata.out
|
||||
}
|
||||
|
||||
|
||||
# 'process-service-perfdata' command definition
|
||||
define command{
|
||||
command_name process-service-perfdata
|
||||
command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /var/lib/nagios3/service-perfdata.out
|
||||
}
|
30
roles/nagios/files/hostgroups.cfg
Normal file
30
roles/nagios/files/hostgroups.cfg
Normal file
@ -0,0 +1,30 @@
|
||||
define hostgroup {
|
||||
|
||||
hostgroup_name debian-servers ; The name of the hostgroup
|
||||
alias Linux Servers ; Long name of the group
|
||||
members s-infra, s-proxy, s-adm, s-nxc, s-appli, s-backup, s-itil, s-fog, r-int, r-ext ; Comma separated list of hosts that belong to this group
|
||||
}
|
||||
|
||||
define hostgroup {
|
||||
hostgroup_name windows-servers
|
||||
alias Serveurs Windows
|
||||
members s-win
|
||||
}
|
||||
|
||||
define hostgroup {
|
||||
hostgroup_name http-servers
|
||||
alias Serveurs web
|
||||
members s-itil
|
||||
}
|
||||
|
||||
define hostgroup {
|
||||
hostgroup_name dhcp-servers
|
||||
alias Serveurs DHCP
|
||||
members s-adm, r-int
|
||||
}
|
||||
|
||||
define hostgroup {
|
||||
hostgroup_name dns-servers
|
||||
alias Serveurs DNS
|
||||
members s-infra, s-backup
|
||||
}
|
23
roles/nagios/files/interfaces
Normal file
23
roles/nagios/files/interfaces
Normal file
@ -0,0 +1,23 @@
|
||||
# This file describes the network interfaces available on your system
|
||||
# and how to activate them. For more information, see interfaces(5).
|
||||
|
||||
source /etc/network/interfaces.d/*
|
||||
|
||||
# The loopback network interface
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
# The primary network interface
|
||||
allow-hotplug enp0s3
|
||||
iface enp0s3 inet static
|
||||
address 192.168.99.104/24
|
||||
gateway 192.168.99.99
|
||||
|
||||
# Cote n-infra
|
||||
allow-hotplug enp0s8
|
||||
iface enp0s8 inet static
|
||||
address 172.16.0.8/24
|
||||
up ip route add 172.16.64.0/24 via 172.16.0.254
|
||||
up ip route add 172.16.128.0/24 via 172.16.0.254
|
||||
up ip route add 192.168.0.0/16 via 172.16.0.254
|
||||
up ip route add 192.168.200.0/24 via 172.16.0.254
|
15
roles/nagios/files/nt.cfg
Normal file
15
roles/nagios/files/nt.cfg
Normal file
@ -0,0 +1,15 @@
|
||||
# If you are confused about this command definition, cause you was
|
||||
# reading other suggestions, please have a look into
|
||||
# /usr/share/doc/monitoring-plugins/README.Debian
|
||||
|
||||
# 'check_nt' command definition
|
||||
#define command {
|
||||
# command_name check_nt
|
||||
# command_line /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -v '$ARG1$'
|
||||
#}
|
||||
|
||||
# 'check_nscp' command definition
|
||||
define command {
|
||||
command_name check_nscp
|
||||
command_line /usr/lib/nagios/plugins/check_nt -H '$HOSTADDRESS$' -p 12489 -v '$ARG1$'
|
||||
}
|
2
roles/nagios/files/sasl_passwd
Normal file
2
roles/nagios/files/sasl_passwd
Normal file
@ -0,0 +1,2 @@
|
||||
[smtp.gmail.com]:587 nagios.gsb22@gmail.com:Azerty1+
|
||||
chmod 600 /etc/postfix/sasl_passwd
|
126
roles/nagios/files/services.cfg
Normal file
126
roles/nagios/files/services.cfg
Normal file
@ -0,0 +1,126 @@
|
||||
# A simple configuration file for monitoring the local host
|
||||
# This can serve as an example for configuring other servers;
|
||||
# Custom services specific to this host are added here, but services
|
||||
# defined in nagios2-common_services.cfg may also apply.
|
||||
#
|
||||
|
||||
define service {
|
||||
use generic-service
|
||||
hostgroup_name debian-servers
|
||||
service_description PING
|
||||
check_command check_ping!100.0,20%!500.0,60%
|
||||
}
|
||||
|
||||
define service {
|
||||
use generic-service
|
||||
hostgroup_name windows-servers
|
||||
service_description PING
|
||||
check_command check_ping!100.0,20%!500.0,60%
|
||||
}
|
||||
|
||||
define service {
|
||||
hostgroup_name http-servers
|
||||
service_description HTTP
|
||||
check_command check_http
|
||||
use generic-service
|
||||
notification_interval 0 ; set > 0 if you want to be renotified
|
||||
}
|
||||
|
||||
define service {
|
||||
hostgroup_name debian-servers
|
||||
service_description SSH
|
||||
check_command check_ssh
|
||||
use generic-service
|
||||
notification_interval 0 ; set > 0 if you want to be renotified
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name debian-servers
|
||||
service_description Espace disque
|
||||
check_command check_snmp_storage!public!--v2c!"^/$|tmp|usr|var"!90!95
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name debian-servers
|
||||
service_description Charge machine
|
||||
check_command check_snmp_load!public!--v2c!netsl!2,1,1!3,2,2
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name debian-servers
|
||||
service_description Charge machine
|
||||
check_command check_load!5.0!4.0!3.0!10.0!6.0!4.0
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name debian-servers
|
||||
service_description RAM
|
||||
check_command check_snmp_mem!public!--v2c!-N!95,60!99,90
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name debian-servers
|
||||
service_description Uptime
|
||||
check_command check_snmp!-C public -o 1.3.6.1.2.1.1.3.0
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name windows-servers
|
||||
service_description Uptime
|
||||
check_command check_snmp!-C public -o 1.3.6.1.2.1.1.3.0
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name windows-servers
|
||||
service_description Charge CPU
|
||||
check_command check_nt!CPULOAD!-l 5,80,90,15,80,90
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name windows-servers
|
||||
service_description Uptime
|
||||
check_command check_nt!UPTIME
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name windows-servers
|
||||
service_description Mem Use
|
||||
check_command check_nt!MEMUSE!80,90
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name windows-servers
|
||||
service_description Disk Space
|
||||
check_command check_nt!USEDDISKSPACE!-l C!10,5
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name windows-servers
|
||||
service_description Service DNS
|
||||
check_command check_nt!SERVICESTATE!-l W32Time,"Client DNS"
|
||||
}
|
||||
|
||||
define service{
|
||||
use generic-service
|
||||
hostgroup_name dns-servers
|
||||
service_description DNS Ext
|
||||
check_command check_dns_ext
|
||||
}
|
||||
|
||||
#define service{
|
||||
# use generic-service
|
||||
# hostgroup_name dns-servers
|
||||
# service_description DNS Int
|
||||
# check_command check_dns_int
|
||||
#}
|
17
roles/nagios/handlers/main.yml
Normal file
17
roles/nagios/handlers/main.yml
Normal file
@ -0,0 +1,17 @@
|
||||
- name: restart nagios4
|
||||
service:
|
||||
name: nagios4
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: restart apache2
|
||||
service:
|
||||
name: apache2
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: restart postfix
|
||||
service:
|
||||
name: postfix
|
||||
state: restarted
|
||||
enabled: yes
|
124
roles/nagios/tasks/main.yml
Normal file
124
roles/nagios/tasks/main.yml
Normal file
@ -0,0 +1,124 @@
|
||||
- name: apt update
|
||||
tags: update
|
||||
apt:
|
||||
update-cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Installation apache2
|
||||
tags: apache
|
||||
apt:
|
||||
name:
|
||||
- apache2
|
||||
- snmp
|
||||
- nagios4
|
||||
- nagios-snmp-plugins
|
||||
- python3-passlib
|
||||
state: present
|
||||
|
||||
- name: Copie du fichier nagios4-cgi.conf pour apache
|
||||
tags: nagios4-cgi
|
||||
template:
|
||||
src: nagios4-cgi.conf.j2
|
||||
dest: /etc/apache2/conf-enabled/nagios4-cgi.conf
|
||||
notify: restart nagios4
|
||||
|
||||
- name: Copier le fichier commands.cfg pour nagios
|
||||
tags: commande
|
||||
copy:
|
||||
src: commands.cfg
|
||||
dest: /etc/nagios4/objects/commands.cfg
|
||||
notify: restart nagios4
|
||||
|
||||
- name: Copie le fichier nt.cfg pour commenter la ligne qui pose problème
|
||||
tags: nt.cfg
|
||||
copy:
|
||||
src: nt.cfg
|
||||
dest: /etc/nagios-plugins/config/nt.cfg
|
||||
notify: restart nagios4
|
||||
|
||||
- name: Copie du fichier hostgroup pour nagios
|
||||
tags: groups
|
||||
copy:
|
||||
src: hostgroups.cfg
|
||||
dest: /etc/nagios4/objects
|
||||
notify: restart nagios4
|
||||
|
||||
- name: Copie du fichier des services
|
||||
tags: services
|
||||
copy:
|
||||
src: services.cfg
|
||||
dest: /etc/nagios4/objects
|
||||
notify: restart nagios4
|
||||
|
||||
- name: python3 par defaut
|
||||
tags: python3
|
||||
alternatives:
|
||||
link: /usr/bin/python
|
||||
name: python
|
||||
path: /usr/bin/python3
|
||||
priority: 10
|
||||
|
||||
- name: Remplacement de la ligne use_authentication=0
|
||||
tags: authentication
|
||||
replace:
|
||||
path: /etc/nagios4/cgi.cfg
|
||||
regexp: 'use_authentication=0'
|
||||
replace: 'use_authentication=1'
|
||||
notify: restart nagios4
|
||||
|
||||
|
||||
- name: a2enmod rewrite cgi
|
||||
tags: a2enmod
|
||||
command: a2enmod rewrite cgi
|
||||
notify:
|
||||
- restart apache2
|
||||
- restart nagios4
|
||||
|
||||
- name: Mot de passe pour nagiosadmin
|
||||
tags: passwd
|
||||
command: htdigest -c /etc/nagios4/htdigest.users "{{ access }}" nagiosadmin
|
||||
register: htpexist
|
||||
|
||||
- name: Copie du fichier contact
|
||||
tags: contact
|
||||
template:
|
||||
src: contacts.cfg.j2
|
||||
dest: /etc/nagios4/objects/contacts.cfg
|
||||
|
||||
- name: Copie des fichiers des machines
|
||||
tags: cfg
|
||||
copy:
|
||||
src: cfg/
|
||||
dest: /etc/nagios4/objects
|
||||
notify: restart nagios4
|
||||
|
||||
- name: Copie du fichier nagios.cfg
|
||||
tags: nagios.cfg
|
||||
template:
|
||||
src: nagios.cfg.j2
|
||||
dest: /etc/nagios4/nagios.cfg
|
||||
notify:
|
||||
- restart nagios4
|
||||
- restart apache2
|
||||
|
||||
- name: Suppression du fichier windows.cfg
|
||||
tags: windowscfg
|
||||
file:
|
||||
state: absent
|
||||
path: /etc/nagios4/objects/windows.cfg
|
||||
|
||||
- name: Suppression du fichier printer.cfg
|
||||
tags: printercfg
|
||||
file:
|
||||
state: absent
|
||||
path: /etc/nagios4/objects/printer.cfg
|
||||
|
||||
- name: Suppression du fichier switch.cfg
|
||||
tags: switchcfg
|
||||
file:
|
||||
state: absent
|
||||
path: /etc/nagios4/objects/switch.cfg
|
||||
|
||||
- name: message d'information
|
||||
tags: msg
|
||||
debug: msg="Pour superviser le Windows, il faut installer NSClient++"
|
57
roles/nagios/templates/contacts.cfg.j2
Normal file
57
roles/nagios/templates/contacts.cfg.j2
Normal file
@ -0,0 +1,57 @@
|
||||
###############################################################################
|
||||
# CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS
|
||||
#
|
||||
#
|
||||
# NOTES: This config file provides you with some example contact and contact
|
||||
# group definitions that you can reference in host and service
|
||||
# definitions.
|
||||
#
|
||||
# You don't need to keep these definitions in a separate file from your
|
||||
# other object definitions. This has been done just to make things
|
||||
# easier to understand.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# CONTACTS
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Just one contact defined by default - the Nagios admin (that's you)
|
||||
# This contact definition inherits a lot of default values from the
|
||||
# 'generic-contact' template which is defined elsewhere.
|
||||
|
||||
define contact {
|
||||
|
||||
contact_name nagiosadmin
|
||||
use generic-contact
|
||||
alias Administrateur
|
||||
service_notification_period 24x7
|
||||
host_notification_period 24x7
|
||||
service_notification_options w,u,c,r
|
||||
host_notification_options d,r
|
||||
service_notification_commands notify-service-by-email
|
||||
host_notification_commands notify-host-by-email
|
||||
email nagios.gsb22@gmail.com
|
||||
}
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# CONTACT GROUPS
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# We only have one contact in this simple configuration file, so there is
|
||||
# no need to create more than one contact group.
|
||||
|
||||
define contactgroup {
|
||||
|
||||
contactgroup_name admins
|
||||
alias Nagios Administrators
|
||||
members nagiosadmin
|
||||
}
|
10
roles/nagios/templates/main.cf.j2
Normal file
10
roles/nagios/templates/main.cf.j2
Normal file
@ -0,0 +1,10 @@
|
||||
#On active l'authentification SASL
|
||||
smtp_sasl_auth_enable=yes
|
||||
#Les méthodes pour l'authenfication anonyme
|
||||
smtp_sasl_security_options=noanonymous
|
||||
#Le chemin de sasl_passwd
|
||||
smtp_sasl_password_maps=hash:/etc/postfix/sasl/sasl_passwd
|
||||
#On active le cryptage STARTTLS
|
||||
smtp_tls_security_level=encrypt
|
||||
#Chemin des certificats CA
|
||||
smtp_tls_CAfile=/etc/ssl/certs/ca-certificate.crt
|
1394
roles/nagios/templates/nagios.cfg.j2
Normal file
1394
roles/nagios/templates/nagios.cfg.j2
Normal file
File diff suppressed because it is too large
Load Diff
27
roles/nagios/templates/nagios4-cgi.conf.j2
Normal file
27
roles/nagios/templates/nagios4-cgi.conf.j2
Normal file
@ -0,0 +1,27 @@
|
||||
ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
|
||||
ScriptAlias /nagios4/cgi-bin /usr/lib/cgi-bin/nagios4
|
||||
Alias /nagios4/stylesheets /etc/nagios4/stylesheets
|
||||
|
||||
Alias /nagios4 /usr/share/nagios4/htdocs
|
||||
|
||||
<DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)>
|
||||
Options FollowSymLinks
|
||||
DirectoryIndex index.php index.html
|
||||
AllowOverride AuthConfig
|
||||
AuthDigestDomain "nagios4"
|
||||
AuthDigestProvider file
|
||||
AuthUserFile "/etc/nagios4/htdigest.users"
|
||||
AuthGroupFile "/etc/group"
|
||||
AuthName "Restricted Nagios4 Access"
|
||||
AuthType Digest
|
||||
Require valid-user
|
||||
</DirectoryMatch>
|
||||
|
||||
<Directory /usr/share/nagios4/htdocs>
|
||||
Options +ExecCGI
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/lib/cgi-bin/nagios4>
|
||||
Options +ExecCGI
|
||||
AddHandler cgi-script .cgi
|
||||
</Directory>
|
Reference in New Issue
Block a user