node-os-utils 1.3.4 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/netstat.js CHANGED
@@ -106,8 +106,8 @@ bucket.netstat = {
106
106
  if(bucket.isNotSupported(out)) return ifconfigStats()
107
107
 
108
108
  var names = new RegExp(/[0-9]+: ([\S]+): /g)
109
- var RX = new RegExp(/ {4}RX: bytes {2}packets {2}errors {2}dropped overrun mcast\s*\n\s*([0-9]+) /gm)
110
- var TX = new RegExp(/ {4}TX: bytes {2}packets {2}errors {2}dropped carrier collsns\s*\n\s*([0-9]+) /g)
109
+ var RX = new RegExp(/^\s+RX:\s+bytes\s+packets\s+errors\s+dropped\s+(overrun|missed)\s+mcast\s*\n\s*([0-9]+)\s+/gm)
110
+ var TX = new RegExp(/^\s+TX:\s+bytes\s+packets\s+errors\s+dropped\s+carrier\s+collsns\s*\n\s*([0-9]+)\s+/gm)
111
111
 
112
112
  var stats = []
113
113
  var i = 0
@@ -121,7 +121,7 @@ bucket.netstat = {
121
121
 
122
122
  i = 0
123
123
  while ((res = RX.exec(out)) !== null) {
124
- stats[i++].inputBytes = res[1]
124
+ stats[i++].inputBytes = res[2]
125
125
  }
126
126
 
127
127
  i = 0
@@ -162,8 +162,8 @@ bucket.netstat = {
162
162
  for (var i = 0; i < oldStats.length; i++) {
163
163
  if (oldStats[i].interface !== 'lo' && oldStats[i].interface !== 'lo0' && oldStats[i].inputBytes > 0 && oldStats[i].outputBytes > 0) {
164
164
  metrics[oldStats[i].interface] = {}
165
- metrics[oldStats[i].interface]['inputMb'] = parseFloat(((newStats[i].inputBytes - oldStats[i].inputBytes) / interval * 1000 / 1000000).toFixed(2))
166
- metrics[oldStats[i].interface]['outputMb'] = parseFloat(((newStats[i].outputBytes - oldStats[i].outputBytes) / interval * 1000 / 1000000).toFixed(2))
165
+ metrics[oldStats[i].interface]['inputMb'] = parseFloat(((newStats[i].inputBytes - oldStats[i].inputBytes) / 1000000).toFixed(2))
166
+ metrics[oldStats[i].interface]['outputMb'] = parseFloat(((newStats[i].outputBytes - oldStats[i].outputBytes) / 1000000).toFixed(2))
167
167
 
168
168
  metrics.total['inputMb'] += parseFloat(metrics[oldStats[i].interface]['inputMb'])
169
169
  metrics.total['outputMb'] += parseFloat(metrics[oldStats[i].interface]['outputMb'])
package/lib/os.js CHANGED
@@ -99,7 +99,7 @@ bucket.os = {
99
99
  var i = 0
100
100
  try {
101
101
 
102
- if (platform === 'linux') {
102
+ if (platform === 'linux' && interfaces.eth0) {
103
103
  for (i = 0; i < interfaces.eth0.length; i++) {
104
104
  if (os.networkInterfaces().eth0[i].family === 'IPv4') {
105
105
  ip = os.networkInterfaces().eth0[i].address
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-os-utils",
3
- "version": "1.3.4",
3
+ "version": "1.3.7",
4
4
  "description": "An operating system utility library.",
5
5
  "main": "index.js",
6
6
  "scripts": {