sunilwang / node-os-utils Goto Github PK
View Code? Open in Web Editor NEWOS Utils - An operating system utility library.
Home Page: https://www.npmjs.com/package/node-os-utils
License: MIT License
OS Utils - An operating system utility library.
Home Page: https://www.npmjs.com/package/node-os-utils
License: MIT License
On any machine I have tested, drive.info throws "disk name invalid and / not found". Even on Vm with single drive.
The value of usedGb from osu.drive.used() shows the freeGb instead of usedGb.
I really enjoy your npm pagage node-os-utils, but I ran into some problems using osu.drive
functions. It kept throwing Error: disk name invalid and / not found
.
So I did some debugging and found out, that you are using the df -kP
command, to gather plain text information about free disk space.
After that you parse that information by using the headline column names and iterating through the rows looking for lines[i]['Mounted on'] === diskName
. But this works only if the shell is running in english and df
prints out an english headline. Which sadly isn't the case with me (it's german):
For international support I whould like to suggest two possible fixes / updates:
return exec('LC_ALL="en_US.UTF-8";LANG="en_US.UTF-8";LANGUAGE="en_US:en";df -kP')().then(function(out) {
which whould set the language of the child process to english, so you can expect df
to output a english headline.
cp.exec('LC_ALL="en_US.UTF-8";LANG="en_US.UTF-8";LANGUAGE="en_US:en";'+command, { shell: true }, function (err, stdout, stderr) {
which whould set the language of all child processes to english, so you can expect all command outputs to be english as well.
Merry Christmas from
Niklas Englert in Germany
(sorry for bad english)
2022-07-31 17:36:52,396 ERROR 14544 Error: disk name invalid and / not found
node_modules_node-os-utils@1.3.7@node-os-utils\lib\drive.js:62:17
console.log(os.platform(), os.networkInterfaces());
linux {
lo: [
{
address: '127.0.0.1',
netmask: '255.0.0.0',
family: 'IPv4',
mac: '00:00:00:00:00:00',
internal: true,
cidr: '127.0.0.1/8'
}
],
ens160: [
{
address: '192.168.1.100',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '00:aa:bb:cc:dd:ff',
internal: false,
cidr: '192.168.1.100/24'
}
]
}
The OS,Net stats for example doesn't work and drive is giving error "disk name invalid and / not found"
I am running Homepage app (that uses this library) on Asus Tinker Board (armv7) and dietpi OS, and resources widget is showing wrong value for free memory (total is good but it's showing same value for free).
Devs of Homepage told me to open issue here.
var netstat = osu.netstat
netstat.inOut()
.then(info => {
console.log(info)
})
results:
not supported
package is signed as high severity vulnerability from npm
As described in the title this package shows a wrong count for total of capacity (128 not 256), wrong data for used (14.3 not 117.97).
Used on Apple MacBook Air M1 2020
Used with Electron 15.3.0
The function from the title is called .totalMemMb, which suggests a return value in megabit.
I found the actual return value to be in MiB, (mebibytes)
(Mb = megabit, MB = megabyte, MiB = mebibyte, there's a difference!)
Therefore I think the function name should be changed to .totalMemMib.
Line 76 in 64d8e1e
应该是:
freeMem = (parseInt(resultMemory[1], 10) + parseInt(resultMemory[3], 10) + parseInt(resultMemory[4], 10)) * 1024
括号不对,导致计算有误
Platform: Windows 10.0.19041 x64
Result:
TotalMem: 16978169856
TotalMemMb: 15.81
Expected: 16191.64MB
--
I'm guessing since .oos() reports "NOT_SUPPORTED", I'm hitting the extra /1024 at
Line 127 in 069f9cf
my macbook pro have 8 core , but osu.cpu.count() show 16 not 8.
Ref: https://git.joinfirefish.org/firefish/firefish/-/issues/10755
From our issue tracker:
What feature would you like implemented? (Please give us a brief description of what you'd like.)
Excluding IOWAIT from the CPU usage widget.
Why should we add this feature? (Please give us a brief description of why your feature is important.)
Counting IOWAIT in CPU usage can give an inaccurate representation of actual CPU load, since the CPU is idle during IOWAIT and can still process other things.
Hi,
I have an issue with drive.anything failing. I am getting the disk name invalid and / not found. I found on the net that you have fixed this before however there is another issue going on here. I have this problem going on with my ubuntu server. "df: /run/user/1000/doc: Operation not permitted"
You can read about it here: https://bugs.launchpad.net/ubuntu/+source/xdg-desktop-portal/+bug/1905623 Pardon me if you don't like links posted. My work around was to build the command line and pass it to exec.
let command = df -kP
+ diskName; then pass the drive I want as a parameter to the drive object. Then pass the command to your exec function. After that df only returns information about that particular mount with the correct header and all works fine. I cannot however run df without that error popping up.
Other than that, love what I have used so far. Thanks for the work!
Chris
Env.
Windows x64
Webpack
Desc.
All works fine until packaged, require/import error.
Chn.
在应用被Webpack打包后无法正常使用,有引入异常。暂时无法发现什么原因。
I using on Mac OS. But It not support get info network
Please help me!
My application is containerized and runs in a K8S pod, here is the snippet:
var osu = require('node-os-utils')
var cpu = osu.cpu
let cpuUtilization: number = -1;
setInterval(async function () {
cpu.usage()
.then((cpuPercentage: number) => {
cpuUtilization = cpuPercentage;
logger.info(`Updating cpu utilization to cpuUtil=${cpuUtilization}`);
});
}, 10 * 1000); // invoke every 10 seconds
Unfortunately, the library doesn't return correct value for POD utilization, the values never go over 35%, whereas on grafana dashboard Pods CPU utilization is reported to reach 100% with the CPU throttling taking place.
Is this a known issue?
Does this support multiple drives? If not, is it possible to add it somehow? :)
My english is so bad, so I may sound incoherent or rude. So I'll get right to the point. i see in the in drive.js
you are using df -kP. its a great commant for linux users (and servers) but when you try to run that on Windows console and the spam are inevitable
I check on forums and test by myself and i found the "equivalent" of df -kP
and is get-psdrive –psprovider filesystem
. Actually the command give you the Free Mem, Used Mem and Root, (not root or Administrator permission required)
well its posible to get compatibilty. just add a conditional for windows like this (or someting like this)
Lines 38 to 43 in 4136218
//required 'os' dependency
info: function (diskName) {
if (!diskName) {
diskName = '/'
}
if (os.version().toLowerCase().includes('windows')) return exec('get-psdrive –psprovider filesystem', (out) => {})
else (os.version().toLowerCase().includes('linux')) return exec('df -kP', (out) => {}) {}
i hope you have planed to add windows support on osu.drive. is very strange found good libraries with this feature.
Hello, I am getting run time error ,The error is
`
/home/localhost/scrap/node_modules/node-os-utils/index.js:1
export let cpu = undefined;
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (node:internal/modules/cjs/loader:1024:16)
at Module._compile (node:internal/modules/cjs/loader:1072:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:997:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object. (/home/masum/localhost/scrap/controller/OS/index.js:1:13)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
`
cpu.usage() only returns the percentage of usage of a single CPU core, and cpu.free() also only considers what is available for use on a single core
Almost the same as the last one, osu.drive.used usedPercentage shows freePercentage.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.