Enhancement: Checkmk widget (#5301)

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
Dmitry Chumak 2025-05-22 20:07:53 +03:00 committed by GitHub
parent ee07a7dcbe
commit 0d47fa8215
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 86 additions and 0 deletions

View 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
```

View File

@ -1050,5 +1050,9 @@
"movies": "Movies",
"episodes": "Episodes",
"other": "Other"
},
"checkmk": {
"serviceErrors": "Service issues",
"hostErrors": "Host issues",
}
}

View File

@ -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",

View 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>
);
}

View 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;

View File

@ -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")),

View File

@ -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,