Updates
CI / test (push) Successful in 1m4s
Release rolling / release (push) Successful in 7m14s

This commit is contained in:
Raven Scott
2026-07-18 20:01:47 -04:00
parent a639b3c953
commit 52a1823469
7 changed files with 187 additions and 32 deletions
+8 -7
View File
@@ -2,9 +2,9 @@
* Unbound DNS collector via unbound-control or remote HTTP stats.
* Enable: PEARDATA_UNBOUND=1
*/
import { spawnSync } from 'child_process'
import { CollectorPlugin } from './plugin.js'
import { registerChart } from '../../../shared/metrics.js'
import { execFileSync } from '../../utils/exec.js'
export function isUnboundEnabled() {
const v = process.env.PEARDATA_UNBOUND
@@ -40,15 +40,16 @@ export class UnboundCollector extends CollectorPlugin {
}
}
if (!Object.keys(stats).length) {
const res = spawnSync('unbound-control', ['stats_noreset'], {
encoding: 'utf8',
timeout: 2000,
})
if (res.status === 0 && res.stdout) {
for (const line of res.stdout.split('\n')) {
try {
const { stdout } = execFileSync('unbound-control', ['stats_noreset'], {
encoding: 'utf8',
})
for (const line of String(stdout || '').split('\n')) {
const [k, v] = line.split('=')
if (k && v != null && Number.isFinite(Number(v))) stats[k.trim()] = Number(v)
}
} catch {
// unbound-control unavailable
}
}
registerChart({