You guys might be disappointed if you’re waiting for any further support for the existing Glances integration.
I decided to create my own RESTful sensors for Glances CPU, Disk size, Disk utilization, GPU, and Network information, please find the below fully working example configuration with a single REST call every x seconds with respective templates for calculations.
Below, is my own personal configuration.yaml (unchanged). It took me literally months to create/refine this configuration since there wasn’t any documentation or examples floating around anywhere that I could find. You may need to tweak the disk config, since I only needed to monitor logical drive C: and E:
Good luck!
rest:
- resource: http://192.168.1.2:61208/api/3/all
sensor:
- name: Horizon C Drive Used
value_template: '{{ value_json.fs.0.percent }}'
unit_of_measurement: "%"
- name: Horizon E Drive Used
value_template: '{{ value_json.fs.1.percent }}'
unit_of_measurement: "%"
- name: diskio_0
value_template: '{{ value_json[0] | default }}'
json_attributes_path: "$.diskio.0"
json_attributes:
- time_since_update
- disk_name
- read_bytes
- write_bytes
- name: diskio_1
value_template: '{{ value_json[1] | default }}'
json_attributes_path: "$.diskio.1"
json_attributes:
- time_since_update
- disk_name
- read_bytes
- write_bytes
- name: Horizon Uptime
value_template: '{{ value_json.uptime | regex_replace(find="[\"]", replace="") | regex_replace(find="(?<=( (\d{1})|(\d{2})):\d{2}):\d{2}", replace=" hours") }}'
- name: Horizon CPU
value_template: '{{ value_json.cpu.total | round }}'
unit_of_measurement: "%"
- name: Horizon RAM
value_template: '{{ value_json.mem.percent | round }}'
unit_of_measurement: "%"
- name: Horizon Pagefile
value_template: '{{ value_json.memswap.percent | round }}'
unit_of_measurement: "%"
- name: gpu
value_template: '{{ value_json[0] | default }}'
json_attributes_path: "$.gpu.0"
json_attributes:
- name
- mem
- proc
- temperature
- name: network
value_template: '{{ value_json[0] | default }}'
json_attributes_path: "$.network.0"
json_attributes:
- interface_name
- time_since_update
- rx
- tx
- cx
verify_ssl: false
timeout: 30
scan_interval: 3
sensor:
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /home
- type: memory_use
- type: memory_use_percent
- type: processor_use
- platform: template
sensors:
horizon_c_drive_read_bytes:
value_template: >-
{% set read_byte = state_attr('sensor.diskio_0', 'read_bytes') %}
{% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
{% if (read_byte != None ) and (time_since != None ) %}
{{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
{% endif %}
availability_template: >-
{{ states("sensor.diskio_0") not in ["unknown", "unavailable", "none"] }}
unit_of_measurement: 'MB/s'
- platform: template
sensors:
horizon_c_drive_write_bytes:
value_template: >-
{% set write_byte = state_attr('sensor.diskio_0', 'write_bytes') %}
{% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
{% if (write_byte != None ) and (time_since != None ) %}
{{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
{% endif %}
availability_template: >-
{{ states("sensor.diskio_0") not in ["unknown", "unavailable", "none"] }}
unit_of_measurement: 'MB/s'
- platform: template
sensors:
horizon_e_drive_read_bytes:
value_template: >-
{% set read_byte = state_attr('sensor.diskio_1', 'read_bytes') %}
{% set time_since = state_attr('sensor.diskio_1', 'time_since_update') %}
{% if (read_byte != None ) and (time_since != None ) %}
{{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
{% endif %}
availability_template: >-
{{ states("sensor.diskio_1") not in ["unknown", "unavailable", "none"] }}
unit_of_measurement: 'MB/s'
- platform: template
sensors:
horizon_e_drive_write_bytes:
value_template: >-
{% set write_byte = state_attr('sensor.diskio_1', 'write_bytes') %}
{% set time_since = state_attr('sensor.diskio_1', 'time_since_update') %}
{% if (write_byte != None ) and (time_since != None ) %}
{{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
{% endif %}
availability_template: >-
{{ states("sensor.diskio_1") not in ["unknown", "unavailable", "none"] }}
unit_of_measurement: 'MB/s'
- platform: template
sensors:
horizon_gpu_name:
value_template: '{{ state_attr("sensor.gpu", "name") }}'
- platform: template
sensors:
horizon_gpu_memory:
value_template: '{{ state_attr("sensor.gpu", "mem") | round }}'
unit_of_measurement: "%"
- platform: template
sensors:
horizon_gpu_processor:
value_template: '{{ state_attr("sensor.gpu", "proc") }}'
unit_of_measurement: "%"
- platform: template
sensors:
horizon_gpu_temperature:
value_template: '{{ state_attr("sensor.gpu", "temperature") }}'
unit_of_measurement: "°C"
- platform: template
sensors:
horizon_download_speed:
value_template: >-
{% set receive = state_attr('sensor.network', 'rx') %}
{% set time_since = state_attr('sensor.network', 'time_since_update') %}
{% if (receive != None ) and (time_since != None ) %}
{{ ((receive | int) / (time_since | int) * 8 / 1000000) | round (2) }}
{% endif %}
availability_template: >-
{{ states("sensor.network") not in ["unknown", "unavailable", "none"] }}
unit_of_measurement: 'MB/s'
- platform: template
sensors:
horizon_upload_speed:
value_template: >-
{% set transmit = state_attr('sensor.network', 'tx') %}
{% set time_since = state_attr('sensor.network', 'time_since_update') %}
{% if (transmit != None ) and (time_since != None ) %}
{{ ((transmit | int) / (time_since | int) * 8 / 1000000) | round (2) }}
{% endif %}
availability_template: >-
{{ states("sensor.network") not in ["unknown", "unavailable", "none"] }}
unit_of_measurement: 'MB/s'
- platform: template
sensors:
horizon_total_speed:
value_template: >-
{% set total = state_attr('sensor.network', 'cx') %}
{% set time_since = state_attr('sensor.network', 'time_since_update') %}
{% if (total != None ) and (time_since != None ) %}
{{ ((total | int) / (time_since | int) * 8 / 1000000) | round (2) }}
{% endif %}
availability_template: >-
{{ states("sensor.network") not in ["unknown", "unavailable", "none"] }}
unit_of_measurement: 'MB/s'