My goal is to collect and graph CPU usage for the host. I have a simple Vite project and am using vite-plugin-node-polyfills
to try to use the os
JS method. However, it just returns an empty object. I don't have any console errors. Why isn't the method able to access the underlying host?
vite-config.js:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import nodePolyfills from 'vite-plugin-node-polyfills'
// /config/
export default defineConfig({
plugins: [
react(),
nodePolyfills({
globals: {
Buffer: true,
global: true,
process: true,
},
protocolImports: true,
})],
})
My various console logs/dirs to test the data:
console.dir(os.cpus, { depth: null })
let cpus1 = os.cpus().length
let avg = os.loadavg()[0]/cpus1
let load = os.loadavg()
console.log("load "+load)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745118116a4612253.html
评论列表(0条)