zabbix_export: version: '5.4' date: '2021-11-21T22:02:58Z' groups: - uuid: 7df96b18c230490a9a0a9e2307226338 name: Templates templates: - uuid: f6939794e3cc43439d50f561c72529fb template: 's 3CX ODBC' name: 's 3CX ODBC' description: | ## Overview This tempalte is used in 3CX linux servers, it is necessary to create a postgresql ODBC connector to perform the collections and to change the {$ DSN3CX} macro to the name of the created connector. To check the DB credentials, I checked the file "/var/lib/3cxpbx/Bin/3CXSystemService.exe.config" and edit pg\_hba.conf to release remote connections. Note: only release the IP of the zabbix proxy or server for security reasons. Itens: - Discovery of trunks and extensions - Calls today, 7 days and this month Extensions: - User Extension Last Register - User Extension Status - User First Name - User Last Name - User Mail Trunks: - Gateway Host - Gateway Max Calls - Gateway Port - Number of associated routes groups: - name: Templates items: - uuid: 6a056c02adc740f1aebdc160e42e4c59 name: 'Number of Calls in the last 7 days' type: ODBC key: 'db.odbc.select[calls.7days,{$DSN3CX}]' delay: 5m params: 'SELECT count(id) FROM cl_calls where start_time >= current_date - interval ''7 day'';' tags: - tag: Application value: Calls - uuid: df56eb8583c5430c966411512e5adc2e name: 'Number of Calls in this month' type: ODBC key: 'db.odbc.select[calls.month,{$DSN3CX}]' delay: 5m params: 'SELECT count(id) FROM cl_calls where start_time::text LIKE TO_CHAR(now(),''YYYY-mm-%'');' tags: - tag: Application value: Calls - uuid: 5d8c708abd8c4d96ae0a567d58776735 name: 'Number of Calls Today' type: ODBC key: 'db.odbc.select[calls.total,{$DSN3CX}]' delay: 5m params: 'SELECT count(id) FROM cl_calls where start_time >= current_date;' tags: - tag: Application value: Calls discovery_rules: - uuid: d827108a63e54009bb4be1baded78fca name: 'Discovery Gateways' type: ODBC key: 'db.odbc.discovery[discovery.gws,{$DSN3CX}]' delay: 1h params: 'SELECT idgateway, name, model, host, port,maxlines,gatewaytype FROM gateway;' item_prototypes: - uuid: 00d28b9dd82b457180e5a375f21543e5 name: 'Gateway Host' type: ODBC key: 'db.odbc.select[gw.host-{#IDGATEWAY},{$DSN3CX}]' delay: 1h trends: '0' value_type: TEXT params: 'SELECT host FROM gateway WHERE idgateway = ''{#IDGATEWAY}'';' tags: - tag: Application value: 'Gateway : {#NAME}' - uuid: c6eb578810c64f51a9606f9e22d3fdd9 name: 'Gateway Max Calls' type: ODBC key: 'db.odbc.select[gw.max-calls-{#IDGATEWAY},{$DSN3CX}]' delay: 1h params: 'SELECT maxcalls FROM externalline WHERE fkidgateway = ''{#IDGATEWAY}'';' tags: - tag: Application value: 'Gateway : {#NAME}' - uuid: 5bf9aa51227d4e4095ffdb547a816e60 name: 'Number of associated routes' type: ODBC key: 'db.odbc.select[gw.number-routes-{#IDGATEWAY},{$DSN3CX}]' delay: 1h params: 'SELECT COUNT (*) FROM outboundroute WHERE fkidgateway = ''{#IDGATEWAY}'';' tags: - tag: Application value: 'Gateway : {#NAME}' - uuid: 87c05dacab964ac1bd365f0736b9cbe4 name: 'Gateway Port' type: ODBC key: 'db.odbc.select[gw.port-{#IDGATEWAY},{$DSN3CX}]' delay: 1h params: 'SELECT port FROM gateway WHERE idgateway = ''{#IDGATEWAY}'';' tags: - tag: Application value: 'Gateway : {#NAME}' - uuid: d4946f8ec7b849f7befd5b703a950772 name: 'Discovery Users' type: ODBC key: 'db.odbc.discovery[discovery.users,{$DSN3CX}]' delay: 1h params: 'SELECT fkidextension, firstname, lastname, value FROM users INNER JOIN dn ON (users.fkidextension = dn.iddn );' item_prototypes: - uuid: c93c1de3c7ae487aa8ca50d858539dd6 name: 'User Last Name' type: ODBC key: 'db.odbc.select[ext.user.lastname-{#FKIDEXTENSION},{$DSN3CX}]' delay: 1h trends: '0' value_type: TEXT params: 'SELECT lastname FROM users WHERE fkidextension = ''{#FKIDEXTENSION}'';' tags: - tag: Application value: 'Extension: {#VALUE}' - uuid: 82180fbe855e4ee99d455b658cdb5c79 name: 'User First Name' type: ODBC key: 'db.odbc.select[ext.username-{#FKIDEXTENSION},{$DSN3CX}]' delay: 1h trends: '0' value_type: TEXT params: 'SELECT firstname FROM users WHERE fkidextension = ''{#FKIDEXTENSION}'';' tags: - tag: Application value: 'Extension: {#VALUE}' - uuid: 93529158e1d7430db1125b60996aa2cc name: 'User Extension Last Register' type: ODBC key: 'db.odbc.select[user-last-resgister-{#FKIDEXTENSION},{$DSN3CX}]' trends: '0' value_type: TEXT params: 'SELECT timegenerated FROM eventlog WHERE params::text LIKE ''{{#VALUE},"registered,%'' ORDER BY ideventlog DESC LIMIT 1;' preprocessing: - type: JAVASCRIPT parameters: - | if(value == '') { value = 0 }return value tags: - tag: Application value: 'Extension: {#VALUE}' - uuid: 6be0969efdb44ad79703d1c4d3c0c7c9 name: 'User Extension Status' type: ODBC key: 'db.odbc.select[user-last-status-{#FKIDEXTENSION},{$DSN3CX}]' params: 'SELECT params FROM eventlog WHERE params::text LIKE ''{{#VALUE},"%registered,%'' ORDER BY ideventlog DESC LIMIT 1;' valuemap: name: '3CX Status' preprocessing: - type: REGEX parameters: - unregistered - '0' error_handler: CUSTOM_VALUE error_handler_params: '1' tags: - tag: Application value: 'Extension: {#VALUE}' - uuid: d89bb3b48ada45daad280d6c58526834 name: 'User Mail' type: ODBC key: 'db.odbc.select[user.mail-{#FKIDEXTENSION},{$DSN3CX}]' delay: 1h trends: '0' value_type: TEXT params: 'SELECT email FROM voicemail AS vm INNER JOIN users AS usr ON (vm.fkiduser = usr.iduser) WHERE fkidextension = ''{#FKIDEXTENSION}'';' preprocessing: - type: JAVASCRIPT parameters: - | if(value == '') { value = 0 }return value tags: - tag: Application value: 'Extension: {#VALUE}' macros: - macro: '{$DSN3CX}' value: 3CXDB valuemaps: - uuid: 2ee9542bed224727980bf7bf022e40a7 name: '3CX Status' mappings: - value: '0' newvalue: unregistered - value: '1' newvalue: registered