From 792f768a7f0f929bf1b94def9e9d5cd9ebef53fc Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 20 Oct 2023 00:09:33 -0700 Subject: [PATCH] Feature: true ping, rename old ping to siteMonitor (#2215) --- docs/configs/services.md | 34 ++++++++++--- docs/configs/settings.md | 8 +-- package-lock.json | 9 ++++ package.json | 1 + pnpm-lock.yaml | 8 +++ public/locales/en/common.json | 9 +++- src/components/services/item.jsx | 8 +++ src/components/services/ping.jsx | 19 +++---- src/components/services/site-monitor.jsx | 63 ++++++++++++++++++++++++ src/pages/api/ping.js | 38 ++++++-------- src/pages/api/siteMonitor.js | 52 +++++++++++++++++++ src/utils/config/service-helpers.js | 3 ++ 12 files changed, 205 insertions(+), 47 deletions(-) create mode 100644 src/components/services/site-monitor.jsx create mode 100644 src/pages/api/siteMonitor.js diff --git a/docs/configs/services.md b/docs/configs/services.md index 3a099e631..89b9cdbdd 100644 --- a/docs/configs/services.md +++ b/docs/configs/services.md @@ -101,30 +101,50 @@ To use a local icon, first create a Docker mount to `/app/public/icons` and then ## Ping -Services may have an optional `ping` property that allows you to monitor the availability of an endpoint you chose and have the response time displayed. You do not need to set your ping URL equal to your href URL. - -!!! note - - The ping feature works by making an http `HEAD` request to the URL, and falls back to `GET` in case that fails. It will not, for example, login if the URL requires auth or is behind e.g. Authelia. In the case of a reverse proxy and/or auth this usually requires the use of an 'internal' URL to make the ping feature correctly display status. +Services may have an optional `ping` property that allows you to monitor the availability of an external host. As of v0.7.5, the ping feature uses the true ping command on the underlying host. ```yaml - Group A: - Sonarr: icon: sonarr.png href: http://sonarr.host/ - ping: http://sonarr.host/ + ping: sonarr.host - Group B: - Radarr: icon: radarr.png href: http://radarr.host/ - ping: http://some.other.host/ + ping: some.other.host ``` Ping You can also apply different styles to the ping indicator by using the `statusStyle` property, see [settings](settings.md#status-style). +## Site Monitor + +Services may have an optional `siteMonitor` property (formerly `ping`) that allows you to monitor the availability of a URL you chose and have the response time displayed. You do not need to set your monitor URL equal to your href or ping URL. + +!!! note + + The site monitor feature works by making an http `HEAD` request to the URL, and falls back to `GET` in case that fails. It will not, for example, login if the URL requires auth or is behind e.g. Authelia. In the case of a reverse proxy and/or auth this usually requires the use of an 'internal' URL to make the site monitor feature correctly display status. + +```yaml +- Group A: + - Sonarr: + icon: sonarr.png + href: http://sonarr.host/ + siteMonitor: http://sonarr.host/ + +- Group B: + - Radarr: + icon: radarr.png + href: http://radarr.host/ + siteMonitor: http://some.other.host/ +``` + +You can also apply different styles to the site monitor indicator by using the `statusStyle` property, see [settings](settings.md#status-style). + ## Docker Integration Services may be connected to a Docker container, either running on the local machine, or a remote machine. diff --git a/docs/configs/settings.md b/docs/configs/settings.md index f2c179342..f366b2040 100644 --- a/docs/configs/settings.md +++ b/docs/configs/settings.md @@ -382,11 +382,11 @@ If you have both set the per-service settings take precedence. ## Status Style -You can choose from the following styles for docker or k8s status and ping: `dot` or `basic` +You can choose from the following styles for docker or k8s status, site monitor and ping: `dot` or `basic` -- The default is no value, and displays the ping response time in ms and the docker / k8s container status -- `dot` shows a green dot for a successful ping or healthy status. -- `basic` shows either UP or DOWN for ping +- The default is no value, and displays the montior and ping response time in ms and the docker / k8s container status +- `dot` shows a green dot for a successful monitor ping or healthy status. +- `basic` shows either UP or DOWN for monitor & ping For example: diff --git a/package-lock.json b/package-lock.json index 904d337cf..16e2ed684 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "minecraft-ping-js": "^1.0.2", "next": "^12.3.1", "next-i18next": "^12.0.1", + "ping": "^0.4.4", "pretty-bytes": "^6.0.0", "raw-body": "^2.5.1", "react": "^18.2.0", @@ -4861,6 +4862,14 @@ "node": ">=0.10.0" } }, + "node_modules/ping": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/ping/-/ping-0.4.4.tgz", + "integrity": "sha512-56ZMC0j7SCsMMLdOoUg12VZCfj/+ZO+yfOSjaNCRrmZZr6GLbN2X/Ui56T15dI8NhiHckaw5X2pvyfAomanwqQ==", + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/pirates": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", diff --git a/package.json b/package.json index cc4805a5d..0b10fedf6 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "minecraft-ping-js": "^1.0.2", "next": "^12.3.1", "next-i18next": "^12.0.1", + "ping": "^0.4.4", "pretty-bytes": "^6.0.0", "raw-body": "^2.5.1", "react": "^18.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 197c559c2..335da832d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,6 +50,9 @@ dependencies: next-i18next: specifier: ^12.0.1 version: 12.1.0(next@12.3.4)(react-dom@18.2.0)(react@18.2.0) + ping: + specifier: ^0.4.4 + version: 0.4.4 pretty-bytes: specifier: ^6.0.0 version: 6.1.0 @@ -3103,6 +3106,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /ping@0.4.4: + resolution: {integrity: sha512-56ZMC0j7SCsMMLdOoUg12VZCfj/+ZO+yfOSjaNCRrmZZr6GLbN2X/Ui56T15dI8NhiHckaw5X2pvyfAomanwqQ==} + engines: {node: '>=4.0.0'} + dev: false + /pirates@4.0.5: resolution: {integrity: sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==} engines: {node: '>= 6'} diff --git a/public/locales/en/common.json b/public/locales/en/common.json index cd6012f8a..dd14a58e5 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -79,13 +79,20 @@ "partial": "Partial" }, "ping": { - "http_status": "HTTP status", "error": "Error", "ping": "Ping", "down": "Down", "up": "Up", "not_available": "Not Available" }, + "siteMonitor": { + "http_status": "HTTP status", + "error": "Error", + "response": "Response", + "down": "Down", + "up": "Up", + "not_available": "Not Available" + }, "emby": { "playing": "Playing", "transcoding": "Transcoding", diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index e4dff6b23..d9d962abd 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -4,6 +4,7 @@ import { useContext, useState } from "react"; import Status from "./status"; import Widget from "./widget"; import Ping from "./ping"; +import SiteMonitor from "./site-monitor"; import KubernetesStatus from "./kubernetes-status"; import Docker from "widgets/docker/component"; @@ -93,6 +94,13 @@ export default function Item({ service, group }) { )} + {service.siteMonitor && ( +
+ + Site monitor status +
+ )} + {service.container && (