Richard Bruno
navigation
Home
admin









Shinken
October 18th, 2016

Table des matières



Plugins Perl
Créer un nouveau pack
Modifier un service pour qu'il accepte des paramètres
Windows : exclure des services de la vérification
Variables
Informations diverses
Architecture
Divers

Plugins Perl



check_wmi_plus.pl

-w 0 is a short form of the full range specification 0:0 which defines a range from 0 to 0. If the number of "bad" services are outside this range then we get a warning state. So, if we find even 1 "bad" service we will get a warning.
Source : http://www.edcint.co.nz/checkwmiplus/?q=faq_examplewarncrit

-o 2 : errors only
-3 4 : last 4 hours
Source : http://www.edcint.co.nz/checkwmiplus/?q=faq_examplecommandlines

Créer un nouveau pack



Plutôt que de modifier un pack, il peut être plus judicieux d'en créer un nouveau à partir de l'ancien.
Ainsi, lors des mises à jours, il n'y a pas (moins ?) de risques que nos modifications soient touchées.

On fait alors :

cd /usr/local/shinken/etc/packs/
cp -r ancien_pack nouveau_pack



Dans le répertoire de base du nouveau pack :
fichier commands.cfg : suppressions des commandes déjà définies dans ancien_pack/commands.cfg + définition des nouvelles (i.e. on ne définit ici que les commandes qui sont différentes de celles du fichier ancien_pack/commands.cfg)

fichier templates.cfg : modification du nom + ajout de variables si nécessaire

fichier nouveau_pack.pack : modification du nom

répertoire services : pour chaque service, modification du hostname

host_name ancien_pack devient host_name nouveau_pack


et, si nécessaire, modification de check_command qui pointera désormais vers la nouvelle commande définie dans commands.cfg.

Si on ne modifie pas check_command, on continue d'exécuter la commande définie dans ancien_pack/commands.cfg.



Modifier un service pour qu'il accepte des paramètres




Mon problème est le suivant : sur les cisco 2960, j'ai cette remontée d'alerte :

Cisco 2960, mempool I/O usage is 83%



Cette alerte n'est a priori pas problématique et plutôt normale pour ce type de matériel.
"my specialist told me that for this model it is normal"
Source : http://www.shinken-monitoring.org/forum/index.php?topic=764.0
"SO this is how it works and I guess nothing to worry about."
Source : https://supportforums.cisco.com/thread/2112475

Une solution est de remonter le seuil d'alerte.
Pour faire quelque chose de propre, nous allons créer un nouveau type de matériel cisco_2960 :

cd /usr/local/shinken/etc/packs/network/
cp -r cisco cisco_2960



Modification du fichier /usr/local/shinken/etc/packs/network/cisco_2960/discovery.cfg

discoveryrule_name Cisco_2960



Ajout des lignes suivantes dans le fichier /usr/local/shinken/etc/packs/network/cisco_2960/templates.cfg

_SWITCHMEM_WARN 85
_SWITCHMEM_CRIT 90



Modification du fichier /usr/local/shinken/etc/packs/network/cisco_2960/services/memory.cfg

host_name cisco_2960
check_command check_switch_memory_2960




Modification du fichier /usr/local/shinken/etc/packs/network/switch/commands.cfg

define command {
command_name check_switch_memory_2960
command_line $PLUGINSDIR$/check_nwc_health --hostname $HOSTADDRESS$ --timeout 60 --community $_HOSTSNMPCOMMUNITY$ --mode memory-usage --warning $_HOSTSWITCHMEM_WARN$ --critical $_HOSTSWITCHMEM_CRIT$
}



Il est maintenant possible de positionner dans la définition d'un host les macros SWITCHMEM_WARN et SWITCHMEM_CRIT :

define host {
use switch,cisco_2960
host_name sr698ec1
address 192.168.100.61
_SWITCHMEM_WARN 83
_SWITCHMEM_CRIT 90
}



Si ces macros ne sont pas positionnées, ce sont celles du fichier templates.cfg qui sont utilisées.


Windows : exclure des services de la vérification



Il est possible d'exclure des services des vérifications :
On modifie le fichier commands.cfg du pack windows :

# more /usr/local/shinken/etc/packs/os/windows/commands.cfg
[...]
# Auto services are started
define command {
command_name check_windows_auto_services
command_line $PLUGINSDIR$/check_wmi_plus.pl -H $HOSTADDRESS$ -u "$_HOSTDOMAINUSER$" -p "$_HOSTDOMAINPASSWORD$" -m checkservice -a Auto -o '$_HOSTSERVEXCLUDED$' --inifile=$PLUGINSDIR$/check_wmi
_plus.d/checkservice.ini -w 0 -c 1
}
[...]



La chaine $_HOSTSERVEXCLUDED$ a été rajoutée.

On modifie le fichier de config de la machine :

# more /usr/local/shinken/etc/objects/discovery/serv1/serv1.cfg
define host {
use windows,windows2008
host_name deepsecurity
address 10.165.120.8

_SERVEXCLUDED NGEN
}



On exclut ici les services dont le nom contient la chaine NGEN.

Source : http://www.edcint.co.nz/checkwmiplus/?q=faq_examplecommandlines

Aller plus loin :

check_wmi_plus.pl [-o ARG2]
ARG2 : A regular expression that matches against the short or long service name that can be seen in the properties of the
service in Windows. The matching services are excluded in the resulting list.
This exclusion list is applied after the inclusion list.

Source : check_wmi_plus.pl

=> on peut exclure plusieurs services :

_SERVEXCLUDED NGEN|Protection




Variables



Des variables peuvent être insérées dans les définitions des machines, des services ou des contacts.
Exemple :

cat etc/objects/discovery/dnsext/dnsext.cfg
define host {
use linux,dns
host_name dnsext
address 195.zzz

_DNSHOSTNAME 195.zzzz
_DNSEXPECTEDRESULT dns.zzzz
_ADDRESS dnsext
}



Ces variables s'utilisent ensuite dans les fichiers de commande avec la syntaxe $_HOST<nom de la variable>$ quand il s'agit d'une variable définie dans un fichier host.
Exemple :

cat etc/packs/network/services/dns/commands.cfg
# Check a DNS server
define command {
command_name check_dns
command_line $PLUGINSDIR$/check_dns -H $_HOSTDNSHOSTNAME$ -a $_HOSTDNSEXPECTEDRESULT$ -s $HOSTADDRESS$
}



Source : http://www.shinken-monitoring.org/wiki/official/configuringshinken-customobjectvars
Docs



http://www.shinken-monitoring.org/wiki/official/configuringshinken-config
http://blog.nicolargo.com/2012/11/installation-pas-a-pas-dun-serveur-de-supervision-shinken.html
La liste variables (macros) à utiliser dans les scripts : http://www.shinken-monitoring.org/wiki/official/thebasics-macrolist


Architecture



http://www.shinken-monitoring.org/wiki/_media/official/images/shinken-architecture.png

Divers



Désactiver un service

/usr/local/shinken/etc/packs/os/windows# mv services/inactive_sessions.cfg services/inactive_sessions.cfg.20131112




Perfdata

http://smilingsubnode.blogspot.fr/2012/05/installation-de-pnp4nagios-sur-shinken.html

Répertoires et fichiers importants

etc/packs/os/linux/services/ : les services qui seront accessibles dans shinken.
Par exemple NetworkUsage :

more etc/packs/os/linux/services/network_usage.cfg
define service{
service_description NetworkUsage
use generic-service
register 0
host_name linux
check_command check_linux_network_usage
}



etc/packs/os/linux/commands.cfg : répertories les commandes associées aux services pour ce pack

more etc/packs/os/linux/commands.cfg
[...]

define command {
command_name check_linux_network_usage
command_line $PLUGINSDIR$/check_snmp_bandwidth -H $HOSTADDRESS$ -C $_HOSTSNMPCOMMUNITY$ -O "$LASTSERVICEPERFDATA$" -w $_HOSTNETWORKUSAGE_WARN$ -c $_HOSTNETWORKUSAGE_CRIT$ $_HOSTNETWORKUSAGE_SE
LECTOR$
}
[...]



Monitorer un switch

http://www.shinken-monitoring.org/wiki/monitoring_a_router_or_switch

Monitorer un Windows

https://kb.op5.com/display/HOWTOs/Agentless+Monitoring+of+Windows+using+WMI

Quel délai pour surveiller une machine

# more /usr/local/shinken/etc/templates.cfg
[...]
# Generic host definition template - This is NOT a real host, just a template!
# Most hosts should inherit from this one
define host{
name generic-host
alias generic-host

check_interval 5






Dernières modifs
Divers (October 18th, 2016)
ElasticSearch (October 18th, 2016)
Les portables et leurs batteries (October 18th, 2016)
Munin (October 18th, 2016)
Nagios (October 18th, 2016)
OpenManage (October 18th, 2016)
Rkhunter (October 18th, 2016)

Contact
Pour m'envoyer un mail,
Pour me laisser un commentaire :
richard.brunooo
chez
gmail.com


powered by kure, modified by Bruno