Skip to content

Commit

Permalink
Fix null stats (#15)
Browse files Browse the repository at this point in the history
* null to zero network stats

* test for null value

* revert test cases

* fix null for cpu and memory
  • Loading branch information
gokhan721 authored Aug 24, 2022
1 parent 48cbba7 commit 93f572a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/statCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ async function getCPUStats(): Promise<ProcessedCPUStats> {
response.data.forEach((element: CPUStats) => {
userLoadX.push({
x: element.time,
y: element.userLoad
y: element.userLoad || 0
})

systemLoadX.push({
x: element.time,
y: element.systemLoad
y: element.systemLoad || 0
})
})

Expand All @@ -224,12 +224,12 @@ async function getMemoryStats(): Promise<ProcessedMemoryStats> {
response.data.forEach((element: MemoryStats) => {
activeMemoryX.push({
x: element.time,
y: element.activeMemoryMb
y: element.activeMemoryMb || 0
})

availableMemoryX.push({
x: element.time,
y: element.availableMemoryMb
y: element.availableMemoryMb || 0
})
})

Expand All @@ -247,16 +247,16 @@ async function getNetworkStats(): Promise<ProcessedNetworkStats> {
if (logger.isDebugEnabled()) {
logger.debug(`Got network stats: ${JSON.stringify(response.data)}`)
}

response.data.forEach((element: NetworkStats) => {
networkReadX.push({
x: element.time,
y: element.rxMb
})
y: element.rxMb || 0
})

networkWriteX.push({
x: element.time,
y: element.txMb
y: element.txMb || 0
})
})

Expand All @@ -276,12 +276,12 @@ async function getDiskStats(): Promise<ProcessedDiskStats> {
response.data.forEach((element: DiskStats) => {
diskReadX.push({
x: element.time,
y: element.rxMb
y: element.rxMb || 0
})

diskWriteX.push({
x: element.time,
y: element.wxMb
y: element.wxMb || 0
})
})

Expand Down

0 comments on commit 93f572a

Please sign in to comment.