Skip to content

Commit

Permalink
Added diskUsage stats
Browse files Browse the repository at this point in the history
  • Loading branch information
samson0v committed Nov 22, 2024
1 parent 1497926 commit 057863d
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 057863d

Please sign in to comment.