pi_portal.modules.system.metrics.SystemMetrics

class pi_portal.modules.system.metrics.SystemMetrics[source]

Bases: object

Report linux system metrics.

cpu_usage() float[source]

Report the system’s cpu utilization as a percentage.

Returns:

The percentage of the system’s cpu that is used.

Return type:

float

disk_usage(path: str) float[source]

Report the specified path’s disk utilization as a percentage.

Parameters:

path (str) – The path to report the disk utilization for.

Returns:

The percentage of the path’s disk that is used.

Return type:

float

disk_usage_threshold(path: str, threshold: float) float[source]

Report the specified path’s disk utilization as a percentage.

Parameters:
  • path (str) – The path to report the disk utilization for.

  • threshold (float) – The disk threshold (in MB) to report utilization of.

Returns:

The percentage of the path’s disk that is used, with threshold.

Return type:

float

memory_usage() float[source]

Report the system’s memory utilization as a percentage.

Returns:

The percentage of the system’s memory that is used.

Return type:

float

uptime() float[source]

Report the system’s uptime.

Returns:

The system’s uptime in seconds.

Return type:

float

uptime_naturalized() str[source]

Report the system’s uptime.

Returns:

The system’s uptime as a naturalized string.

Return type:

str