5 Tipi di supporto

Panoramica

I tipi di supporto sono exported con tutti i relativi oggetti e relazioni tra oggetti.

Esportazione

Per esportare i tipi di supporto, procedi come segue:

  • Vai a: Amministrazionetipi di supporto
  • Contrassegnare le caselle dei template da esportare
  • Clicca su Esporta sotto l'elenco

A seconda del formato selezionato, i template vengono esportati in un file locale con un nome predefinito:

  • zabbix_export_mediatypes.yaml - nell'esportazione YAML (opzione predefinita per l'esportazione)
  • zabbix_export_mediatypes.xml - nell'esportazione XML
  • zabbix_export_mediatypes.json - nell'esportazione JSON

Importazione

per importare i tipi di supporto, procedi come segue:

  • Vai a: AmministrazioneTipi di supporto
  • fare click su Importa a destra
  • Seleziona file da importare
  • Contrassegna le opzioni richieste nelle regole di importazione
  • Clicca su Importa

Un messaggio di successo o di fallimento dell'importazione sarà visualizzato nel frontend.

Regole di importazione:

Regola Descrizione
Aggiorna esistente Gli elementi esistenti verranno aggiornati con i dati presi dal file importato. In caso contrario non verranno aggiornati.
Crea nuovo L'importazione aggiungerà nuovi alimenti utilizzando i dati del file importato. Altrimenti non verranno aggiunti.
Elimina mancante L'importazione rimuoverò gli elementi esistenti non presenti nel file importato. Altrimenti non verranno rimossi.

Formato di Esportazione

Esportazione in YAML:

zabbix_export:
  version: '6.0'
  date: '2021-08-31T13:34:17Z'
  media_types:
    -
      name: Pushover
      type: WEBHOOK
      parameters:
        -
          name: endpoint
          value: 'https://api.pushover.net/1/messages.json'
        -
          name: eventid
          value: '{EVENT.ID}'
        -
          name: event_nseverity
          value: '{EVENT.NSEVERITY}'
        -
          name: event_source
          value: '{EVENT.SOURCE}'
        -
          name: event_value
          value: '{EVENT.VALUE}'
        -
          name: expire
          value: '1200'
        -
          name: message
          value: '{ALERT.MESSAGE}'
        -
          name: priority_average
          value: '0'
        -
          name: priority_default
          value: '0'
        -
          name: priority_disaster
          value: '0'
        -
          name: priority_high
          value: '0'
        -
          name: priority_information
          value: '0'
        -
          name: priority_not_classified
          value: '0'
        -
          name: priority_warning
          value: '0'
        -
          name: retry
          value: '60'
        -
          name: title
          value: '{ALERT.SUBJECT}'
        -
          name: token
          value: '<PUSHOVER TOKEN HERE>'
        -
          name: triggerid
          value: '{TRIGGER.ID}'
        -
          name: url
          value: '{$ZABBIX.URL}'
        -
          name: url_title
          value: Zabbix
        -
          name: user
          value: '{ALERT.SENDTO}'
      max_sessions: '0'
      script: |
        try {
            var params = JSON.parse(value),
                request = new HttpRequest(),
                data,
                response,
                severities = [
                    {name: 'not_classified', color: '#97AAB3'},
                    {name: 'information', color: '#7499FF'},
                    {name: 'warning', color: '#FFC859'},
                    {name: 'average', color: '#FFA059'},
                    {name: 'high', color: '#E97659'},
                    {name: 'disaster', color: '#E45959'},
                    {name: 'resolved', color: '#009900'},
                    {name: 'default', color: '#000000'}
                ],
                priority;

            if (typeof params.HTTPProxy === 'string' && params.HTTPProxy.trim() !== '') {
                request.setProxy(params.HTTPProxy);
            }

            if ([0, 1, 2, 3].indexOf(parseInt(params.event_source)) === -1) {
                throw 'Incorrect "event_source" parameter given: "' + params.event_source + '".\nMust be 0-3.';
            }

            if (params.event_value !== '0' && params.event_value !== '1'
                && (params.event_source === '0' || params.event_source === '3')) {
                throw 'Incorrect "event_value" parameter given: ' + params.event_value + '\nMust be 0 or 1.';
            }

            if ([0, 1, 2, 3, 4, 5].indexOf(parseInt(params.event_nseverity)) === -1) {
                params.event_nseverity = '7';
            }

            if (params.event_value === '0') {
                params.event_nseverity = '6';
            }

            priority = params['priority_' + severities[params.event_nseverity].name] || params.priority_default;

            if (isNaN(priority) || priority < -2 || priority > 2) {
                throw '"priority" should be -2..2';
            }

            if (params.event_source === '0' && isNaN(params.triggerid)) {
                throw 'field "triggerid" is not a number';
            }

            if (isNaN(params.eventid)) {
                throw 'field "eventid" is not a number';
            }

            if (typeof params.message !== 'string' || params.message.trim() === '') {
                throw 'field "message" cannot be empty';
            }

            data = {
                token: params.token,
                user: params.user,
                title: params.title,
                message: params.message,
                url: (params.event_source === '0') 
                    ? params.url + '/tr_events.php?triggerid=' + params.triggerid + '&eventid=' + params.eventid
                    : params.url,
                url_title: params.url_title,
                priority: priority
            };

            if (priority == 2) {
                if (isNaN(params.retry) || params.retry < 30) {
                    throw 'field "retry" should be a number with value of at least 30 if "priority" is set to 2';
                }

                if (isNaN(params.expire) || params.expire > 10800) {
                    throw 'field "expire" should be a number with value of at most 10800 if "priority" is set to 2';
                }

                data.retry = params.retry;
                data.expire = params.expire;
            }

            data = JSON.stringify(data);
            Zabbix.log(4, '[ Pushover Webhook ] Sending request: ' + params.endpoint + '\n' + data);

            request.addHeader('Content-Type: application/json');
            response = request.post(params.endpoint, data);

            Zabbix.log(4, '[ Pushover Webhook ] Received response with status code ' + request.getStatus() + '\n' + response);

            if (response !== null) {
                try {
                    response = JSON.parse(response);
                }
                catch (error) {
                    Zabbix.log(4, '[ Pushover Webhook ] Failed to parse response received from Pushover');
                    response = null;
                }
            }

            if (request.getStatus() != 200 || response === null || typeof response !== 'object' || response.status !== 1) {
                if (response !== null && typeof response === 'object' && typeof response.errors === 'object'
                        && typeof response.errors[0] === 'string') {
                    throw response.errors[0];
                }
                else {
                    throw 'Unknown error. Check debug log for more information.';
                }
            }

            return 'OK';
        }
        catch (error) {
            Zabbix.log(4, '[ Pushover Webhook ] Pushover notification failed: ' + error);
            throw 'Pushover notification failed: ' + error;
        }
      description: |
        Gentilmente fare riferimento alla guida: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/media/pushover

        Set token parameter with to your Pushover application key.
        When assigning Pushover media to the Zabbix user - add user key into send to field.
      message_templates:
        -
          event_source: TRIGGERS
          operation_mode: PROBLEM
          subject: 'Problem: {EVENT.NAME}'
          message: |
            Problem started at {EVENT.TIME} on {EVENT.DATE}
            Problem name: {EVENT.NAME}
            Host: {HOST.NAME}
            Severity: {EVENT.SEVERITY}
            Operational data: {EVENT.OPDATA}
            Original problem ID: {EVENT.ID}
            {TRIGGER.URL}
        -
          event_source: TRIGGERS
          operation_mode: RECOVERY
          subject: 'Resolved in {EVENT.DURATION}: {EVENT.NAME}'
          message: |
            Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}
            Problem name: {EVENT.NAME}
            Problem duration: {EVENT.DURATION}
            Host: {HOST.NAME}
            Severity: {EVENT.SEVERITY}
            Original problem ID: {EVENT.ID}
            {TRIGGER.URL}
        -
          event_source: TRIGGERS
          operation_mode: UPDATE
          subject: 'Updated problem in {EVENT.AGE}: {EVENT.NAME}'
          message: |
            {USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.
            {EVENT.UPDATE.MESSAGE}

            Current problem status is {EVENT.STATUS}, age is {EVENT.AGE}, acknowledged: {EVENT.ACK.STATUS}.
        -
          event_source: DISCOVERY
          operation_mode: PROBLEM
          subject: 'Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}'
          message: |
            Discovery rule: {DISCOVERY.RULE.NAME}

            Device IP: {DISCOVERY.DEVICE.IPADDRESS}
            Device DNS: {DISCOVERY.DEVICE.DNS}
            Device status: {DISCOVERY.DEVICE.STATUS}
            Device uptime: {DISCOVERY.DEVICE.UPTIME}

            Device service name: {DISCOVERY.SERVICE.NAME}
            Device service port: {DISCOVERY.SERVICE.PORT}
            Device service status: {DISCOVERY.SERVICE.STATUS}
            Device service uptime: {DISCOVERY.SERVICE.UPTIME}
        -
          event_source: AUTOREGISTRATION
          operation_mode: PROBLEM
          subject: 'Autoregistration: {HOST.HOST}'
          message: |
            Host name: {HOST.HOST}
            Host IP: {HOST.IP}
            Agent port: {HOST.PORT}

Tag dell'elemento

I valori dei tag dell'elemento sono spiegati nella tabella seguente.

Elemento Proprietà elemento Obbligatorio Tipo Intervallo[1](#note a piè di pagina) Descrizione
media_tipi - Elemento radice per media_tipi.
nome x stringa Nome del tipo di supporto.
type x string 0 - EMAIL
1 - SMS
2 - SCRIPT
4 - WEBHOOK
Trasporto utilizzato dal tipo di supporto.
status - string 0 - ABILITATO (predefinito)
1 - DISABILITATO
Se il tipo di supporto è abilitato.
max_sessions - intero Valori possibili per SMS: 1 - (predefinito)

Valori possibili per altri tipi di media: 0-100, 0 - illimitato
Il numero massimo di avvisi che possono essere elaborati in parallelo.
attempts - intero 1-10 (predefinito: 3) Il numero massimo di tentativi per inviare un avviso.
attempt_interval - string 0-60s (predefinito: 10s) L'intervallo tra i tentativi di nuovo.

Accetta secondi e unità di tempo con suffisso.
descrizione - stringa Descrizione del tipo di supporto.
messaggio_modelli - Elemento radice per modelli di messaggi di tipo multimediale.
event_source x string 0 - TRIGGERS
1 - DISCOVERY
2 - AUTOREGISTRATION
3 - INTERNAL
Fonte evento.
operazione_mode x string 0 - PROBLEMA
1 - RECUPERO
2 - AGGIORNAMENTO
Modalità di funzionamento.
oggetto - stringa Oggetto del messaggio.
messaggio - stringa Corpo del messaggio.
Utilizzato solo dal tipo di supporto e-mail
smtp_server x stringa Server SMTP.
smtp_port - integer Predefinito: 25 Porta del server SMTP a cui connettersi.
smtp_helo x stringa Chiamata SMTP.
smtp_email x stringa Indirizzo e-mail da cui verranno inviate le notifiche.
smtp_security - string 0 - NONE (predefinito)
1 - STARTTLS
2 - SSL_OR_TLS
Livello di sicurezza della connessione SMTP da utilizzare.
smtp_verify_host - string 0 - NO (predefinito)
1 - SÌ
Host di verifica SSL per SMTP. Facoltativo se smtp_security è STARTTLS o SSL_OR_TLS.
smtp_verify_peer - string 0 - NO (predefinito)
1 - SÌ
Peer di verifica SSL per SMTP. Facoltativo se smtp_security è STARTTLS o SSL_OR_TLS.
smtp_authentication - string 0 - NESSUNO (predefinito)
1 - PASSWORD
Metodo di autenticazione SMTP da utilizzare.
nomeutente - stringa Nome utente.
password - stringa Password di autenticazione.
content_type - string 0 - TESTO
1 - HTML (predefinito)
Formato messaggio.
Utilizzato solo dal tipo di supporto SMS
gsm_modem x stringa Nome dispositivo seriale del modem GSM.
Utilizzato solo dal tipo di supporto script
nome script x stringa Nome script.
parametri - Elemento radice per parametri di script.
Utilizzato solo dal tipo di supporto webhook
script x stringa Sceneggiatura.
timeout - string 1-60s (predefinito: 30s) Intervallo di timeout della richiesta HTTP script JavaScript.
process_tags - string 0 - NO (predefinito)
1 - YES
Se elaborare i tag restituiti.
show_event_menu - string 0 - NO (predefinito)
1 - YES
Se {EVENT.TAGS.*} è stato risolto con successo in event_menu_url e event_menu\ _name campi, questo campo indica la presenza di una voce nel menu dell'evento.
evento_menu_url - string URL della voce del menu dell'evento. Supporta la macro {EVENT.TAGS.*}.
evento_menu_nome - stringa Nome della voce del menu dell'evento. Supporta la macro {EVENT.TAGS.*}.
parametri - Elemento radice per i parametri del tipo di supporto webhook.
nome x stringa Nome parametro webhook.
valore - stringa Valore parametro webhook.
Note a piè di pagina

1 Per i valori di stringa, verrà esportata solo la stringa (ad es. "EMAIL") senza la numerazione utilizzata in questa tabella. I numeri per l'intervallo valori (corrispondenti ai valori API) in questa tabella viene utilizzato per solo ordinazione.