-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Zabbix service widget (#3905)
Co-Authored-By: shamoon <[email protected]>
- Loading branch information
1 parent
4c6150a
commit 44f8e9d
Showing
10 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: Zabbix | ||
description: Zabbix Widget Configuration | ||
--- | ||
|
||
Learn more about [Zabbix](https://github.com/zabbix/zabbix). | ||
|
||
See the [Zabbix documentation](https://www.zabbix.com/documentation/current/en/manual/web_interface/frontend_sections/users/api_tokens) for details on generating API tokens. | ||
|
||
The widget supports (at least) Zibbax server version 7.0. | ||
|
||
Allowed fields: `["warning", "average", "high", "disaster"]`. | ||
|
||
```yaml | ||
widget: | ||
type: zabbix | ||
url: http://zabbix.host.or.ip/zabbix | ||
key: your-api-key | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useTranslation } from "next-i18next"; | ||
|
||
import Container from "components/services/widget/container"; | ||
import Block from "components/services/widget/block"; | ||
import useWidgetAPI from "utils/proxy/use-widget-api"; | ||
|
||
const PriorityWarning = "2"; | ||
const PriorityAverage = "3"; | ||
const PriorityHigh = "4"; | ||
const PriorityDisaster = "5"; | ||
|
||
export default function Component({ service }) { | ||
const { t } = useTranslation(); | ||
const { widget } = service; | ||
|
||
const { data: zabbixData, error: zabbixError } = useWidgetAPI(widget, "trigger"); | ||
|
||
if (zabbixError) { | ||
return <Container service={service} error={zabbixError} />; | ||
} | ||
|
||
if (!zabbixData) { | ||
return ( | ||
<Container service={service}> | ||
<Block label="zabbix.warning" /> | ||
<Block label="zabbix.average" /> | ||
<Block label="zabbix.high" /> | ||
<Block label="zabbix.disaster" /> | ||
</Container> | ||
); | ||
} | ||
|
||
const warning = zabbixData.filter((item) => item.priority === PriorityWarning).length; | ||
const average = zabbixData.filter((item) => item.priority === PriorityAverage).length; | ||
const high = zabbixData.filter((item) => item.priority === PriorityHigh).length; | ||
const disaster = zabbixData.filter((item) => item.priority === PriorityDisaster).length; | ||
|
||
return ( | ||
<Container service={service}> | ||
<Block label="zabbix.warning" value={t("common.number", { value: warning })} /> | ||
<Block label="zabbix.average" value={t("common.number", { value: average })} /> | ||
<Block label="zabbix.high" value={t("common.number", { value: high })} /> | ||
<Block label="zabbix.disaster" value={t("common.number", { value: disaster })} /> | ||
</Container> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import jsonrpcProxyHandler from "utils/proxy/handlers/jsonrpc"; | ||
|
||
const widget = { | ||
api: "{url}/api_jsonrpc.php", | ||
proxyHandler: jsonrpcProxyHandler, | ||
|
||
mappings: { | ||
trigger: { | ||
endpoint: "trigger.get", | ||
params: { | ||
output: ["triggerid", "description", "priority"], | ||
filter: { | ||
value: 1, | ||
}, | ||
sortfield: "priority", | ||
sortorder: "DESC", | ||
monitored: "true", | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default widget; |