mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 17:59:28 +08:00
add bandwidth alerts
This commit is contained in:
@@ -214,6 +214,7 @@ func (a *Agent) getSystemStats() system.Stats {
|
|||||||
a.systemInfo.MemPct = systemStats.MemPct
|
a.systemInfo.MemPct = systemStats.MemPct
|
||||||
a.systemInfo.DiskPct = systemStats.DiskPct
|
a.systemInfo.DiskPct = systemStats.DiskPct
|
||||||
a.systemInfo.Uptime, _ = host.Uptime()
|
a.systemInfo.Uptime, _ = host.Uptime()
|
||||||
|
a.systemInfo.Bandwidth = twoDecimals(systemStats.NetworkSent + systemStats.NetworkRecv)
|
||||||
|
|
||||||
return systemStats
|
return systemStats
|
||||||
}
|
}
|
||||||
|
@@ -57,6 +57,8 @@ func (am *AlertManager) HandleSystemAlerts(systemRecord *models.Record, systemIn
|
|||||||
am.handleSlidingValueAlert(systemRecord, alertRecord, name, "%", systemInfo.MemPct)
|
am.handleSlidingValueAlert(systemRecord, alertRecord, name, "%", systemInfo.MemPct)
|
||||||
case "Disk":
|
case "Disk":
|
||||||
am.handleSlidingValueAlert(systemRecord, alertRecord, name+" usage", "%", systemInfo.DiskPct)
|
am.handleSlidingValueAlert(systemRecord, alertRecord, name+" usage", "%", systemInfo.DiskPct)
|
||||||
|
case "Bandwidth":
|
||||||
|
am.handleSlidingValueAlert(systemRecord, alertRecord, name, " MB/s", systemInfo.Bandwidth)
|
||||||
case "Temperature":
|
case "Temperature":
|
||||||
if temperatures == nil {
|
if temperatures == nil {
|
||||||
continue
|
continue
|
||||||
|
@@ -61,6 +61,7 @@ type Info struct {
|
|||||||
Cpu float64 `json:"cpu"`
|
Cpu float64 `json:"cpu"`
|
||||||
MemPct float64 `json:"mp"`
|
MemPct float64 `json:"mp"`
|
||||||
DiskPct float64 `json:"dp"`
|
DiskPct float64 `json:"dp"`
|
||||||
|
Bandwidth float64 `json:"b"`
|
||||||
AgentVersion string `json:"v"`
|
AgentVersion string `json:"v"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -143,7 +143,7 @@ export default function CommandPalette() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DatabaseBackupIcon className="mr-2 h-4 w-4" />
|
<DatabaseBackupIcon className="mr-2 h-4 w-4" />
|
||||||
<span>Database backups</span>
|
<span>Backups</span>
|
||||||
<CommandShortcut>Admin</CommandShortcut>
|
<CommandShortcut>Admin</CommandShortcut>
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
<CommandItem
|
<CommandItem
|
||||||
|
@@ -164,12 +164,13 @@ export default function SystemsTable({ filter }: { filter?: string }) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'info.b',
|
accessorKey: 'info.b',
|
||||||
size: 80,
|
size: 115,
|
||||||
header: ({ column }) => sortableHeader(column, 'Net', EthernetIcon),
|
header: ({ column }) => sortableHeader(column, 'Net', EthernetIcon),
|
||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
|
const val = (info.getValue() as number) || 0
|
||||||
return (
|
return (
|
||||||
<span className="tabular-nums whitespace-nowrap pl-1">
|
<span className="tabular-nums whitespace-nowrap pl-1">
|
||||||
{decimalString((info.getValue() as number) || 0, 2)} MB/s
|
{decimalString(val, val >= 100 ? 1 : 2)} MB/s
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@@ -48,7 +48,7 @@ export default function AlertsButton({ system }: { system: SystemRecord }) {
|
|||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="max-h-full overflow-auto">
|
<DialogContent className="max-h-full overflow-auto max-w-[35rem]">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="text-xl">{system.name} alerts</DialogTitle>
|
<DialogTitle className="text-xl">{system.name} alerts</DialogTitle>
|
||||||
<DialogDescription className="mb-1">
|
<DialogDescription className="mb-1">
|
||||||
@@ -82,6 +82,14 @@ export default function AlertsButton({ system }: { system: SystemRecord }) {
|
|||||||
title="Disk Usage"
|
title="Disk Usage"
|
||||||
description="Triggers when root usage exceeds a threshold."
|
description="Triggers when root usage exceeds a threshold."
|
||||||
/>
|
/>
|
||||||
|
<AlertWithSlider
|
||||||
|
system={system}
|
||||||
|
alerts={systemAlerts}
|
||||||
|
name="Bandwidth"
|
||||||
|
title="Bandwidth"
|
||||||
|
description="Triggers when combined up/down exceeds a threshold."
|
||||||
|
unit=" MB/s"
|
||||||
|
/>
|
||||||
<AlertWithSlider
|
<AlertWithSlider
|
||||||
system={system}
|
system={system}
|
||||||
alerts={systemAlerts}
|
alerts={systemAlerts}
|
||||||
@@ -152,6 +160,7 @@ function AlertWithSlider({
|
|||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
unit = '%',
|
unit = '%',
|
||||||
|
max = 99,
|
||||||
}: {
|
}: {
|
||||||
system: SystemRecord
|
system: SystemRecord
|
||||||
alerts: AlertRecord[]
|
alerts: AlertRecord[]
|
||||||
@@ -159,6 +168,7 @@ function AlertWithSlider({
|
|||||||
title: string
|
title: string
|
||||||
description: string
|
description: string
|
||||||
unit?: string
|
unit?: string
|
||||||
|
max?: number
|
||||||
}) {
|
}) {
|
||||||
const [pendingChange, setPendingChange] = useState(false)
|
const [pendingChange, setPendingChange] = useState(false)
|
||||||
const [liveValue, setLiveValue] = useState(80)
|
const [liveValue, setLiveValue] = useState(80)
|
||||||
@@ -226,7 +236,7 @@ function AlertWithSlider({
|
|||||||
setLiveValue(val[0])
|
setLiveValue(val[0])
|
||||||
}}
|
}}
|
||||||
min={1}
|
min={1}
|
||||||
max={99}
|
max={max}
|
||||||
// step={1}
|
// step={1}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
Reference in New Issue
Block a user