README.md 5.12 KB

Overview

A simple machine monitor and performance stats utility written in Python for Linux systems.

Gathers system performance data and outputs to terminal (for debugging purposes) or to a USB/Serial LCD display such as the Adafruit USB/Serial shield and 19x2 LCD module.

The use of this is slanted towards embedded Linux platforms that run headless, in the specific case the data acquisition class also gathers information related to the status of running services related to OpenStack for test micro VM systems.

The Python classes require the following packages: socket urllib psutil

Useage

Edit the settings.py configuration file to your requirements. Use the run.py file to start a single instance of the LCD output display. The run.sh script contains a simple shell script while loop to reconnect the LCD module if it is disconnected, or not present at start up.

To automatically run on boot, add the following line to /etc/rc.local

bash run.sh 2>&1 | tee /var/log/lcd.log

Settings

INTERVAL - How many loop counts between display refresh and data gathering. A value of 1 is the minimum and means to gather new performance data between each display refresh. This also consumes the most CPU time. Takes: int

SERVICE_INTERVAL - How many loop counts between refreshing system service health data. These are mostly gathering through relatively crude mechanisms such as os.system(), and the checks themselves may be quite long (e.g. connecting to MySQL, or retriving a HTML page from Apache) so don't set this value too low, or your display will constantly pause while refreshing this health information. Takes: int

ZAP_INTERVAL - How often to reset the counters used for IO or system load calculations. Mainly used to prevent memory ballooning; shouldn't need to be altered. Takes: int

DETAIL_1_INTERVAL through DETAIL_4_INTERVAL - Controls how many display loops until the display progresses to the next page. The cycle is: CPU and IP Address, CPU and System Load Average, CPU and Disk space and then finally CPU and RAM use. The display then loops around back to CPU and IP Address. Takes: int

DETAIL_DURATION - How long (in refresh loops) each of the four detail pages is shown, before cycling back to the main (read: first) page. Takes: int

DISK_PATH - A path that is used to check for space useage, as displayed in the DETAIL_3_INTERVAL page. NFS. Takes: string

NFS_PATH - A path that we should check is mounted correctly over NFS. Takes: string

ETH_DEVICE - The primary network interface of the machine, the device which we assume has the primary IP address used to display in the DETAIL_1_INTERVAL page. Takes: string

ETH_DEVICE - A list of all network interfaces which should be up, configured and connected for the machine. If either unconfigured, disconnected or otherwise unavailable, an error is raised. Takes: Python list of strings

DISPLAY_WIDTH - The number of characters shown on an output device (terminal or LCD) before scrolling the display right to left. Takes: int

SCROLL_SPEED - Time (in seconds) to pause between right to left scrolling refresh. Takes: int OR float

SERVICE_CHECK_TYPE - This parameter affects whether service checks are carried out from a client or server perspective. For example, the checks for a Nova or Neutron client are fundamentally different than if the machine is hosting those services. Similarly, NFS client checks are different than when checking for the Kernel NFS server. See the section in data.py that lists the service checks for more information. Takes: "server" OR "client"

SERVICE_CHECKS - A list of the service checks that should be run for this particular host. Takes: Python list of strings.

ERR_ Messages - Preset error text that is shown when a service or health check is failed. Customise as required. Takes: string

CPU_PEAK - Controls the colour of the LCD screen when the CPU is considered to be at the highest level of load.

CPU_HIGH - Controls the colour of the LCD screen when CPU use rises above a set value classed as high. Takes: Python dictionary with the keys 'level' - CPU use level, above which activates this colour scheme, 'r' - Red LED intensity, 'g' - Green LED intensity, 'b' - Blue LED intensity.

CPU_MED - Controls the colour of the LCD screen when CPU use rises above a set value classed as medium. Takes: Python dictionary with the keys 'level' - CPU use level, above which activates this colour scheme, 'r' - Red LED intensity, 'g' - Green LED intensity, 'b' - Blue LED intensity.

CPU_LOW - Controls the colour of the LCD screen when CPU use rises above a set value classed as low. Takes: Python dictionary with the keys 'level' - CPU use level, above which activates this colour scheme, 'r' - Red LED intensity, 'g' - Green LED intensity, 'b' - Blue LED intensity.

CPU_IDLE - Controls the colour of the LCD screen when CPU use falls below a set value classed as idle. Takes: Python dictionary with the keys 'level' - CPU use level, below which activates this colour scheme, 'r' - Red LED intensity, 'g' - Green LED intensity, 'b' - Blue LED intensity.

Author

John Snowdon (john.snowdon@newcastle.ac.uk) December 2015, updated October 2016.