Skip to content

Commit

Permalink
Merge pull request #1606 from samson0v/issues/iotgw-376
Browse files Browse the repository at this point in the history
Added diskUsage stats
  • Loading branch information
samson0v authored Nov 22, 2024
2 parents 1497926 + 057863d commit 9784efb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions thingsboard_gateway/gateway/statistics/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
"function": StatisticsServiceFunctions.cpu_usage,
"attributeOnGateway": "totalCpuUsage"
},
{
"function": StatisticsServiceFunctions.disk_usage_perc,
"attributeOnGateway": "diskUsage"
},
{
"function": StatisticsServiceFunctions.ram_usage,
"attributeOnGateway": "freeMemory"
Expand Down
4 changes: 4 additions & 0 deletions thingsboard_gateway/gateway/statistics/service_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def total_disk_memory(_):
def total_cpu_count(_):
return os.cpu_count()

@staticmethod
def disk_usage_perc(_):
return disk_usage('/').percent

@staticmethod
def cpu_usage(_):
return cpu_percent(0.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import datetime
import subprocess
from threading import Thread, RLock, Event
from time import sleep, monotonic
from time import monotonic
from platform import system as platform_system

import simplejson
Expand Down

0 comments on commit 9784efb

Please sign in to comment.