Skip to content

Commit

Permalink
check metric values greater than zero (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhan721 authored Sep 1, 2022
1 parent 574c4c1 commit 8464823
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 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.

20 changes: 10 additions & 10 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 || 0)
value: (data.currentLoad && data.currentLoad > 0 ? data.currentLoad : 0)
},
{
unit: "Percentage",
description: "CPU Load User",
name: "cpu.load.user",
value:(data.currentLoadUser || 0)
value:(data.currentLoadUser && data.currentLoadUser > 0 ? data.currentLoadUser : 0)
},
{
unit: "Percentage",
description: "CPU Load System",
name: "cpu.load.system",
value: (data.currentLoadSystem || 0)
value: (data.currentLoadSystem && data.currentLoadSystem > 0 ? 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 || 0) / 1024 / 1024
value: (data.total && data.total > 0 ? data.total : 0) / 1024 / 1024
},
{
unit: "Mb",
description: "Memory Usage Active",
name: "memory.usage.active",
value: (data.active || 0) / 1024 / 1024
value: (data.active && data.active > 0 ? data.active : 0) / 1024 / 1024
},
{
unit: "Mb",
description: "Memory Usage Available",
name: "memory.usage.available",
value: (data.available || 0) / 1024 / 1024
value: (data.available && data.available > 0 ? 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 || 0
totalTxSec += nsd.tx_sec || 0
totalRxSec += nsd.rx_sec && nsd.rx_sec > 0 ? nsd.rx_sec : 0
totalTxSec += nsd.tx_sec && nsd.tx_sec > 0 ? nsd.tx_sec : 0
}
const points: Point[] = [
{
Expand Down Expand Up @@ -171,8 +171,8 @@ function collectDiskStats(
return si
.fsStats()
.then((data: si.Systeminformation.FsStatsData) => {
let rxSec = data.rx_sec ? data.rx_sec : 0
let wxSec = data.wx_sec ? data.wx_sec : 0
let rxSec = data.rx_sec && data.rx_sec > 0 ? data.rx_sec : 0
let wxSec = data.wx_sec && data.wx_sec > 0 ? data.wx_sec : 0

const points: Point[] = [
{
Expand Down

0 comments on commit 8464823

Please sign in to comment.