zabbix_export: version: '6.0' date: '2021-11-21T22:01:40Z' groups: - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6 name: Templates/Applications templates: - uuid: 2d52475f892745d79319e144072d4c9e template: 'App Rocket Chat' name: 'App Rocket Chat' description: | ## Overview **Zabbix Template Rocket Chat Statistics** ========================================== Template using Zabbix for monitoring Rocket Chat Statistics via API. **Versions** ------------ I tested this using zabbix 4.4.10 and Rocket Chat 3.5.0, but maybe it works with different versions. **Requirements** ---------------- Zabbix version > 4.4 because template is using HTTP agent and JSON Path. * If you need using it in late zabbix version, I recommend https://github.com/tristanlt/zabbix-rocketchat-stats **Installation** ---------------- * Download Zabbix template * Import the template on Zabbix * Add a Rocket Chat user which contains permissions to view-statistics * Create a rocketchat api keypair + Login user + Profile -> My Account -> Personal Access Token * Create a Personal Token + Save the ID and Token, you will need this * Create host on Zabbix and apply the template + On host configuration, modify macros{$USERAPI\_ID} and {$USERAPI\_TOKEN} with the information you saved. ## Author Felipe Vieira groups: - name: Templates/Applications items: - uuid: c52db47cd786458d8be605f76ce9f28a name: 'Rocket Chat Last Message Time ago' type: CALCULATED key: calc.lastMessage.timeDiff delay: 2m history: 14d units: s params: 'last(//rocketchat-stats[updatedAt]) - last(//rocketchat-stats[lastMessageSentAt])' description: 'Time difference between update time and last message time.' tags: - tag: Application value: 'Rocket Chat Messages' - uuid: 133a36ff74ac427bb39eb4386f50ca96 name: 'Rocket Chat Get Stats' type: HTTP_AGENT key: rocketchat-stats delay: 2m history: 14d trends: '0' value_type: TEXT timeout: 10s url: 'https://{HOST.CONN}/api/v1/statistics' query_fields: - name: refresh value: 'true' headers: - name: X-Auth-Token value: '{$USERAPI_TOKEN}' - name: X-User-Id value: '{$USERAPI_ID}' tags: - tag: Application value: 'Rocket Chat Raw Data' triggers: - uuid: e8a2e4129e4f447388094f549185701d expression: 'nodata(/App Rocket Chat/rocketchat-stats,10m)=1' name: 'Rocket Chat: Failed to fetch statistics JSON (or no data for 10m)' url: '{$ROCKETCHAT_URL}/../' priority: AVERAGE - uuid: 5e7fbcf2438a43379335b279a8302026 name: 'Rocket Chat Users - Away' type: DEPENDENT key: 'rocketchat-stats[awayUsers]' delay: '0' history: 14d units: users preprocessing: - type: JSONPATH parameters: - $.awayUsers master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Users' - uuid: 7551aa3837c64db088d457dd82a3f75d name: 'Rocket Chat Last Message Time' type: DEPENDENT key: 'rocketchat-stats[lastMessageSentAt]' delay: '0' history: 14d units: unixtime preprocessing: - type: JSONPATH parameters: - $.lastMessageSentAt - type: JAVASCRIPT parameters: - | var unixTime = parseInt((new Date(value).getTime() / 1000).toFixed(0)); return unixTime master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat Messages' - uuid: 890bca62d4cf40278020ecd6b54d3056 name: 'Rocket Chat Users - Offline' type: DEPENDENT key: 'rocketchat-stats[offlineUsers]' delay: '0' history: 14d units: users preprocessing: - type: JSONPATH parameters: - $.offlineUsers master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Users' - uuid: 56d0ad958bd7498bbb6cbd99353ee12f name: 'Rocket Chat Users - Online' type: DEPENDENT key: 'rocketchat-stats[onlineUsers]' delay: '0' history: 14d units: users preprocessing: - type: JSONPATH parameters: - $.onlineUsers master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Users' - uuid: baef8caf0fed468498e1b4013acefa10 name: 'Rocket Chat OS Memory Free' type: DEPENDENT key: 'rocketchat-stats[os.freemem]' delay: '0' history: 14d units: B preprocessing: - type: JSONPATH parameters: - $.os.freemem master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat OS' - uuid: e7eb672ef0fe43d79b3c69f9be15973a name: 'Rocket Chat OS CPU Load 1 min' type: DEPENDENT key: 'rocketchat-stats[os.load.1min]' delay: '0' history: 14d value_type: FLOAT preprocessing: - type: JSONPATH parameters: - '$.os.loadavg[0]' master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat OS' - uuid: 816b0547ccb444aba93f9fe920fc1de0 name: 'Rocket Chat OS CPU Load 5 min' type: DEPENDENT key: 'rocketchat-stats[os.load.5min]' delay: '0' history: 14d value_type: FLOAT preprocessing: - type: JSONPATH parameters: - '$.os.loadavg[1]' master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat OS' - uuid: d4624daf118b4679a07a839ead097f7e name: 'Rocket Chat OS CPU Load 15 min' type: DEPENDENT key: 'rocketchat-stats[os.load.15min]' delay: '0' history: 14d value_type: FLOAT preprocessing: - type: JSONPATH parameters: - '$.os.loadavg[2]' master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat OS' - uuid: 8f384ac41bc7488bb3af496cabb558d4 name: 'Rocket Chat OS Memory Total' type: DEPENDENT key: 'rocketchat-stats[os.totalmem]' delay: '0' history: 14d units: B preprocessing: - type: JSONPATH parameters: - $.os.totalmem master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat OS' - uuid: fd8b63d1d4d6465eb12cc7878116f460 name: 'Rocket Chat OS Uptime' type: DEPENDENT key: 'rocketchat-stats[os.uptime]' delay: '0' history: 14d units: uptime preprocessing: - type: JSONPATH parameters: - $.os.uptime master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat OS' - uuid: 2fd217c833944abfb41da09e14a340f0 name: 'Rocket Chat Channel - Messages' type: DEPENDENT key: 'rocketchat-stats[totalChannelMessages]' delay: '0' history: 14d units: msg preprocessing: - type: JSONPATH parameters: - $.totalChannelMessages - type: SIMPLE_CHANGE parameters: - '' master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: fbae8c89f2e44510a4080b7e51d3dd91 name: 'Rocket Chat Channel - Total' type: DEPENDENT key: 'rocketchat-stats[totalChannels]' delay: '0' history: 14d preprocessing: - type: JSONPATH parameters: - $.totalChannels master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: 4ef0d6d788e045b29ea62adc78da7887 name: 'Rocket Chat Direct - Messages' type: DEPENDENT key: 'rocketchat-stats[totalDirectMessages]' delay: '0' history: 14d units: msg preprocessing: - type: JSONPATH parameters: - $.totalDirectMessages - type: SIMPLE_CHANGE parameters: - '' master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: 16abb6ac145d41d68e231c73e305daf5 name: 'Rocket Chat Direct - Total' type: DEPENDENT key: 'rocketchat-stats[totalDirect]' delay: '0' history: 14d units: msg preprocessing: - type: JSONPATH parameters: - $.totalDirect master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: 144b3487eeec410d93f1e44ea701590a name: 'Rocket Chat Livechat - Messages' type: DEPENDENT key: 'rocketchat-stats[totalLivechatMessages]' delay: '0' history: 14d units: msg preprocessing: - type: JSONPATH parameters: - $.totalLivechatMessages - type: SIMPLE_CHANGE parameters: - '' master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: b728f5fe7ae348d482e572b1b0635919 name: 'Rocket Chat Livechats - Total' type: DEPENDENT key: 'rocketchat-stats[totalLivechat]' delay: '0' history: 14d preprocessing: - type: JSONPATH parameters: - $.totalLivechat master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: 4ea2e7c276e74b979867acd4917b6965 name: 'Rocket Total Messages' type: DEPENDENT key: 'rocketchat-stats[totalMessages]' delay: '0' history: 14d preprocessing: - type: JSONPATH parameters: - $.totalMessages master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: 07401148522d4989a9017584a0675707 name: 'Rocket Chat Private Group - Messages' type: DEPENDENT key: 'rocketchat-stats[totalPrivateGroupMessages]' delay: '0' history: 14d units: msg preprocessing: - type: JSONPATH parameters: - $.totalPrivateGroupMessages - type: SIMPLE_CHANGE parameters: - '' master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: f129855336ee43488567eb2dc4ae4a95 name: 'Rocket Chat Private Group - Total' type: DEPENDENT key: 'rocketchat-stats[totalPrivateGroups]' delay: '0' history: 14d preprocessing: - type: JSONPATH parameters: - $.totalPrivateGroups master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat Messages' - uuid: 4a8fcf5fc7c343eb97b5d9932fb0fb51 name: 'Rocket Chat Users - Total' type: DEPENDENT key: 'rocketchat-stats[totalUsers]' delay: '0' history: 14d units: users preprocessing: - type: JSONPATH parameters: - $.totalUsers master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat Users' - uuid: ec3c118620704dfe97cdd2275e3c7fe8 name: 'Rocket Chat Last Update' type: DEPENDENT key: 'rocketchat-stats[updatedAt]' delay: '0' history: 14d units: unixtime preprocessing: - type: JSONPATH parameters: - $._updatedAt - type: JAVASCRIPT parameters: - | var unixTime = parseInt((new Date(value).getTime() / 1000).toFixed(0)); return unixTime master_item: key: rocketchat-stats tags: - tag: Application value: 'Rocket Chat' - uuid: 08bc078a8f2e43dd8cb0e8fe90551f24 name: 'Rocket Chat Version' type: DEPENDENT key: 'rocketchat-stats[version]' delay: '0' history: 14d trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.version master_item: key: rocketchat-stats request_method: POST tags: - tag: Application value: 'Rocket Chat' triggers: - uuid: d665f39621fc4e93b3d5dc7f3d3430b2 expression: '(last(/App Rocket Chat/rocketchat-stats[version],#1)<>last(/App Rocket Chat/rocketchat-stats[version],#2))=1' name: 'Rocket Chat: Version changed to {ITEM.VALUE}' url: '{$ROCKETCHAT_URL}/../' priority: INFO macros: - macro: '{$ROCKETCHAT_URL}' value: 'https://rocket_chat.fqdn/api' - macro: '{$ROCKETCHAT_USERAPI_ID}' value: ujjdjdhhhh7822232 - macro: '{$ROCKETCHAT_USERAPI_TOKEN}' value: gf-PAT-l_W4jhddggdggsshdhdhdhkkkjfbbdbddt332 dashboards: - uuid: 52e15fda0ad74b3cb8f1a72cc0c3fd3b name: 'Rocket Chat Statistics' pages: - widgets: - type: PLAIN_TEXT width: '12' height: '5' fields: - type: INTEGER name: show_lines value: '1' - type: INTEGER name: show_as_html value: '1' - type: ITEM name: itemids value: key: 'rocketchat-stats[version]' host: 'App Rocket Chat' - type: GRAPH_CLASSIC x: '12' width: '12' height: '5' fields: - type: INTEGER name: source_type value: '1' - type: ITEM name: itemid value: key: calc.lastMessage.timeDiff host: 'App Rocket Chat' - type: GRAPH_CLASSIC 'y': '5' width: '12' height: '7' fields: - type: INTEGER name: source_type value: '0' - type: GRAPH name: graphid value: name: 'Rocket Chat OS CPU Load' host: 'App Rocket Chat' - type: GRAPH_CLASSIC x: '12' 'y': '5' width: '12' height: '7' fields: - type: INTEGER name: source_type value: '0' - type: GRAPH name: graphid value: name: 'Rocket Chat OS Memory' host: 'App Rocket Chat' - type: GRAPH_CLASSIC 'y': '12' width: '12' height: '7' fields: - type: INTEGER name: source_type value: '0' - type: GRAPH name: graphid value: name: 'Rocket Chat Messages' host: 'App Rocket Chat' - type: GRAPH_CLASSIC x: '12' 'y': '12' width: '12' height: '7' fields: - type: INTEGER name: source_type value: '0' - type: GRAPH name: graphid value: name: 'Rocket Chat Exchanges' host: 'App Rocket Chat' - type: GRAPH_CLASSIC 'y': '19' width: '12' height: '7' fields: - type: INTEGER name: source_type value: '0' - type: GRAPH name: graphid value: name: 'Rocket Chat Total Messages' host: 'App Rocket Chat' - type: GRAPH_CLASSIC x: '12' 'y': '19' width: '12' height: '7' fields: - type: INTEGER name: source_type value: '0' - type: GRAPH name: graphid value: name: 'Rocket Chat Users' host: 'App Rocket Chat' graphs: - uuid: f29bf8dd09be4cc3b64788c3640122cc name: 'Rocket Chat Exchanges' height: '300' type: STACKED graph_items: - color: BBBB00 calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[totalPrivateGroups]' - sortorder: '1' color: 2774A4 calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[totalLivechat]' - sortorder: '2' color: F63100 calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[totalChannels]' - uuid: 35a3a67fdcfe495ba08670c9d15da3ae name: 'Rocket Chat Messages' type: STACKED ymin_type_1: FIXED graph_items: - color: BBBB00 calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[totalPrivateGroupMessages]' - sortorder: '1' color: 2774A4 calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[totalLivechatMessages]' - sortorder: '2' color: F63100 calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[totalDirectMessages]' - uuid: bb39bd966a794aca8e2397fb3689bbe3 name: 'Rocket Chat OS CPU Load' graph_items: - color: 199C0D item: host: 'App Rocket Chat' key: 'rocketchat-stats[os.load.1min]' - sortorder: '1' color: F63100 item: host: 'App Rocket Chat' key: 'rocketchat-stats[os.load.5min]' - sortorder: '2' color: 2774A4 item: host: 'App Rocket Chat' key: 'rocketchat-stats[os.load.15min]' - uuid: 35448118e70c4cbcb85e8a8099e1d690 name: 'Rocket Chat OS Memory' ymin_type_1: FIXED ymax_type_1: ITEM ymax_item_1: host: 'App Rocket Chat' key: 'rocketchat-stats[os.totalmem]' graph_items: - drawtype: FILLED_REGION color: 199C0D item: host: 'App Rocket Chat' key: 'rocketchat-stats[os.freemem]' - sortorder: '1' drawtype: GRADIENT_LINE color: F63100 item: host: 'App Rocket Chat' key: 'rocketchat-stats[os.totalmem]' - uuid: 0966b03754c049f19dd1ae23a1338664 name: 'Rocket Chat Total Messages' ymin_type_1: FIXED graph_items: - drawtype: GRADIENT_LINE color: 1A7C11 calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[totalMessages]' - uuid: 6415ad7ef02241a0989e54fd58a3a53a name: 'Rocket Chat Users' height: '300' type: STACKED ymin_type_1: FIXED graph_items: - color: 303F9F calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[offlineUsers]' - sortorder: '1' color: FFD54F calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[awayUsers]' - sortorder: '2' color: 66BB6A calc_fnc: MAX item: host: 'App Rocket Chat' key: 'rocketchat-stats[onlineUsers]'