Metrics and System Info API
kevinbotlib.metrics
kevinbotlib.metrics.MetricType
Bases: IntEnum
Display types for kevinbotlib.metrics.Metric
RawType = 0
class-attribute
instance-attribute
Display the value raw
PercentageUsedType = 1
class-attribute
instance-attribute
Display the value as a percentage used. Dashboards may assume that the percentage available is 1.0 - value
PercentageRemainingType = 2
class-attribute
instance-attribute
Display the value as a percentage remaining. Dashboards may assume that the percentage used is 1.0 - value
TemperatureCelsiusType = 3
class-attribute
instance-attribute
Display the value as a temperature in Celcius. Dashboards may convert to Fahrenheit.
TemperatureFahrenheitType = 4
class-attribute
instance-attribute
Display the value as a temperature in Fahrenheit. Dashboards may convert to Celcius.
BytesType = 5
class-attribute
instance-attribute
Display the values as a number of bytes. Dashboards may convert it into human readable KB, MB, etc
BooleanType = 6
class-attribute
instance-attribute
Display the value as a boolean.
kevinbotlib.metrics.Metric
A single system metric
Examples: Memory Free, CPU Usage, CPU Temperature, etc
title
instance-attribute
The title of the metric
value = None
class-attribute
instance-attribute
The value of the metric
kind = MetricType.RawType
class-attribute
instance-attribute
How should the metric be displayed?
kevinbotlib.metrics.SystemMetrics
Keep track of various system metrics
Example metrics: CPU usage, CPU temperature, Disk usage, etc...
add(identifier, metric)
Add a new metric
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
Metric identifier. Will not be displayed in dashboards. |
required |
metric
|
Metric
|
The metric to add |
required |
update(identifier, value)
Update the value of a metric
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
The metric identifier to update |
required |
value
|
str | int | float | None
|
The new value |
required |
get(identifier)
Retrieve the value of a metric
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
Identifier of the metric to get |
required |
Returns:
Type | Description |
---|---|
Metric
|
A system metric |
getall()
Get all available system metrics
Returns:
Type | Description |
---|---|
dict[str, Metric]
|
Identifier-metric pair dictionary |
kevinbotlib.system
kevinbotlib.system.CPUInfo
CPU Information Type
cores_logical
instance-attribute
Logical cores
cores_physical
instance-attribute
Physical cores
frequency_current
instance-attribute
Current running CPU frequency
frequency_min
instance-attribute
Minimum operational CPU frequency
frequency_max
instance-attribute
Maximum operational CPU frequency
usage_percent_per_core
instance-attribute
Percent CPU usage per core
total_usage_percent
instance-attribute
Total CPU usage percentage
kevinbotlib.system.MemoryInfo
Memory Information Type
total
instance-attribute
Total memory amount (bytes)
available
instance-attribute
Total memory available (bytes)
used
instance-attribute
Total memory used (bytes)
free
instance-attribute
Total memory free (bytes)
percent
instance-attribute
Total memory used (percent)
kevinbotlib.system.DiskInfo
Disk Information Type
device
instance-attribute
Device path
mountpoint
instance-attribute
Disk mountpoint
fstype
instance-attribute
Disk filesystem type
total
instance-attribute
Total disk bytes
used
instance-attribute
Total disk space used (bytes)
free
instance-attribute
Total disk space free (bytes)
percent
instance-attribute
Total disk used (percent)
kevinbotlib.system.SystemPerformanceData
System information API