-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'zabbix trigger' monitor #3972
base: master
Are you sure you want to change the base?
Conversation
If I understand it correctly, you meant this monitor will query the Zabbix API in a fixed interval like another monitors do. If yes, it is OK to be added. You can add a new monitor type here: Here is the tailscale monitor for your reference: I am still working on 2.0.0, this pr may be expected in 2.2.0. |
Let me know if assistance is needed, this would be incredible for me as I use Zabbix for our admins, and uptime kuma for our customers status pages. |
Hi, thanks for your Feedback. I already started trying out a implementation, so it shouldn't take long to finish it.
Exactly. |
* Add zabbix-trigger monitor type
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First sorry for the long review time.
Your PR somewhat got off my radar/never entered it 😅
table.text("zabbix_instance_url"); | ||
table.text("zabbix_auth_token"); | ||
table.integer("zabbix_trigger_id"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is added below in the migration
table.text("zabbix_instance_url"); | |
table.text("zabbix_auth_token"); | |
table.integer("zabbix_trigger_id"); |
const axios = require("axios"); | ||
|
||
class ZabbixTriggerMonitorType extends MonitorType { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
|
||
// Make Request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: lets link to the here docs instead
// Make Request | |
// see https://www.zabbix.com/documentation/current/en/manual/api/reference/trigger/get |
const options = { | ||
method: "post", | ||
url: monitor.zabbixInstanceUrl, | ||
data: { | ||
"jsonrpc": "2.0", | ||
"method": "trigger.get", | ||
"params": { | ||
"triggerids": monitor.zabbixTriggerId, | ||
"output": "extend", | ||
"selectFunctions": "extend", | ||
}, | ||
// Will be deprecated, but Bearer Auth is currently not working | ||
"auth": monitor.zabbixAuthToken, | ||
"id": 1 | ||
}, | ||
headers: { | ||
"Content-Type": "application/json-rpc", | ||
// In the future Authentication will use Bearer Token | ||
"Authorization": `Bearer ${monitor.zabbixAuthToken}`, | ||
} | ||
}; | ||
|
||
// Send Request & Convert Data | ||
let res = await axios(options); | ||
let data = res.data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Our codebase is mostly using the axios.post
syntax.
Lets not change this here ^^
const options = { | |
method: "post", | |
url: monitor.zabbixInstanceUrl, | |
data: { | |
"jsonrpc": "2.0", | |
"method": "trigger.get", | |
"params": { | |
"triggerids": monitor.zabbixTriggerId, | |
"output": "extend", | |
"selectFunctions": "extend", | |
}, | |
// Will be deprecated, but Bearer Auth is currently not working | |
"auth": monitor.zabbixAuthToken, | |
"id": 1 | |
}, | |
headers: { | |
"Content-Type": "application/json-rpc", | |
// In the future Authentication will use Bearer Token | |
"Authorization": `Bearer ${monitor.zabbixAuthToken}`, | |
} | |
}; | |
// Send Request & Convert Data | |
let res = await axios(options); | |
let data = res.data; | |
const options = { | |
headers: { | |
"Content-Type": "application/json-rpc", | |
// In the future Authentication will use Bearer Token | |
"Authorization": `Bearer ${monitor.zabbixAuthToken}`, | |
} | |
}; | |
const postData = { | |
"jsonrpc": "2.0", | |
"method": "trigger.get", | |
"params": { | |
"triggerids": monitor.zabbixTriggerId, | |
"output": "extend", | |
"selectFunctions": "extend", | |
}, | |
// Will be deprecated, but Bearer Auth is currently not working | |
"auth": monitor.zabbixAuthToken, | |
"id": 1 | |
}; | |
const { data } = await axios.post(monitor.zabbixInstanceUrl, postData, options); |
let data = res.data; | ||
|
||
// convert data to object | ||
if (typeof data === "string") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs don't mention that this can be a string.
=> I think this check can be removed (I have not tried to set up zabbix => idk if the json-decoding is already done at this point)
let trigger = data.result[0]; | ||
|
||
/* | ||
Zabbix Trigger Value Mapping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find a reference to this in their docs.
Are there more states that might be interesting?
The value also might be empty (at least it is in one of their examples). Do we have to pay special attention to this case?
<template v-if="monitor.type === 'zabbix-trigger'"> | ||
<div class="my-3"> | ||
<label for="zabbix_instance_url" class="form-label">{{ $t("zabbixInstanceUrl") }}</label> | ||
<input id="zabbix_instance_url" v-model="monitor.zabbixInstanceUrl" type="text" class="form-control" required /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here a placeholder what the url we expect is might be helpfull.
<input id="zabbix_instance_url" v-model="monitor.zabbixInstanceUrl" type="text" class="form-control" required /> | |
<input id="zabbix_instance_url" v-model="monitor.zabbixInstanceUrl" type="text" class="form-control" placeholder="https://example.com/zabbix/api_jsonrpc.php" required /> |
|
||
<div class="my-3"> | ||
<label for="zabbix_trigger_id" class="form-label">{{ $t("zabbixTriggerId") }}</label> | ||
<input id="zabbix_trigger_id" v-model="monitor.zabbixTriggerId" type="text" class="form-control" required /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have never used zabbix.
Is it nessesary to add a helptext how to find the triggerid?
|
||
<div class="my-3"> | ||
<label for="zabbix_auth_token" class="form-label">{{ $t("zabbixAuthToken") }}</label> | ||
<input id="zabbix_auth_token" v-model="monitor.zabbixAuthToken" type="password" class="form-control" required /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use HiddenInput
for such fields instead to communicate to our users that this is a sensitive field ^^
|
||
<div class="my-3"> | ||
<label for="zabbix_auth_token" class="form-label">{{ $t("zabbixAuthToken") }}</label> | ||
<input id="zabbix_auth_token" v-model="monitor.zabbixAuthToken" type="password" class="form-control" required /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have never used zabbix.
Is it nessesary to add a helptext how to find the auth token?
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma
Tick the checkbox if you understand [x]:
Description
I want to add a 'Zabbix Trigger' Monitor, which will query the API of a Zabbix Server and get the status of a trigger.
Resolves #1960
Why? I use uptime-kuma as a simple 'customer-side' status page. In the background there is more complex monitoring using Zabbix.
It would be nice to use the existing data & triggers from zabbix and show them in uptime-kuma, to get the true overview into the status page and not only part of the monitoring.
Type of change
Please delete any options that are not relevant.
Checklist