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