mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-27 16:06:16 +01:00
updates
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/fnv"
|
"hash/fnv"
|
||||||
"log/slog"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -152,8 +151,7 @@ func (sys *System) createRecords(data *system.CombinedData) (*core.Record, error
|
|||||||
hub := sys.manager.hub
|
hub := sys.manager.hub
|
||||||
err = hub.RunInTransaction(func(txApp core.App) error {
|
err = hub.RunInTransaction(func(txApp core.App) error {
|
||||||
if data.Details != nil {
|
if data.Details != nil {
|
||||||
slog.Info("Static info", "data", data.Details)
|
if err := createSystemDetailsRecord(txApp, data.Details, sys.Id); err != nil {
|
||||||
if err := createStaticInfoRecord(txApp, data.Details, sys.Id); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,28 +216,29 @@ func (sys *System) createRecords(data *system.CombinedData) (*core.Record, error
|
|||||||
return systemRecord, err
|
return systemRecord, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func createStaticInfoRecord(app core.App, data *system.Details, systemId string) error {
|
func createSystemDetailsRecord(app core.App, data *system.Details, systemId string) error {
|
||||||
record, err := app.FindRecordById("system_details", systemId)
|
params := dbx.Params{
|
||||||
if err != nil {
|
"id": systemId,
|
||||||
collection, err := app.FindCollectionByNameOrId("system_details")
|
"system": systemId,
|
||||||
if err != nil {
|
"hostname": data.Hostname,
|
||||||
return err
|
"kernel": data.Kernel,
|
||||||
}
|
"cores": data.Cores,
|
||||||
record = core.NewRecord(collection)
|
"threads": data.Threads,
|
||||||
record.Set("id", systemId)
|
"cpu": data.CpuModel,
|
||||||
|
"os": data.Os,
|
||||||
|
"os_name": data.OsName,
|
||||||
|
"arch": data.Arch,
|
||||||
|
"memory": data.MemoryTotal,
|
||||||
|
"podman": data.Podman,
|
||||||
|
"updated": time.Now().UTC(),
|
||||||
}
|
}
|
||||||
record.Set("system", systemId)
|
queryString := `INSERT INTO system_details (id, system, hostname, kernel, cores, threads, cpu, os, os_name, arch, memory, podman, updated)
|
||||||
record.Set("hostname", data.Hostname)
|
VALUES ({:id}, {:system}, {:hostname}, {:kernel}, {:cores}, {:threads}, {:cpu}, {:os}, {:os_name}, {:arch}, {:memory}, {:podman}, {:updated})
|
||||||
record.Set("kernel", data.Kernel)
|
ON CONFLICT(id) DO UPDATE SET system = excluded.system, hostname = excluded.hostname, kernel = excluded.kernel, cores = excluded.cores,
|
||||||
record.Set("cores", data.Cores)
|
threads = excluded.threads, cpu = excluded.cpu, os = excluded.os, os_name = excluded.os_name, arch = excluded.arch,
|
||||||
record.Set("threads", data.Threads)
|
memory = excluded.memory, podman = excluded.podman, updated = excluded.updated`
|
||||||
record.Set("cpu", data.CpuModel)
|
_, err := app.DB().NewQuery(queryString).Bind(params).Execute()
|
||||||
record.Set("os", data.Os)
|
return err
|
||||||
record.Set("os_name", data.OsName)
|
|
||||||
record.Set("arch", data.Arch)
|
|
||||||
record.Set("memory", data.MemoryTotal)
|
|
||||||
record.Set("podman", data.Podman)
|
|
||||||
return app.SaveNoValidate(record)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createSystemdStatsRecords(app core.App, data []*systemd.Service, systemId string) error {
|
func createSystemdStatsRecords(app core.App, data []*systemd.Service, systemId string) error {
|
||||||
|
|||||||
@@ -33,10 +33,7 @@
|
|||||||
"noUnusedFunctionParameters": "error",
|
"noUnusedFunctionParameters": "error",
|
||||||
"noUnusedPrivateClassMembers": "error",
|
"noUnusedPrivateClassMembers": "error",
|
||||||
"useExhaustiveDependencies": {
|
"useExhaustiveDependencies": {
|
||||||
"level": "warn",
|
"level": "off"
|
||||||
"options": {
|
|
||||||
"reportUnnecessaryDependencies": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"useUniqueElementIds": "off",
|
"useUniqueElementIds": "off",
|
||||||
"noUnusedVariables": "error"
|
"noUnusedVariables": "error"
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
import ChartTimeSelect from "@/components/charts/chart-time-select"
|
import { plural } from "@lingui/core/macro"
|
||||||
import { Button } from "@/components/ui/button"
|
import { useLingui } from "@lingui/react/macro"
|
||||||
import { Card } from "@/components/ui/card"
|
|
||||||
import { FreeBsdIcon, TuxIcon, WebSocketIcon, WindowsIcon } from "@/components/ui/icons"
|
|
||||||
import { SystemStatus, ConnectionType, connectionTypeLabels, Os } from "@/lib/enums"
|
|
||||||
import { cn, formatBytes, getHostDisplayValue, secondsToString, toFixedFloat } from "@/lib/utils"
|
|
||||||
import { Separator } from "@/components/ui/separator"
|
|
||||||
import {
|
import {
|
||||||
AppleIcon,
|
AppleIcon,
|
||||||
ChevronRightSquareIcon,
|
ChevronRightSquareIcon,
|
||||||
@@ -12,16 +7,21 @@ import {
|
|||||||
CpuIcon,
|
CpuIcon,
|
||||||
GlobeIcon,
|
GlobeIcon,
|
||||||
LayoutGridIcon,
|
LayoutGridIcon,
|
||||||
|
MemoryStickIcon,
|
||||||
MonitorIcon,
|
MonitorIcon,
|
||||||
Rows,
|
Rows,
|
||||||
MemoryStickIcon,
|
|
||||||
} from "lucide-react"
|
} from "lucide-react"
|
||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
|
|
||||||
import type { ChartData, SystemDetailsRecord, SystemRecord } from "@/types"
|
|
||||||
import { useEffect, useMemo, useState } from "react"
|
import { useEffect, useMemo, useState } from "react"
|
||||||
import { useLingui } from "@lingui/react/macro"
|
import ChartTimeSelect from "@/components/charts/chart-time-select"
|
||||||
|
import { Button } from "@/components/ui/button"
|
||||||
|
import { Card } from "@/components/ui/card"
|
||||||
|
import { FreeBsdIcon, TuxIcon, WebSocketIcon, WindowsIcon } from "@/components/ui/icons"
|
||||||
|
import { Separator } from "@/components/ui/separator"
|
||||||
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
|
||||||
import { pb } from "@/lib/api"
|
import { pb } from "@/lib/api"
|
||||||
import { plural } from "@lingui/core/macro"
|
import { ConnectionType, connectionTypeLabels, Os, SystemStatus } from "@/lib/enums"
|
||||||
|
import { cn, formatBytes, getHostDisplayValue, secondsToString, toFixedFloat } from "@/lib/utils"
|
||||||
|
import type { ChartData, SystemDetailsRecord, SystemRecord } from "@/types"
|
||||||
|
|
||||||
export default function InfoBar({
|
export default function InfoBar({
|
||||||
system,
|
system,
|
||||||
@@ -41,6 +41,7 @@ export default function InfoBar({
|
|||||||
|
|
||||||
// Fetch system_details on mount / when system changes
|
// Fetch system_details on mount / when system changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
let active = true
|
||||||
setDetails(null)
|
setDetails(null)
|
||||||
// skip fetching system details if agent is older version which includes details in Info struct
|
// skip fetching system details if agent is older version which includes details in Info struct
|
||||||
if (!system.id || system.info?.m) {
|
if (!system.id || system.info?.m) {
|
||||||
@@ -54,10 +55,16 @@ export default function InfoBar({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((details) => {
|
.then((details) => {
|
||||||
setDetails(details)
|
if (active) {
|
||||||
setIsPodman(details.podman)
|
setDetails(details)
|
||||||
|
setIsPodman(details.podman)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => setDetails(null))
|
.catch(() => {})
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
active = false
|
||||||
|
}
|
||||||
}, [system.id])
|
}, [system.id])
|
||||||
|
|
||||||
// values for system info bar - use details with fallback to system.info
|
// values for system info bar - use details with fallback to system.info
|
||||||
|
|||||||
Reference in New Issue
Block a user