Comparing version 0.2.1 to 0.2.2
var sysinfo = require('bindings')('sysinfo'); | ||
var fs = require('fs'); | ||
console.log(sysinfo); | ||
var UPTIME_FILE = '/proc/uptime'; | ||
@@ -47,16 +49,6 @@ var STAT_FILE = '/proc/$pid/stat'; | ||
// unsigned long long total_time; /* jiffies used by this process */ | ||
// unsigned pcpu = 0; /* scaled %cpu, 999 means 99.9% */ | ||
// unsigned long long seconds; /* seconds of process life */ | ||
// unsigned int seconds_since_boot = uptime(0, 0); | ||
// total_time = pp->utime + pp->stime; | ||
// seconds = seconds_since_boot - pp->start_time / Hertz; | ||
// if(seconds) pcpu = (total_time * 1000ULL / Hertz) / seconds; | ||
// return (float) pcpu/10U; | ||
var totalTime = stat.stime + stat.utime; | ||
var seconds = uptime - stat.startTime / sysinfo.HERTZ; | ||
var pcpu = (totalTime * 1000 / sysinfo.HERTZ ) / seconds; | ||
return pcpu / 10; | ||
var totalTime = (stat.stime + stat.utime) / sysinfo.HERTZ; | ||
var processUptime = uptime - stat.startTime / sysinfo.HERTZ; | ||
var pcpu = (totalTime / processUptime) * 100; | ||
return pcpu; | ||
} | ||
@@ -63,0 +55,0 @@ |
{ | ||
"name": "usage", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "simple way to lookup linux process usage", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -0,1 +1,2 @@ | ||
[![Build Status](https://travis-ci.org/arunoda/node-usage.png?branch=master)](https://travis-ci.org/arunoda/node-usage) | ||
# node-usage | ||
@@ -5,4 +6,4 @@ | ||
* With `node-usage` we can lookup cpu and memory usage of any accessible process on the system. | ||
* This is 98% JavaScript and logic is based on [procps](http://procps.sourceforge.net/) | ||
* Simple interface to lookup cpu and memory usage of any accessible process on the system. | ||
* Written in 98% JavaScript and logic is based on [procps](http://procps.sourceforge.net/) | ||
@@ -31,4 +32,4 @@ ## Example | ||
* Some NodeJS PAAS providers do not expose us an interface to monitor CPU and Memory usage of our apps. | ||
* Some of the NodeJS PAAS providers do not expose an interface to monitor CPU and Memory usage. | ||
* They asks us to go for somewhere else for that which I don't want to go (or simply I cannot go) | ||
* So `node-usage` was born to tackle on this. |
@@ -32,5 +32,4 @@ var usage = require('../'); | ||
if(err && err.code == 'PLATFORM_NOT_SUPPORTED') { | ||
console.log(err.code); | ||
done(); | ||
if(err && err.message == 'NOT_SUPPORTED_ON_THIS_PLATFORM') { | ||
throw new Error('NOT_SUPPORTED_ON_THIS_PLATFORM'); | ||
} else { | ||
@@ -37,0 +36,0 @@ calback(err, result); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code which could be a vector to obscure malicious code, and generally decrease the likelihood of reproducible or reliable installs.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
0
100
34
1
6675
13
125