add uptime kuma integration

This commit is contained in:
2025-10-12 15:30:36 -05:00
parent 460d79c107
commit 86582c0dcc
5 changed files with 75 additions and 67 deletions

View File

@@ -1,6 +1,6 @@
# flake for blakes nixos config # flake for blakes nixos config
# define new devices in outputs # define new devices in outputs
# generation: 365, timestamp: 2025-10-12 15:04:31 # generation: 366, timestamp: 2025-10-12 15:30:09
{ {
description = "blakes nix config"; description = "blakes nix config";
inputs = { inputs = {

View File

@@ -111,6 +111,7 @@ in
curl curl
fzf fzf
fd fd
alejandra
tree tree
vim vim
lf lf

View File

@@ -105,7 +105,7 @@ in
size = "small"; size = "small";
widgets = [ widgets = [
{ type = "calendar"; first-day-of-week = "monday"; } { type = "calendar"; first-day-of-week = "monday"; }
{ type = "server-stats"; servers = [ { type = "local"; name = "violet"; } ]; } { type = "server-stats"; servers = [ { type = "local"; name = "snowbelle"; } ]; }
{ {
type = "clock"; type = "clock";
hour-format = "24h"; hour-format = "24h";
@@ -162,6 +162,15 @@ in
size = "small"; size = "small";
widgets = [ widgets = [
{ type = "weather"; location = "Pearland, Texas, United States"; units = "imperial"; hour-format = "24h"; } { type = "weather"; location = "Pearland, Texas, United States"; units = "imperial"; hour-format = "24h"; }
{
type = "custom-api";
title = "uptime";
title-url = "127.0.0.1:7901";
url = "127.0.0.1:7901/api/status-page/glance";
subrequests = {heartbeats = {url = "127.0.0.1:7901/api/status-page/heartbeat/glance";};};
cache = "10m";
template = "{{ $hb := .Subrequest \"heartbeats\" }}\n\n{{ if not (.JSON.Exists \"publicGroupList\") }}\n<p class=\"color-negative\">Error reading response</p>\n{{ else if eq (len (.JSON.Array \"publicGroupList\")) 0 }}\n<p>No monitors found</p>\n{{ else }}\n\n<ul class=\"dynamic-columns list-gap-8\">\n {{ range .JSON.Array \"publicGroupList\" }}\n {{ range .Array \"monitorList\" }}\n {{ $id := .String \"id\" }}\n {{ $hbArray := $hb.JSON.Array (print \"heartbeatList.\" $id) }}\n <div class=\"flex items-center gap-12\">\n <a class=\"size-title-dynamic color-highlight text-truncate block grow\" href=\"\${UPTIME_KUMA_URL}/dashboard/{{ $id }}\"\n target=\"_blank\" rel=\"noreferrer\">\n {{ .String \"name\" }} </a>\n\n {{ if gt (len $hbArray) 0 }}\n {{ $latest := index $hbArray (sub (len $hbArray) 1) }}\n {{ if eq ($latest.Int \"status\") 1 }}\n <div>{{ $latest.Int \"ping\" }}ms</div>\n <div class=\"monitor-site-status-icon-compact\" title=\"OK\">\n <svg fill=\"var(--color-positive)\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">\n <path fill-rule=\"evenodd\"\n d=\"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z\"\n clip-rule=\"evenodd\"></path>\n </svg>\n </div>\n {{ else }}\n <div><span class=\"color-negative\">DOWN</span></div>\n <div class=\"monitor-site-status-icon-compact\" title=\"{{ if $latest.Exists \"msg\" }}{{ $latest.String \"msg\" }}{{ else\n }}Error{{ end }}\">\n <svg fill=\"var(--color-negative)\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">\n <path fill-rule=\"evenodd\"\n d=\"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z\"\n clip-rule=\"evenodd\"></path>\n </svg>\n </div>\n {{ end }}\n {{ else }}\n <div><span class=\"color-negative\">No data</span></div>\n <div class=\"monitor-site-status-icon-compact\" title=\"No data available\">\n <svg fill=\"var(--color-negative)\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">\n <path d=\"M10 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16zm0-2a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm-.75-8a.75.75 0 0 1 1.5 0v3a.75.75 0 0 1-1.5 0V8zm.75 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2z\"/>\n </svg>\n </div>\n {{ end }}\n </div>\n {{ end }}\n {{ end }}\n</ul>\n{{ end }}\n";
}
{ {
type = "markets"; type = "markets";
markets = [ markets = [

View File

@@ -1,9 +1,11 @@
[ [
{ {
type = "custom-api"; type = "custom-api";
title = "Minecraft"; title = "Uptime Kumas";
url = "https://api.mcstatus.io/v2/status/java/\${MC_SERVER_URL}"; title-url = "\${UPTIME_KUMA_URL}";
cache = "30s"; url = "\${UPTIME_KUMA_URL}/api/status-page/\${UPTIME_KUMA_STATUS_SLUG}";
template = "<div style=\"display:flex; align-items:center; gap:12px;\">\n <div style=\"width:40px; height:40px; flex-shrink:0; border-radius:4px; display:flex; justify-content:center; align-items:center; overflow:hidden;\">\n {{ if .JSON.Bool \"online\" }}\n <img src=\"{{ .JSON.String \"icon\" | safeURL }}\" width=\"64\" height=\"64\" style=\"object-fit:contain;\">\n {{ else }}\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"width:32px; height:32px; opacity:0.5;\">\n <path fill-rule=\"evenodd\" d=\"M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\" clip-rule=\"evenodd\" />\n </svg>\n {{ end }}\n </div>\n\n <div style=\"flex-grow:1; min-width:0;\">\n <a class=\"size-h4 block text-truncate color-highlight\">\n {{ .JSON.String \"host\" }}\n {{ if .JSON.Bool \"online\" }}\n <span\n style=\"width: 8px; height: 8px; border-radius: 50%; background-color: var(--color-positive); display: inline-block; vertical-align: middle;\"\n data-popover-type=\"text\"\n data-popover-text=\"Online\"\n ></span>\n {{ else }}\n <span\n style=\"width: 8px; height: 8px; border-radius: 50%; background-color: var(--color-negative); display: inline-block; vertical-align: middle;\"\n data-popover-type=\"text\"\n data-popover-text=\"Offline\"\n ></span>\n {{ end }}\n </a>\n\n <ul class=\"list-horizontal-text\">\n <li>\n {{ if .JSON.Bool \"online\" }}\n <span>{{ .JSON.String \"version.name_clean\" }}</span>\n {{ else }}\n <span>Offline</span>\n {{ end }}\n </li>\n {{ if .JSON.Bool \"online\" }}\n <li data-popover-type=\"html\">\n <div data-popover-html>\n {{ range .JSON.Array \"players.list\" }}{{ .String \"name_clean\" }}<br>{{ end }}\n </div>\n <p style=\"display:inline-flex;align-items:center;\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" class=\"size-6\" style=\"height:1em;vertical-align:middle;margin-right:0.5em;\">\n <path fill-rule=\"evenodd\" d=\"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z\" clip-rule=\"evenodd\" />\n </svg>\n {{ .JSON.Int \"players.online\" | formatNumber }}/{{ .JSON.Int \"players.max\" | formatNumber }} players\n </p>\n </li>\n {{ else }}\n <li>\n <p style=\"display:inline-flex;align-items:center;\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" class=\"size-6\" style=\"height:1em;vertical-align:middle;margin-right:0.5em;opacity:0.5;\">\n <path fill-rule=\"evenodd\" d=\"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z\" clip-rule=\"evenodd\" />\n </svg>\n 0 players\n </p>\n </li>\n {{ end }}\n </ul>\n </div>\n</div>"; subrequests = {heartbeats = {url = "\${UPTIME_KUMA_URL}/api/status-page/heartbeat/\${UPTIME_KUMA_STATUS_SLUG}";};};
cache = "10m";
template = "{{ $hb := .Subrequest \"heartbeats\" }}\n\n{{ if not (.JSON.Exists \"publicGroupList\") }}\n<p class=\"color-negative\">Error reading response</p>\n{{ else if eq (len (.JSON.Array \"publicGroupList\")) 0 }}\n<p>No monitors found</p>\n{{ else }}\n\n<ul class=\"dynamic-columns list-gap-8\">\n {{ range .JSON.Array \"publicGroupList\" }}\n {{ range .Array \"monitorList\" }}\n {{ $id := .String \"id\" }}\n {{ $hbArray := $hb.JSON.Array (print \"heartbeatList.\" $id) }}\n <div class=\"flex items-center gap-12\">\n <a class=\"size-title-dynamic color-highlight text-truncate block grow\" href=\"\${UPTIME_KUMA_URL}/dashboard/{{ $id }}\"\n target=\"_blank\" rel=\"noreferrer\">\n {{ .String \"name\" }} </a>\n\n {{ if gt (len $hbArray) 0 }}\n {{ $latest := index $hbArray (sub (len $hbArray) 1) }}\n {{ if eq ($latest.Int \"status\") 1 }}\n <div>{{ $latest.Int \"ping\" }}ms</div>\n <div class=\"monitor-site-status-icon-compact\" title=\"OK\">\n <svg fill=\"var(--color-positive)\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">\n <path fill-rule=\"evenodd\"\n d=\"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z\"\n clip-rule=\"evenodd\"></path>\n </svg>\n </div>\n {{ else }}\n <div><span class=\"color-negative\">DOWN</span></div>\n <div class=\"monitor-site-status-icon-compact\" title=\"{{ if $latest.Exists \"msg\" }}{{ $latest.String \"msg\" }}{{ else\n }}Error{{ end }}\">\n <svg fill=\"var(--color-negative)\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">\n <path fill-rule=\"evenodd\"\n d=\"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z\"\n clip-rule=\"evenodd\"></path>\n </svg>\n </div>\n {{ end }}\n {{ else }}\n <div><span class=\"color-negative\">No data</span></div>\n <div class=\"monitor-site-status-icon-compact\" title=\"No data available\">\n <svg fill=\"var(--color-negative)\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">\n <path d=\"M10 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16zm0-2a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm-.75-8a.75.75 0 0 1 1.5 0v3a.75.75 0 0 1-1.5 0V8zm.75 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2z\"/>\n </svg>\n </div>\n {{ end }}\n </div>\n {{ end }}\n {{ end }}\n</ul>\n{{ end }}\n";
} }
] ]

View File

@@ -1,67 +1,63 @@
- type: custom-api - type: custom-api
title: Minecraft title: Uptime Kumas
url: https://api.mcstatus.io/v2/status/java/${MC_SERVER_URL} title-url: ${UPTIME_KUMA_URL}
cache: 30s url: ${UPTIME_KUMA_URL}/api/status-page/${UPTIME_KUMA_STATUS_SLUG}
subrequests:
heartbeats:
url: ${UPTIME_KUMA_URL}/api/status-page/heartbeat/${UPTIME_KUMA_STATUS_SLUG}
cache: 10m
template: | template: |
<div style="display:flex; align-items:center; gap:12px;"> {{ $hb := .Subrequest "heartbeats" }}
<div style="width:40px; height:40px; flex-shrink:0; border-radius:4px; display:flex; justify-content:center; align-items:center; overflow:hidden;">
{{ if .JSON.Bool "online" }} {{ if not (.JSON.Exists "publicGroupList") }}
<img src="{{ .JSON.String "icon" | safeURL }}" width="64" height="64" style="object-fit:contain;"> <p class="color-negative">Error reading response</p>
{{ else if eq (len (.JSON.Array "publicGroupList")) 0 }}
<p>No monitors found</p>
{{ else }}
<ul class="dynamic-columns list-gap-8">
{{ range .JSON.Array "publicGroupList" }}
{{ range .Array "monitorList" }}
{{ $id := .String "id" }}
{{ $hbArray := $hb.JSON.Array (print "heartbeatList." $id) }}
<div class="flex items-center gap-12">
<a class="size-title-dynamic color-highlight text-truncate block grow" href="${UPTIME_KUMA_URL}/dashboard/{{ $id }}"
target="_blank" rel="noreferrer">
{{ .String "name" }} </a>
{{ if gt (len $hbArray) 0 }}
{{ $latest := index $hbArray (sub (len $hbArray) 1) }}
{{ if eq ($latest.Int "status") 1 }}
<div>{{ $latest.Int "ping" }}ms</div>
<div class="monitor-site-status-icon-compact" title="OK">
<svg fill="var(--color-positive)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path fill-rule="evenodd"
d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z"
clip-rule="evenodd"></path>
</svg>
</div>
{{ else }}
<div><span class="color-negative">DOWN</span></div>
<div class="monitor-site-status-icon-compact" title="{{ if $latest.Exists "msg" }}{{ $latest.String "msg" }}{{ else
}}Error{{ end }}">
<svg fill="var(--color-negative)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path fill-rule="evenodd"
d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
clip-rule="evenodd"></path>
</svg>
</div>
{{ end }}
{{ else }} {{ else }}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width:32px; height:32px; opacity:0.5;"> <div><span class="color-negative">No data</span></div>
<path fill-rule="evenodd" d="M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z" clip-rule="evenodd" /> <div class="monitor-site-status-icon-compact" title="No data available">
</svg> <svg fill="var(--color-negative)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path d="M10 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16zm0-2a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm-.75-8a.75.75 0 0 1 1.5 0v3a.75.75 0 0 1-1.5 0V8zm.75 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
</svg>
</div>
{{ end }} {{ end }}
</div> </div>
{{ end }}
{{ end }}
</ul>
{{ end }}
<div style="flex-grow:1; min-width:0;">
<a class="size-h4 block text-truncate color-highlight">
{{ .JSON.String "host" }}
{{ if .JSON.Bool "online" }}
<span
style="width: 8px; height: 8px; border-radius: 50%; background-color: var(--color-positive); display: inline-block; vertical-align: middle;"
data-popover-type="text"
data-popover-text="Online"
></span>
{{ else }}
<span
style="width: 8px; height: 8px; border-radius: 50%; background-color: var(--color-negative); display: inline-block; vertical-align: middle;"
data-popover-type="text"
data-popover-text="Offline"
></span>
{{ end }}
</a>
<ul class="list-horizontal-text">
<li>
{{ if .JSON.Bool "online" }}
<span>{{ .JSON.String "version.name_clean" }}</span>
{{ else }}
<span>Offline</span>
{{ end }}
</li>
{{ if .JSON.Bool "online" }}
<li data-popover-type="html">
<div data-popover-html>
{{ range .JSON.Array "players.list" }}{{ .String "name_clean" }}<br>{{ end }}
</div>
<p style="display:inline-flex;align-items:center;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-6" style="height:1em;vertical-align:middle;margin-right:0.5em;">
<path fill-rule="evenodd" d="M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z" clip-rule="evenodd" />
</svg>
{{ .JSON.Int "players.online" | formatNumber }}/{{ .JSON.Int "players.max" | formatNumber }} players
</p>
</li>
{{ else }}
<li>
<p style="display:inline-flex;align-items:center;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-6" style="height:1em;vertical-align:middle;margin-right:0.5em;opacity:0.5;">
<path fill-rule="evenodd" d="M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z" clip-rule="evenodd" />
</svg>
0 players
</p>
</li>
{{ end }}
</ul>
</div>
</div>