Skip to content

Sensors

richibrics edited this page Nov 16, 2020 · 8 revisions

PyMonitorMQTT has a lot of sensors that you can choose to enable/disable or pass options to.

Each sensor must be placed in the 'sensors' list in the configuration.yaml file:

sensors:
  - Ram
  - Disk
  - Cpu

To pass options to a Sensor, follow this example:

I want to set a custom_topic for the Screenshot sensor to receive the screen picture to a specific topic (test_topic/myphoto):

sensors:
  - Cpu
  - Screenshot:
        custom_topics: 
          - test_topic/myphoto
  - Disk
  - Ram

As you can see you must place ':' after the sensor name and in the next line write (as dict) the option name followed by ':' and the value.

You can find the possible options for sensors and commands in the appropriate page

Sensor list

Battery

  • Sensor name: Battery
  • Optional options:
    • formatted_values
  • Mandatory options: None
  • Compatibility: Windows, macOS, Linux
  • Description: This sensor sends information about battery. It should only be used on laptop computers.
  • Default topics:
    1. monitor/ClientName/battery/battery_level_percentage

      Send battery level percentage (0-100) [%]

    2. monitor/ClientName/battery/battery_charging

      Send True if battery is charging, else send False

Brightness

  • Sensor name: Brightness
  • Optional options:
    • formatted_values
  • Mandatory options: None
  • Compatibility: Windows, macOS
  • Description: This sensor sends screen brightness percentage . It should only be used with brightness controllable displays.
  • Default topic: monitor/ClientName/brightness/get (0-100) [%]

Cpu

  • Sensor name: Cpu
  • Optional options:
    • formatted_values
    • advanced_information
  • Mandatory options: None
  • Compatibility: Windows, macOS*, Linux
  • Description: This sensor sends information about CPU.
  • Default topics:
    1. monitor/ClientName/cpu/cpu_used_percentage

      Send the current system-wide CPU utilization as a percentage

    2. monitor/ClientName/cpu/cpu_count

      Send the number of logical CPUs in the system

    3. monitor/ClientName/cpu/cpu_times/user - Advanced

      Send time spent by normal processes executing in user mode; on Linux this also includes guest time

    4. monitor/ClientName/cpu/cpu_times/system - Advanced

      Send time spent by processes executing in kernel mode

    5. monitor/ClientName/cpu/cpu_times/idle - Advanced

      Send time spent doing nothing

    6. monitor/ClientName/cpu/cpu_stats/ctx_switches - Advanced

      Send number of context switches (voluntary + involuntary) since boot

    7. monitor/ClientName/cpu/cpu_stats/interrupts - Advanced

      Send number of interrupts since boot

    8. monitor/ClientName/cpu/cpu_freq/min - Advanced

      Send minimum CPU frequency

    9. monitor/ClientName/cpu/cpu_freq/max - Advanced

      Send maximum CPU frequency

    10. monitor/ClientName/cpu/cpu_freq/current - Advanced

      Send current CPU frequency

    11. monitor/ClientName/cpu/cpu_avg_load/1minute - Advanced*

      Send the average system load over the last minute

    12. monitor/ClientName/cpu/cpu_avg_load/5minutes - Advanced*

      Send the average system load over the last 5 minutes

    13. monitor/ClientName/cpu/cpu_avg_load/15minutes - Advanced*

      Send the average system load over the last 15 minutes

* Cpu load data not available for macOS

Information from psutil ReadTheDocs

Cpu Temperatures

  • Sensor name: CpuTemperatures
  • Optional options: None
  • Mandatory options: None
  • Compatibility: Windows, Linux
  • Description: This sensor sends
    • on Linux a list of CPU temperatures (one for core)
    • on Window a single CPU temperatures. It needs
      • an external software named 'Open Hardware Monitor' that must be running when PyMonitorMQTT is ON. Download it
      • a pip module named 'wmi'. Install it with python3 -m pip install wmi
  • Default topic: monitor/ClientName/cpu/temperatures (float or list) [°C]

Desktop Environment

  • Sensor name: DesktopEnvironment
  • Optional options:
    • contents: must be dict that contains a 'value' key. It's used to force the Monitor to use that value
  • Mandatory options: None
  • Compatibility: Windows, macOS, Linux
  • Description: This sensor sends the name of the desktop environment running; will return 'base' on Windows and macOS. Must be used if there are specific commands running to permit them to run the proper action on your system (check them in Commands page).
  • Default topic: monitor/ClientName/desktop_environment

Disk

  • Sensor name: Disk
  • Optional options:
    • formatted_values
  • Mandatory options: None
  • Compatibility: Windows, macOS, Linux
  • Description: This sensor sends the percentage of disk used. Currently it only scans the boot disk, but will be improved with more volumes possibility.
  • Default topic: monitor/ClientName/disk_used_percentage

Network

  • Sensor name: Network
  • Optional options:
    • formatted_values
  • Mandatory options: None
  • Compatibility: Windows, macOS, Linux
  • Description: This sensor sends the amount of bytes transmitted on the network, both received and sent.
  • Default topics:
    1. monitor/ClientName/network/bytes_recv

      Send the received bytes amount

    2. monitor/ClientName/network/bytes_sent

      Send the sent bytes amount

Operating System

  • Sensor name: Os
  • Optional options: None
  • Mandatory options: None
  • Compatibility: Windows, macOS, Linux
  • Description: This sensor sends the current operating system.
  • Data: possibilities are:
    • "Windows"
    • "Linux"
    • "macOS"
  • Default topic: monitor/ClientName/operating_system

Ram

  • Sensor name: Ram
  • Optional options:
    • formatted_values
    • advanced_information
  • Mandatory options: None
  • Compatibility: Windows, macOS, Linux
  • Description: This sensor sends information about RAM. All the memory values are represented in bytes.
  • Default topics:
    1. monitor/ClientName/ram/physical_memory/percentage

      Send percentage of used memory

    2. monitor/ClientName/ram/swap_memory/percentage

      Send percentage of used swap memory

    3. monitor/ClientName/ram/physical_memory/total - Advanced

      Send total physical memory

    4. monitor/ClientName/ram/physical_memory/available - Advanced

      Send the memory that can be given instantly to processes without the system going into swap

    5. monitor/ClientName/ram/physical_memory/free - Advanced

      Send the memory that isn't being used at all (zeroed) that is readily available

    6. monitor/ClientName/ram/physical_memory/used - Advanced

      Send used memory

    7. monitor/ClientName/ram/swap_memory/total - Advanced

      Send total swap memory

    8. monitor/ClientName/ram/swap_memory/used - Advanced

      Send used swap memory

    9. monitor/ClientName/ram/swap_memory/free - Advanced

      Send free swap memory

Information from psutil ReadTheDocs

Screenshot

  • Sensor name: Screenshot
  • Optional options: None
  • Mandatory options: None
  • Compatibility
    • Windows, Linux
    • macOS: to enable screen capture you have to
      1. Run the script with the Screenshot sensor enabled
      2. You will receive a privacy message. Now close the script
      3. Open computer system's settings, then enter into Security and finally into Privacy
      4. Open the lock on the bottom-left corner of the settings window
      5. Scroll until you find "Screen recording" permission
      6. In the list of apps with permission you'll find Python: ensure that the checkbox is checked
      7. Close settings and start the script
  • Description: This sensor sends a picture of the screen.
  • Policy: Who is using the computer must know he's being recorded !
  • Default topic: monitor/ClientName/screenshot

Time

  • Sensor name: Time
  • Optional options: None
  • Mandatory options: None
  • Compatibility: Windows, macOS, Linux
  • Description: This sensor sends the current time when the message is sent
  • Default topic: monitor/ClientName/message_time

Clone this wiki locally