Updates
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { spawnSync } from 'child_process'
|
||||
import { execFileSync } from '../../utils/exec.js'
|
||||
import { CollectorPlugin } from './plugin.js'
|
||||
import { registerChart } from '../../../shared/metrics.js'
|
||||
|
||||
@@ -106,12 +106,13 @@ export class ZfsCollector extends CollectorPlugin {
|
||||
|
||||
// zpool list -Hp
|
||||
try {
|
||||
const res = spawnSync('zpool', ['list', '-Hp', '-o', 'name,size,alloc,free,health'], {
|
||||
encoding: 'utf8',
|
||||
timeout: 2000,
|
||||
})
|
||||
if (res.status === 0 && res.stdout) {
|
||||
for (const line of res.stdout.trim().split('\n')) {
|
||||
const { stdout } = execFileSync(
|
||||
'zpool',
|
||||
['list', '-Hp', '-o', 'name,size,alloc,free,health'],
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
if (stdout) {
|
||||
for (const line of String(stdout).trim().split('\n')) {
|
||||
const [name, size, alloc, free, health] = line.split('\t')
|
||||
if (!name) continue
|
||||
const id = `zfs.pool.${name.replace(/[^\w.-]/g, '_')}`
|
||||
|
||||
Reference in New Issue
Block a user