Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's an alternative to os.loadavg() for Windows

Since os.loadavg() returns [0, 0, 0], is there any way of getting the CPU's average load in Windows based systems for 1, 5, and 15 minute intervals without having to check every few seconds and save the result yourself?

like image 824
Alexis Tyler Avatar asked Aug 29 '15 09:08

Alexis Tyler


People also ask

What is OS Loadavg?

The os. loadavg() method is an inbuilt application programming interface of the os module which is used to get load average.

Is node an operating system?

Yes, NodeOS, an operating system written in Node. js. Well, kind of. NodeOS uses the Linux kernel for most performance critical stuff like, for example, hardware interactions, but for everything else it uses Node.

How do I get node js information?

The os. version() method is used to identify the version of the kernel of the Operating System. This information is determined by calling uname on POSIX systems and calling RtlGetVersion() or GetVersionExW() on Windows systems.

Is node JS platform independent?

js is an open source software, and its installation on a server provides the Node program which itself enables JavaScript files to be executed on that server. Node. js is also cross-platform software, meaning that it is operating system independent such that it works on Linux, Windows and macOS.


2 Answers

Digging out this topic.

Use loadavg-windows from npm to enable os.loadavg() on Windows.

Wait few seconds to see first result different than 0.

like image 116
fider Avatar answered Nov 01 '22 06:11

fider


You can use the windows-cpu npm package to get similar results.

like image 28
marekful Avatar answered Nov 01 '22 06:11

marekful