Skip to content

Commit

Permalink
fix null data stats (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhan721 authored Aug 24, 2022
1 parent f5fe512 commit 574c4c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions dist/scw/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/scw/index.js.map

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/statCollectorWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ function collectCPUStats(
unit: "Percentage",
description: "CPU Load Total",
name: "cpu.load.total",
value: data.currentLoad
value: (data.currentLoad || 0)
},
{
unit: "Percentage",
description: "CPU Load User",
name: "cpu.load.user",
value: data.currentLoadUser
value:(data.currentLoadUser || 0)
},
{
unit: "Percentage",
description: "CPU Load System",
name: "cpu.load.system",
value: data.currentLoadSystem
value: (data.currentLoadSystem || 0)
}
]
const cpuStats: MetricStats = {
Expand Down Expand Up @@ -86,19 +86,19 @@ function collectMemoryStats(
unit: "Mb",
description: "Memory Usage Total",
name: "memory.usage.total",
value: data.total / 1024 / 1024
value: (data.total || 0) / 1024 / 1024
},
{
unit: "Mb",
description: "Memory Usage Active",
name: "memory.usage.active",
value: data.active / 1024 / 1024
value: (data.active || 0) / 1024 / 1024
},
{
unit: "Mb",
description: "Memory Usage Available",
name: "memory.usage.available",
value: data.available / 1024 / 1024
value: (data.available || 0) / 1024 / 1024
}
]
const memoryStats: MetricStats = {
Expand Down Expand Up @@ -129,8 +129,8 @@ function collectNetworkStats(
let totalRxSec = 0,
totalTxSec = 0
for (let nsd of data) {
totalRxSec += nsd.rx_sec
totalTxSec += nsd.tx_sec
totalRxSec += nsd.rx_sec || 0
totalTxSec += nsd.tx_sec || 0
}
const points: Point[] = [
{
Expand Down

0 comments on commit 574c4c1

Please sign in to comment.