LingSys
↓ 0 downloadsYour machine's memory, GPU, motherboard and network, drawn and played in the Ling design system: LingSys, a small build for USB liquid-cooler displays, LingNet for IPv4/IPv6, DNS and packets, and a LingOS edition. 64-bit and 32-bit Windows builds included.
Keywords system-monitor, visualization, network, ipv6, gpu, lcd, lingos, ling
lingfu install LingSysCode / Files (48)
src/86_alert.ling
# ───────────────────────────── alerts ────────────────────────────────────────
# When the machine "sounds" irregular, an alarm plays whatever section you are in, and a banner names it.
# Absolute limits (memory nearly full, GPU hot or out of VRAM, hot CPU zone, a sampler gone stale,
# heavy retransmits) and sudden jumps against a slow running average (CPU load, GPU load, gateway latency).
# Each kind can fire at most once every 25 s.
bind AL_TEXT = ["MEMORY NEARLY FULL", "GPU RUNNING HOT", "GPU MEMORY FULL", "CPU ZONE HOT", "SAMPLER STALE", "GPU LOAD SPIKE", "CPU LOAD SPIKE", "LATENCY SPIKE", "PACKET RETRANSMITS"]
bind AL_SEC = [1, 2, 2, 3, 0, 2, 3, 4, 4]
bind AL_COOL = 25.0
# m = [cpu, gpu, net] as 0..1, base = their running averages plus the gateway latency average
# returns the alert number (an index into AL_TEXT) or -1
fn alert_check(m, base, bvS, gpv, lives, usedM, nvS) {
if usedM >= 0.93 { return 0 }
bind g = 0
while g < len(gpv) {
bind v = gpv[g]
if v[GV_THT] > 0.5 { return 1 }
if v[GV_TEMP] >= 88.0 { return 1 }
if v[GV_VUSED] >= 0.97 * max(v[GV_VTOTAL], 1.0) {
if v[GV_VTOTAL] > 0.0 { return 2 }
}
bind g = g + 1
}
if bvS[BV_TEMP] >= 85.0 { return 3 }
bind i = 0
while i < 4 {
if lives[i] == 2 { return 4 }
bind i = i + 1
}
if m[1] - base[1] > 0.5 { return 5 }
if m[0] - base[0] > 0.5 { return 6 }
if nvS[NV_RTT] > 0.0 {
if base[3] > 0.0 {
if nvS[NV_RTT] > 3.0 * base[3] + 150.0 { return 7 }
}
}
if lg(nvS[NV_RETX], 3.0) > 0.85 { return 8 }
return 0 - 1
}
# one beep of an alarm; left counts down. Serious alerts (0-4) are a square wave and higher.
fn alert_beep(code, left) {
bind f = 700.0
bind wave = "tri"
if left % 2 == 0 { bind f = 520.0 }
if code <= 4 {
bind wave = "square"
bind f = 1200.0
if left % 2 == 0 { bind f = 900.0 }
}
audio_sfx(0.0, 0.0, 6.0, 1.0, f, 0.12, 0.16, wave)
}
# the banner, top centre, flashing for 8 s: Z[Z_ALERT] = [text, born, section]
fn alert_banner(Z) {
bind a = Z[Z_ALERT]
bind age = Z[Z_T] - a[1]
if age < 8.0 {
if str_len(a[0]) > 0 {
bind W = Z[Z_W]
bind blink = 0.0
if floor(age * 3.0) % 2 == 0 { bind blink = 1.0 }
bind msg = "! " + a[0]
bind h = 16.0
bind w = text_w(msg, h) + 36.0
bind x = (W - w) / 2.0
col(0, 90.0, 50.0 + 30.0 * blink, 0.0)
brect(x, 10.0, 1.0, 0.0, 0.0, w, 34.0)
brect(x + 3.0, 13.0, 1.0, 0.0, 0.0, w - 6.0, 28.0)
col(0, 90.0, 66.0 + 28.0 * blink, 0.0)
daemon_text(msg, x + 18.0, 27.0, h)
}
}
}