Devices#
acoupi.devices
#
Acoupi devices module.
This module provides functions to retrieve information about the device on which Acoupi is running. This includes identifying the device type (currently supports Raspberry Pi), and obtaining unique identifiers like serial numbers and hostnames.
Modules:
| Name | Description |
|---|---|
audio |
|
metrics |
|
rpi |
Module for detecting and identifying devices. |
Functions:
| Name | Description |
|---|---|
get_device_id |
Get a unique identifier for the current device. |
get_device_info |
Get cached runtime information about the current device. |
get_rpi_host_name |
Get the hostname of the Raspberry Pi. |
get_rpi_serial_number |
Get the serial number of the Raspberry Pi. |
is_rpi |
Check if the current device is a Raspberry Pi. |
Classes#
Functions:#
get_device_id()
#
Get a unique identifier for the current device.
This function returns a device-specific identifier.
- If the device is a Raspberry Pi, the serial number is returned.
- Otherwise, the MAC address is used as the identifier,
retrieved via
uuid.getnode().
Returns:
| Type | Description |
|---|---|
str
|
The device ID. |
Notes
For potential limitations of using MAC addresses for identification,
refer to the [`uuid.getnode()`][uuid.getnode] documentation.
get_device_info()
cached
#
Get cached runtime information about the current device.
Returns:
| Type | Description |
|---|---|
DeviceInfo
|
Device information for the current process. If the device identifier
cannot be resolved, the returned object contains an empty |
get_rpi_host_name()
#
Get the hostname of the Raspberry Pi.
Returns:
| Type | Description |
|---|---|
The hostname of the Raspberry Pi as a string.
|
|
get_rpi_serial_number()
#
Get the serial number of the Raspberry Pi.
Returns:
| Type | Description |
|---|---|
The serial number of the Raspberry Pi as a string.
|
|
is_rpi()
#
Check if the current device is a Raspberry Pi.
Returns:
| Type | Description |
|---|---|
True if the current device is a Raspberry Pi, False otherwise.
|
|
Metrics#
acoupi.devices.metrics
#
Functions:
| Name | Description |
|---|---|
consumed_memory |
Return the resident memory used by the current process. |
get_cpu_usage |
Return the CPU usage of the current process. |
get_free_memory |
Return the currently available system memory. |
get_remaining_storage |
Return the remaining storage space for a path. |
get_used_storage |
Return the used storage space for a path. |
Functions:#
consumed_memory(name='consumed_memory')
#
Return the resident memory used by the current process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Metric name to include in the returned object. |
"consumed_memory"
|
Returns:
| Type | Description |
|---|---|
Metric
|
Metric containing process RSS memory in bytes. |
get_cpu_usage(name='cpu_usage')
#
Return the CPU usage of the current process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Metric name to include in the returned object. |
"cpu_usage"
|
Returns:
| Type | Description |
|---|---|
Metric
|
Metric containing process CPU usage as a percent. |
get_free_memory(name='free_memory')
#
Return the currently available system memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Metric name to include in the returned object. |
"free_memory"
|
Returns:
| Type | Description |
|---|---|
Metric
|
Metric containing available memory in bytes. |
get_remaining_storage(path, name='remaining_storage')
#
Return the remaining storage space for a path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path on the target filesystem. |
required |
name
|
str
|
Metric name to include in the returned object. |
"remaining_storage"
|
Returns:
| Type | Description |
|---|---|
Metric
|
Metric containing the available storage in bytes. |
get_used_storage(path, name='used_storage')
#
Return the used storage space for a path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path on the target filesystem. |
required |
name
|
str
|
Metric name to include in the returned object. |
"used_storage"
|
Returns:
| Type | Description |
|---|---|
Metric
|
Metric containing the used storage in bytes. |