Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added diskUsage stats #1606

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading