documentazione_3di_riservata:manuali_sysadmin:nagios
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
Entrambe le parti precedenti la revisioneRevisione precedente | |||
documentazione_3di_riservata:manuali_sysadmin:nagios [2021/07/29 10:14] – Modifica upload scripts fabio.guidotti | documentazione_3di_riservata:manuali_sysadmin:nagios [Data sconosciuta] (versione attuale) – eliminata - modifica esterna (Data sconosciuta) 127.0.0.1 | ||
---|---|---|---|
Linea 1: | Linea 1: | ||
- | ======= Monitoraggio con Nagios ======= | ||
- | |||
- | =====Installazione NRPE Centos/ | ||
- | |||
- | Installazione panchetti NRP e plugins: | ||
- | |||
- | **Debian**: | ||
- | |||
- | '' | ||
- | |||
- | **Centos**: | ||
- | |||
- | '' | ||
- | |||
- | **Centos 8 Only:** '' | ||
- | |||
- | '' | ||
- | |||
- | Prelevare da '' | ||
- | |||
- | Upload su **Debian** | ||
- | ''/ | ||
- | |||
- | Upload su **Centos** | ||
- | ''/ | ||
- | |||
- | |||
- | Rendere lo script eseguibile: | ||
- | |||
- | **Debian**: | ||
- | '' | ||
- | |||
- | **Centos**: | ||
- | '' | ||
- | |||
- | Da **Debian** creare un nuovo file '' | ||
- | |||
- | <code cfg> | ||
- | ################################################################################ | ||
- | # | ||
- | # nagios-nrpe command configuration file | ||
- | # | ||
- | # COMMAND DEFINITIONS | ||
- | # Syntax: | ||
- | # | ||
- | # | ||
- | command[USERS]=/ | ||
- | command[CPU]=/ | ||
- | command[SDA1]=/ | ||
- | command[ZOMBIE]=/ | ||
- | command[TOTAL_PROC]=/ | ||
- | command[SWAP]=/ | ||
- | command[ROOT]=/ | ||
- | command[OPT]=/ | ||
- | command[RAM]=/ | ||
- | </ | ||
- | |||
- | Da **Centos** '' | ||
- | <code cfg> | ||
- | ################################################################################ | ||
- | # | ||
- | # nagios-nrpe command configuration file | ||
- | # | ||
- | # COMMAND DEFINITIONS | ||
- | # Syntax: | ||
- | # | ||
- | # | ||
- | command[USERS]=/ | ||
- | command[CPU]=/ | ||
- | command[SDA1]=/ | ||
- | command[ZOMBIE]=/ | ||
- | command[TOTAL_PROC]=/ | ||
- | command[SWAP]=/ | ||
- | command[ROOT]=/ | ||
- | command[OPT]=/ | ||
- | command[RAM]=/ | ||
- | </ | ||
- | |||
- | Edita '' | ||
- | |||
- | < | ||
- | |||
- | |||
- | Restart nrpe agent nel host: | ||
- | |||
- | **Debian**: | ||
- | '' | ||
- | |||
- | **Centos**:'' | ||
- | |||
- | =====Nsclient++ Windows===== | ||
- | Per WINDOWS editare il file nsclient.ini che si trova in NSClient++ di Program Files. | ||
- | <code ini> | ||
- | # 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 | ||
- | ; TODO | ||
- | [/ | ||
- | ; Undocumented key | ||
- | password = nagios | ||
- | ; Undocumented key | ||
- | allowed hosts = 127.0.0.1, | ||
- | port = 5666 | ||
- | ; TODO | ||
- | [/ | ||
- | allow arguments = true | ||
- | allow nasty characters = true | ||
- | ; Undocumented key | ||
- | verify mode = none | ||
- | ; Undocumented key | ||
- | insecure = true | ||
- | ; TODO | ||
- | [/modules] | ||
- | #These are basic modules comes with NSClient++ and below configuration enable them. | ||
- | ; Undocumented key | ||
- | CheckExternalScripts = 1 | ||
- | ; Undocumented key | ||
- | CheckHelpers = 1 | ||
- | ; Undocumented key | ||
- | CheckEventLog = 1 | ||
- | ; Undocumented key | ||
- | CheckNSCP = 1 | ||
- | ; Undocumented key | ||
- | CheckDisk = 1 | ||
- | ; Undocumented key | ||
- | CheckSystem = 1 | ||
- | ; Undocumented key | ||
- | NSClientServer = 1 | ||
- | ; Undocumented key | ||
- | NRPEServer = 1 | ||
- | [/ | ||
- | windows_RAM=checkMem MaxWarn=80% MaxCrit=90% type=physical | ||
- | windows_CPU=checkCPU warn=80 crit=90 time=5m time=1m time=30s | ||
- | windows_UPTIME=checkUpTime MinWarn=1d MinWarn=1h | ||
- | windows_DISK_E=CheckDriveSize MinWarn=20% MinCrit=10% Drive=E: FilterType=FIXED ShowAll=short | ||
- | windows_DISK_C=CheckDriveSize MinWarn=20% MinCrit=10% Drive=C: FilterType=FIXED ShowAll=short | ||
- | [/ | ||
- | allow arguments = true | ||
- | allow nasty characters = true | ||
- | [/ | ||
- | # | ||
- | |||
- | check_AbridgeDiagnosticsService = scripts\check_winservice.exe check_winservice — service “AbridgeDiagnostics” — state stopped — critical 0 | ||
- | check_RabbitMQ = scripts\check_winservice.exe check_winservice — service “RabbitMQ” — state stopped — critical 0 | ||
- | check_W3SVC = scripts\check_winservice.exe check_winservice — service “W3SVC” — state stopped — critical 0 | ||
- | </ | ||
- | |||
- | Riavviare il servizio nsclient. | ||
- | |||
- | =====Aggiungere un Host o Servizio===== | ||
- | |||
- | Per aggiungere un server o un servizio in Nagios bisogna andare sul panello di ammnistriazione Univention, Gestione Dominio [[https:// | ||
- | |||
- | ====Aggiungere un Servizio==== | ||
- | In **Devices** trovate Nagios. E' qui che vengono aggiunti o modificati i servizi. Per quelli NRPE è importante che il nome del servizio sia uguale al nome del comando definito nel file dei comandi NRPE del server che si deve monitorare. | ||
- | ====Aggiungere un Host==== | ||
- | Andare su **Computers** per aggiungere un nuovo host oppure per modificare quelli attuali. Su **Options** del host attivate **Nagios support**. Salvare e poi rientrare per decidere i servizi del host che si vogliono monitorare in **Advanced Settings**. | ||
- | ====Attivare le notifiche==== | ||
- | Se si desidera che le notifiche per lo stato del servizio (warning o critical) vengano segnalate tramite email. Andare su **Advanced Settings** del host, ed inserire l' | ||
- | Se si desidera che le notifiche per lo stato del servizio (warning o critical) vengano segnalate tramite slack.Andare su **Advanced Settings** del host, ed inserire l' | ||
- | |||
- | =====Rimuovere un Host o Servizio===== | ||
- | |||
- | ====Rimuovere un Servizio==== | ||
- | Sempre in **Devices**, | ||
- | **NB: Mi raccomando controllate che non abbia host assengnati prima di distruggerlo!** | ||
- | |||
- | ====== Monitorare Tomcat ====== | ||
- | Lo script da copiare in / | ||
- | |||
- | <code perl check_tomcat.pl> | ||
- | #! / | ||
- | # -*- coding: utf-8 -*- | ||
- | |||
- | # I'm a Spanish speaker, my English is basic but I try to write everything in | ||
- | # English. | ||
- | # Many translations have been made with automatic translators. | ||
- | # If something is not meant pray excuse me. | ||
- | # ¡VAMOS A ELLO! (LET'S GO!) | ||
- | |||
- | # | ||
- | # Name: check_tomcat.pl | ||
- | # | ||
- | # Author: | ||
- | # | ||
- | # Purpose: | ||
- | # Plugin para chequeo de servidor tomcat para nagios | ||
- | # Check tomcat server plugin for nagios | ||
- | # This plugin uses the tomcat manager webapp, this app usually is located in the | ||
- | # URL: | ||
- | # http:// | ||
- | # which " | ||
- | # is the port number of the tomcat service (the tomcat port is 8080 by default) | ||
- | # | ||
- | # This plugin can check this items: | ||
- | # 1- tomcat server status | ||
- | # 2- tomcat server memory | ||
- | # 3- tomcat server thread connectors | ||
- | # 4- application status on tomcat server | ||
- | # | ||
- | # | ||
- | # This plugin conforms to the Nagios Plugin Development Guidelines | ||
- | # https:// | ||
- | # | ||
- | # Created: | ||
- | # Copyright: | ||
- | # Licence: | ||
- | # This program is free software; you can redistribute it and/or modify | ||
- | # it under the terms of the GNU General Public License as published by | ||
- | # the Free Software Foundation; either version 2 of the License, or | ||
- | # (at your option) any later version. | ||
- | # | ||
- | # This program is distributed in the hope that it will be useful, | ||
- | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- | # | ||
- | # GNU General Public License for more details. | ||
- | # | ||
- | # You should have received a copy of the GNU General Public License | ||
- | # along with this program; if not, write to the Free Software | ||
- | # | ||
- | # | ||
- | |||
- | import argparse, sys | ||
- | import urllib2 | ||
- | import socket | ||
- | import xml.etree.ElementTree as ET | ||
- | from math import log | ||
- | |||
- | # | ||
- | #VARIABLE DEFINITIONS | ||
- | # | ||
- | version=" | ||
- | status = { ' | ||
- | exit_status = ' | ||
- | output = "" | ||
- | longoutput = "" | ||
- | perfdata = "" | ||
- | mensage = "" | ||
- | plugin_description =''' | ||
- | ''' | ||
- | mode_help =''' | ||
- | status: The status of tomcat server | ||
- | mem: Tomcat server used percentage memory status, warning and critical | ||
- | values. Requiered in percentage. | ||
- | thread: Tomcat connectors Threads used, warning and critical values requiered. | ||
- | The parameter connector is optional, if not exists, all connector were shown. | ||
- | app: Application status in tomcat server, the name of the application | ||
- | must be defined with the parameter -n or --nameapp. | ||
- | This option check the status of java application running on tomcat server | ||
- | ''' | ||
- | tree_xml=None | ||
- | tomcat_version=None | ||
- | |||
- | # | ||
- | |||
- | # | ||
- | #FUNCTIONS | ||
- | # | ||
- | #Try if string is a float | ||
- | def is_float_try(str): | ||
- | try: | ||
- | float(str) | ||
- | return True | ||
- | except ValueError: | ||
- | return False | ||
- | |||
- | #This function define the range of warning and critical values | ||
- | #Return a range --> (min, | ||
- | #if True, data must be in a range | ||
- | #if False, data must be out of a range | ||
- | def define_range(str): | ||
- | if is_float_try(str): | ||
- | range = (0, | ||
- | elif str.count(":" | ||
- | splits = str.split(":" | ||
- | if is_float_try(splits[0]) and is_float_try(splits[1]): | ||
- | range=(float(splits[0]), | ||
- | elif is_float_try(splits[0]) and splits[1]=="": | ||
- | range=(float(splits[0]), | ||
- | elif splits[0]==" | ||
- | range=(float(" | ||
- | if splits[0][0]==" | ||
- | range=(float(splits[0].replace(" | ||
- | else: | ||
- | print "bad range definition in "+str | ||
- | sys.exit(1) #Error in range definition | ||
- | if range[0]< | ||
- | return range # OK | ||
- | else: | ||
- | print " | ||
- | exit(1) | ||
- | |||
- | #Critical and warning function resolve | ||
- | #This function return exit_status: | ||
- | def define_status(value, | ||
- | warning_range = define_range(warning) | ||
- | critical_range = define_range(critical) #Define critical range | ||
- | val=float(value) | ||
- | exit_status=" | ||
- | |||
- | if args.verbosity: | ||
- | print "Value for test: " | ||
- | print " | ||
- | print " | ||
- | print "" | ||
- | |||
- | #value into the range range(x: | ||
- | if warning_range[2]==True and critical_range[2]==True: | ||
- | if (warning_range[1]> | ||
- | parser.print_usage() | ||
- | parser.exit(3," | ||
- | if value< | ||
- | exit_status=" | ||
- | if value< | ||
- | exit_status=" | ||
- | else: | ||
- | exit_status=" | ||
- | |||
- | #value out of range range(x: | ||
- | elif warning_range[2]==False and critical_range[2]==False: | ||
- | if (warning_range[1]< | ||
- | parser.print_usage() | ||
- | parser.exit(3," | ||
- | if value> | ||
- | exit_status=" | ||
- | if value> | ||
- | exit_status=" | ||
- | else: | ||
- | exit_status=" | ||
- | #warning and critical ranges must be both in or out | ||
- | else: | ||
- | parser.print_usage() | ||
- | parser.exit(status[exit_status],''' | ||
- | ERROR: Both critical and warning values must be in or out of the ranges: | ||
- | | ||
- | |||
- | return exit_status | ||
- | |||
- | # convert human readable size function | ||
- | def sizeof_fmt(num): | ||
- | # Human friendly size | ||
- | unit_list = zip([' | ||
- | if num > 1: | ||
- | exponent = min(int(log(num, | ||
- | quotient = float(num) / 1024**exponent | ||
- | unit, num_decimals = unit_list[exponent] | ||
- | format_string = ' | ||
- | return format_string.format(quotient, | ||
- | elif num == 0: | ||
- | return '0 bytes' | ||
- | elif num == 1: | ||
- | return '1 byte' | ||
- | elif num < 0: | ||
- | return ' | ||
- | else: | ||
- | return None | ||
- | |||
- | #open and read XML from tomcat manager/ | ||
- | def read_page_status_XML(host, | ||
- | |||
- | url_status_xml = url+"/ | ||
- | page, | ||
- | # End of Open manager status | ||
- | if(error_page): | ||
- | return page, | ||
- | else: | ||
- | # Read xml | ||
- | try: | ||
- | root = ET.fromstring(page) | ||
- | #If can't parse XML | ||
- | except ET.ParseError as e: | ||
- | root=" | ||
- | error_page=True | ||
- | #show XML tree | ||
- | if args.verbosity> | ||
- | print "XML tree:" | ||
- | print ET.dump(root) | ||
- | print "" | ||
- | return root, | ||
- | |||
- | #Read a html manager page | ||
- | def read_page(host, | ||
- | error=False | ||
- | url_tomcat = " | ||
- | if args.verbosity: | ||
- | print " | ||
- | |||
- | try: | ||
- | password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() | ||
- | password_mgr.add_password(None, | ||
- | handler = urllib2.HTTPBasicAuthHandler(password_mgr) | ||
- | opener=urllib2.build_opener(handler) | ||
- | urllib2.install_opener(opener) | ||
- | req = urllib2.Request(url_tomcat) | ||
- | handle = urllib2.urlopen(req, | ||
- | # Store all page in a variable | ||
- | page = handle.read() | ||
- | # End of Open manager status | ||
- | except urllib2.HTTPError as e: | ||
- | if(e.code==401): | ||
- | page=" | ||
- | elif(e.code==403): | ||
- | page=" | ||
- | else: | ||
- | page=" | ||
- | error=True | ||
- | except urllib2.URLError as e: | ||
- | page = ' | ||
- | error = True | ||
- | except socket.timeout as e: | ||
- | page = ' | ||
- | error = True | ||
- | except socket.error as e: | ||
- | page = " | ||
- | error = True | ||
- | except: | ||
- | page = " | ||
- | error = True | ||
- | |||
- | # Show page if -vvv option | ||
- | if args.verbosity> | ||
- | print "page " | ||
- | print page | ||
- | print "" | ||
- | return page,error | ||
- | |||
- | # | ||
- | |||
- | |||
- | # | ||
- | # ARGPARSE OBJECT DEFINITION | ||
- | # | ||
- | parser = argparse.ArgumentParser(description=plugin_description, | ||
- | formatter_class=argparse.RawTextHelpFormatter) | ||
- | parser.version = parser.prog+" | ||
- | parser.add_argument(' | ||
- | help=" | ||
- | version=' | ||
- | parser.add_argument(' | ||
- | help=''' | ||
- | -v Single line, additional information (eg list processes that fail)\n | ||
- | -vv Multi line, configuration debug output (eg ps command used) | ||
- | -vvv Lots of detail for plugin problem diagnosis | ||
- | ''' | ||
- | |||
- | # Connection parameters | ||
- | conn_parameters = parser.add_argument_group(' | ||
- | ' | ||
- | conn_parameters.add_argument(' | ||
- | help=" | ||
- | required=True) | ||
- | conn_parameters.add_argument(' | ||
- | help=" | ||
- | required=True) | ||
- | conn_parameters.add_argument(' | ||
- | default = " | ||
- | help=" | ||
- | conn_parameters.add_argument(' | ||
- | metavar=' | ||
- | default = " | ||
- | help=" | ||
- | conn_parameters.add_argument(' | ||
- | default = "/ | ||
- | help=''' | ||
- | conn_parameters.add_argument(' | ||
- | help=''' | ||
- | conn_parameters.add_argument(' | ||
- | default = " | ||
- | help=''' | ||
- | conn_parameters.add_argument(' | ||
- | default = " | ||
- | help=''' | ||
- | value in minutes (0 minutes by default)''' | ||
- | |||
- | parameters = parser.add_argument_group(' | ||
- | ' | ||
- | parameters.add_argument(' | ||
- | help=" | ||
- | parameters.add_argument(' | ||
- | help=" | ||
- | parameters.add_argument(' | ||
- | help=" | ||
- | parameters.add_argument(' | ||
- | choices=[' | ||
- | help=mode_help, | ||
- | required=True) | ||
- | |||
- | |||
- | #Corrects negative numbers in arguments parser | ||
- | for i, arg in enumerate(sys.argv): | ||
- | if arg!="": | ||
- | if (arg[0] == ' | ||
- | # arguments parse | ||
- | args = parser.parse_args() | ||
- | # | ||
- | |||
- | |||
- | |||
- | #No arguments | ||
- | if sys.argv[1: | ||
- | parser.print_usage() | ||
- | parser.exit(status[' | ||
- | " | ||
- | |||
- | if args.verbosity!=None: | ||
- | if args.verbosity> | ||
- | args.verbosity=3 | ||
- | print " | ||
- | |||
- | if args.verbosity: | ||
- | print " | ||
- | #plugin logic... | ||
- | |||
- | |||
- | |||
- | # | ||
- | #MODE OPTIONS LOGIC | ||
- | # | ||
- | |||
- | #Set timeout global | ||
- | socket.setdefaulttimeout(float(args.timeout)) | ||
- | |||
- | #read serviceinfo | ||
- | url_serverinfo = args.URL+"/ | ||
- | page_serverinfo, | ||
- | if args.verbosity> | ||
- | print " | ||
- | print page_serverinfo | ||
- | |||
- | # if error, try the manager/ | ||
- | # of the manager app commands | ||
- | if(error_serverinfo): | ||
- | url_serverinfo = args.URL+"/ | ||
- | page_serverinfo, | ||
- | # Now it is an error yes or yes | ||
- | if(error_serverinfo): | ||
- | output = page_serverinfo | ||
- | exit_status=' | ||
- | if(error_serverinfo==False): | ||
- | # read tomcat version in serverinfo | ||
- | serverinfo = page_serverinfo.splitlines() | ||
- | if args.verbosity> | ||
- | print " | ||
- | print serverinfo | ||
- | print "" | ||
- | tomcat_version_string = (serverinfo[1].split(":" | ||
- | tomcat_status_string = serverinfo[0] | ||
- | if args.verbosity> | ||
- | print " | ||
- | print " | ||
- | #tomcat version is read in line 2 of serverinfo | ||
- | # | ||
- | tomcat_version = (tomcat_version_string.split("/" | ||
- | if args.verbosity: | ||
- | print " | ||
- | #If i can't read the tomcat version because it is not a number | ||
- | if (tomcat_version.isdigit()==False): | ||
- | tomcat_version=0 | ||
- | if args.verbosity: | ||
- | print " | ||
- | |||
- | # status option | ||
- | # | ||
- | if args.mode == ' | ||
- | #Default state is CRITICAL | ||
- | exit_status=' | ||
- | # If serverinfo page is correct | ||
- | if (error_serverinfo!=True): | ||
- | # check if the first line of serverinfo content " | ||
- | if (tomcat_status_string.find(" | ||
- | output = tomcat_version_string+" | ||
- | exit_status=' | ||
- | else: | ||
- | output=" | ||
- | exit_status=' | ||
- | # if serverinfo page is not correct try with th status xml page | ||
- | else: | ||
- | tree_xml, | ||
- | #check if page status xml is OK | ||
- | if (error_status_xml!=True): | ||
- | if (tree_xml!=None): | ||
- | if tree_xml.tag==' | ||
- | output=" | ||
- | exit_status=' | ||
- | else: | ||
- | output=" | ||
- | exit_status=' | ||
- | else: | ||
- | output=" | ||
- | exit_status=' | ||
- | else: | ||
- | output=tree_xml | ||
- | exit_status=' | ||
- | |||
- | |||
- | # mem option | ||
- | # | ||
- | if args.mode == ' | ||
- | # read status xml for extract mem data | ||
- | tree_xml, | ||
- | if error_status_xml: | ||
- | output = tree_xml | ||
- | exit_status = ' | ||
- | else: | ||
- | if tree_xml!=None: | ||
- | #control warning and critical values | ||
- | if (args.warning==None) or (args.critical==None): | ||
- | parser.print_usage() | ||
- | parser.exit(status[' | ||
- | ' | ||
- | memory = tree_xml.find(' | ||
- | free_memory = float(memory.get(' | ||
- | total_memory = float(memory.get(' | ||
- | max_memory = float(memory.get(' | ||
- | available_memory = free_memory + max_memory - total_memory | ||
- | used_memory = max_memory - available_memory | ||
- | percent_used_memory = float((used_memory * 100)/ | ||
- | if args.verbosity: | ||
- | print "mode: mem(memory)" | ||
- | if args.verbosity > 1: | ||
- | print " | ||
- | total_memory, | ||
- | print " | ||
- | print " | ||
- | print " | ||
- | print " | ||
- | |||
- | #Define status whit function | ||
- | exit_status=define_status(percent_used_memory, | ||
- | output=" | ||
- | perfdata="' | ||
- | args.critical) | ||
- | |||
- | # threads option | ||
- | # | ||
- | if args.mode == ' | ||
- | # read status xml for extract mem data | ||
- | tree_xml, | ||
- | if error_status_xml: | ||
- | output = tree_xml | ||
- | exit_status = ' | ||
- | else: | ||
- | if tree_xml!=None: | ||
- | #control warning and critical values | ||
- | if (args.warning==None) or (args.critical==None): | ||
- | parser.print_usage() | ||
- | parser.exit(status[' | ||
- | ' | ||
- | if(args.connector==None): | ||
- | if (args.verbosity> | ||
- | for connector in tree_xml.findall(' | ||
- | connector_name = str(connector.get(' | ||
- | if (args.verbosity> | ||
- | thread = connector.find(' | ||
- | max_thread = float(thread.get(' | ||
- | busy_thread = float(thread.get(' | ||
- | iter_status=define_status(busy_thread, | ||
- | if status[iter_status] > status[exit_status]: | ||
- | exit_status=iter_status | ||
- | output = output + '/ | ||
- | perfdata = perfdata + "' | ||
- | |||
- | else: | ||
- | if (args.verbosity> | ||
- | for connector in tree_xml.findall(' | ||
- | connector_name = str(connector.get(' | ||
- | if (args.connector==connector_name): | ||
- | if (args.verbosity> | ||
- | print "Find %s connector" | ||
- | thread = connector.find(' | ||
- | max_thread = float(thread.get(' | ||
- | busy_thread = float(thread.get(' | ||
- | exit_status=define_status(busy_thread, | ||
- | output = output + ' | ||
- | perfdata = perfdata + "' | ||
- | |||
- | # app option | ||
- | # | ||
- | if args.mode == ' | ||
- | #Watch if nameapp is defined | ||
- | if args.nameapp==None: | ||
- | parser.print_usage() | ||
- | parser.exit(status[' | ||
- | ' | ||
- | #If serverinfo is not read | ||
- | if error_serverinfo: | ||
- | output=" | ||
- | exit_status=' | ||
- | #If serverinfo is read | ||
- | else: | ||
- | #for versions upper Tomcat 6 | ||
- | if (int(tomcat_version) > 6): | ||
- | url_list = args.URL+"/ | ||
- | else: | ||
- | url_list = args.URL+"/ | ||
- | |||
- | #read application list page | ||
- | page_list, | ||
- | #If list page is not read | ||
- | if error_list: | ||
- | output=" | ||
- | exit_status=' | ||
- | #If list page is read | ||
- | else: | ||
- | #Divide page_list in lines, each line is an application in the tomcat server | ||
- | applist = page_list.splitlines() | ||
- | if args.verbosity> | ||
- | print " | ||
- | print applist | ||
- | print "" | ||
- | # | ||
- | matchapp = "/" | ||
- | match = False #Flag | ||
- | for application in applist: | ||
- | application = application.split(":" | ||
- | if matchapp == application[0]: | ||
- | match=True | ||
- | break | ||
- | #If match app | ||
- | if match: | ||
- | if application[1]==" | ||
- | output = args.nameapp+" | ||
- | exit_status=" | ||
- | elif application[1]==" | ||
- | output = args.nameapp+" | ||
- | exit_status=" | ||
- | else: | ||
- | output = "I can't understand the state " | ||
- | exit_status=" | ||
- | #perfdata is the number of sessions for the application | ||
- | perfdata="' | ||
- | #If not match app | ||
- | else: | ||
- | output = "I can't find the " | ||
- | exit_status=" | ||
- | |||
- | # | ||
- | # | ||
- | #Expire sessions | ||
- | |||
- | #If serverinfo is read | ||
- | if not error_serverinfo: | ||
- | if (int(tomcat_version) > 6): | ||
- | url_expire = args.URL+"/ | ||
- | else: | ||
- | url_expire = args.URL+"/ | ||
- | #for versions upper Tomcat 6 | ||
- | #Expire sessions of manager app | ||
- | page_expire, | ||
- | if (args.verbosity> | ||
- | if not error_expire: | ||
- | print(" | ||
- | if (args.verbosity> | ||
- | print(" | ||
- | print(page_expire) | ||
- | |||
- | |||
- | |||
- | # | ||
- | # | ||
- | #Outputs | ||
- | |||
- | if output=='': | ||
- | output = " | ||
- | exit_status =' | ||
- | message = exit_status + " " + output | ||
- | if perfdata!="": | ||
- | message = message + ' | ||
- | if longoutput!="": | ||
- | message = message + longoutput | ||
- | print message | ||
- | sys.exit(status[exit_status]) | ||
- | </ | ||
- | |||
- | Una volta creato lo script nella cartella indicata assegnare permessi di escuzione. | ||
- | |||
- | < | ||
- | |||
- | Editare il file < | ||
- | |||
- | aggiungiere le seguenti righe: | ||
- | |||
- | < | ||
- | command[check_tomcat_status]=/ | ||
- | command[check_tomcat_mem]=/ | ||
- | command[check_tomcat_thread]=/ | ||
- | command[check_tomcat_app]=/ | ||
- | command[check_tomcat_app_jenkins]=/ | ||
- | </ | ||
- | |||
- | <WRAP center round info 60%> | ||
- | NB: check_tomcat_app_jenkins verifica che l' | ||
- | </ | ||
- | |||
- | {{anchor: | ||
- | |||
- | <code cfg template_monitoraggio_tomcat.cfg> | ||
- | define host{ | ||
- | use linux-server | ||
- | host_name | ||
- | alias | ||
- | # | ||
- | address | ||
- | parents vmtest | ||
- | } | ||
- | |||
- | define service{ | ||
- | use | ||
- | host_name | ||
- | service_description | ||
- | check_command | ||
- | } | ||
- | |||
- | define service { | ||
- | service_description | ||
- | host_name | ||
- | check_command | ||
- | use | ||
- | notification_interval | ||
- | } | ||
- | |||
- | define service { | ||
- | service_description | ||
- | host_name | ||
- | check_command | ||
- | use | ||
- | notification_interval | ||
- | } | ||
- | |||
- | define service { | ||
- | service_description | ||
- | host_name | ||
- | check_command | ||
- | use | ||
- | notification_interval | ||
- | } | ||
- | |||
- | define service { | ||
- | service_description | ||
- | host_name | ||
- | check_command | ||
- | use | ||
- | notification_interval | ||
- | } | ||
- | |||
- | define service { | ||
- | host_name | ||
- | service_description | ||
- | check_command | ||
- | use | ||
- | notification_interval | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ==== Mappa ==== | ||
- | === Icone === | ||
- | Nagios core richiede 4 formati dello stesso file (gd2, png, jpg, gif). Usare icone 40x40 con sfondo trasparente. Ci sono diverse utility ed è stato realizzato anche uno script che dato come argomento un gif realizza la conversione negli altri formati. | ||
- | |||
- | <code bash nagiosicon.sh> | ||
- | #!/bin/bash | ||
- | # Create Nagios Icon from GIF | ||
- | # Autor : Marvin Pascale | ||
- | # Make a 40x40 px GIF image without backgroud | ||
- | # Usage: nagiosicon.sh image.gif | ||
- | #install: libgd-tools pnmtopng | ||
- | #Enjoy nerd | ||
- | |||
- | if [ $# -eq 0 ] | ||
- | then | ||
- | echo "" | ||
- | echo " | ||
- | echo "No arguments supplied" | ||
- | echo "Usage : ./ | ||
- | echo "" | ||
- | fi | ||
- | |||
- | path="/ | ||
- | for arg | ||
- | do | ||
- | if [ -f " | ||
- | echo converting $arg | ||
- | arg=" | ||
- | echo " | ||
- | mkdir $arg | ||
- | cp $arg.gif $arg/ | ||
- | $path/ | ||
- | $path/ | ||
- | $path/ | ||
- | $path/ | ||
- | fi | ||
- | done | ||
- | |||
- | rm -f *.pnm | ||
- | </ | ||
- | |||
- | === Collegamenti gerarchici === | ||
- | |||
- | Per visualizzare correttamente le gerarchie nella mappa di Nagios bisogna correttamente utilizzare la specifica " | ||
- | |||
- | < | ||
- | define host{ | ||
- | use | ||
- | host_name | ||
- | alias | ||
- | address | ||
- | parents | ||
- | } | ||
- | |||
- | </ | ||
/data/attic/documentazione_3di_riservata/manuali_sysadmin/nagios.1627546455.txt.gz · Ultima modifica: 2021/07/29 10:14 da fabio.guidotti