mirror of
https://github.com/gethomepage/homepage.git
synced 2025-05-24 02:02:35 -04:00
Enhancement: Checkmk widget (#5301)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
ee07a7dcbe
commit
0d47fa8215
17
docs/widgets/services/checkmk.md
Normal file
17
docs/widgets/services/checkmk.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Checkmk
|
||||
description: Checkmk Widget Configuration
|
||||
---
|
||||
|
||||
Learn more about [Checkmk](https://github.com/Checkmk/checkmk).
|
||||
|
||||
To setup authentication, follow the official [Checkmk API](https://docs.checkmk.com/latest/en/rest_api.html?lquery=api#bearerauth) documentation.
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: checkmk
|
||||
url: http://checkmk.host.or.ip:port
|
||||
site: your-site-name-cla-by-default
|
||||
username: username
|
||||
password: password
|
||||
```
|
@ -1050,5 +1050,9 @@
|
||||
"movies": "Movies",
|
||||
"episodes": "Episodes",
|
||||
"other": "Other"
|
||||
},
|
||||
"checkmk": {
|
||||
"serviceErrors": "Service issues",
|
||||
"hostErrors": "Host issues",
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
headers["X-CMC_PRO_API_KEY"] = `${widget.key}`;
|
||||
} else if (widget.type === "gotify") {
|
||||
headers["X-gotify-Key"] = `${widget.key}`;
|
||||
} else if (widget.type === "checkmk") {
|
||||
headers["Accept"] = `application/json`;
|
||||
headers.Authorization = `Bearer ${widget.username} ${widget.password}`;
|
||||
} else if (
|
||||
[
|
||||
"argocd",
|
||||
|
40
src/widgets/checkmk/component.jsx
Normal file
40
src/widgets/checkmk/component.jsx
Normal file
@ -0,0 +1,40 @@
|
||||
import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { data: servicesData, error: servicesError } = useWidgetAPI(widget, "services_info", {
|
||||
columns: "state",
|
||||
query: '{"op": "!=", "left": "state", "right": "0"}',
|
||||
});
|
||||
const { data: hostsData, error: hostsError } = useWidgetAPI(widget, "hosts_info", {
|
||||
columns: "state",
|
||||
query: '{"op": "!=", "left": "state", "right": "0"}',
|
||||
});
|
||||
|
||||
if (servicesError || hostsError) {
|
||||
return <Container service={service} error={servicesError ?? hostsError} />;
|
||||
}
|
||||
|
||||
if (!servicesData || !hostsData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="checkmk.serviceErrors" />
|
||||
<Block label="checkmk.hostErrors" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="checkmk.serviceErrors" value={t("common.number", { value: servicesData.value.length })} />
|
||||
<Block label="checkmk.hostErrors" value={t("common.number", { value: hostsData.value.length })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
19
src/widgets/checkmk/widget.js
Normal file
19
src/widgets/checkmk/widget.js
Normal file
@ -0,0 +1,19 @@
|
||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/{site}/check_mk/api/1.0/{endpoint}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
services_info: {
|
||||
endpoint: "domain-types/service/collections/all",
|
||||
params: ["columns", "query"],
|
||||
},
|
||||
hosts_info: {
|
||||
endpoint: "domain-types/host/collections/all",
|
||||
params: ["columns", "query"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
@ -16,6 +16,7 @@ const components = {
|
||||
calibreweb: dynamic(() => import("./calibreweb/component")),
|
||||
changedetectionio: dynamic(() => import("./changedetectionio/component")),
|
||||
channelsdvrserver: dynamic(() => import("./channelsdvrserver/component")),
|
||||
checkmk: dynamic(() => import("./checkmk/component")),
|
||||
cloudflared: dynamic(() => import("./cloudflared/component")),
|
||||
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
|
||||
crowdsec: dynamic(() => import("./crowdsec/component")),
|
||||
|
@ -13,6 +13,7 @@ import calendar from "./calendar/widget";
|
||||
import calibreweb from "./calibreweb/widget";
|
||||
import changedetectionio from "./changedetectionio/widget";
|
||||
import channelsdvrserver from "./channelsdvrserver/widget";
|
||||
import checkmk from "./checkmk/widget";
|
||||
import cloudflared from "./cloudflared/widget";
|
||||
import coinmarketcap from "./coinmarketcap/widget";
|
||||
import crowdsec from "./crowdsec/widget";
|
||||
@ -151,6 +152,7 @@ const widgets = {
|
||||
calibreweb,
|
||||
changedetectionio,
|
||||
channelsdvrserver,
|
||||
checkmk,
|
||||
cloudflared,
|
||||
coinmarketcap,
|
||||
crowdsec,
|
||||
|
Loading…
x
Reference in New Issue
Block a user