Updates
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user