Monitor your old Linux devices
Remote Commands
Rather than having remote Linux servers send data to a central monitoring node, the central node can periodically poll the remote servers for data.
SSH can be used to run remote commands; however, SSH needs you to enter a password. Although this is fine for manual testing, for automated polling it is a problem. Two solutions to this problem are:
ssh-keygen
, which generates an SSH key pair that is stored in a user directory, enabling the standard SSH client to run without you having to enter a password.sshpass
, which is an SSH client that includes the username/password as a command-line option.
The ssh-keygen
approach is recommended for most applications because it does not expose passwords. For testing, I use the sshpass
method, and in the Node-RED project that follows, I use the ssh-keygen
approach. The sshpass
command is included in many standard distributions. To install it, enter:
sudo apt-get install sshpass
Listing 3 shows how to get CPU (line 1) and hard drive (line 13) temperatures.
Listing 3
CPU and Hard Drive Temps
01 $ sshpass -p mypassword ssh username@192.168.0.116 sensors 02 dell_smm-virtual-0 03 Adapter: Virtual device 04 Processor Fan: 3044 RPM 05 CPU: +31.0°C 06 Ambient: +33.0°C 07 SODIMM: +33.0°C 08 09 acpitz-virtual-0 10 Adapter: Virtual device 11 temp1: +51.5°C (crit = +107.0°C) 12 13 $ sshpass -p mypassword ssh username@192.168.0.116 hddtemp /dev/sda 14 /dev/sda: HTS548040M9AT00: 39°C
As you saw earlier, grep
and awk
calls can be used to show just the required values for the CPU:
$ sshpass -p mypassword ssh username@192.168.0.116 sensors | grep temp1 | awk '{print $2}' +30.5°C
and for the hard drive:
$ sshpass -p mypassword ssh username@192.168.0.116 hddtemp /dev/sda | awk '{print $3}' 39°C
At this point, a mechanism is available to get key monitoring values from remote Linux nodes. The next step is to pass these values to a Node-RED dashboard.
Node-RED Dashboard
Node-RED [4] is a web-based visual programming environment with a wide variety of nodes that can be wired together to create logic. On the Raspberry Pi platform, Node-RED is pre-installed in Raspbian images. To install Node-RED on other systems see the Get Started docs [5].
For this project I installed two nodes: bigssh, an SSH node that saves and uses ssh-keygen
credentials, and bigtimer, a timer node that schedules data polling. These components can be installed either manually or with the Manage palette menu option (Figure 2).

A basic test circuit to poll a Linux server manually and return a temperature would use an Inject, a bigssh, and a Debug node (Figure 3). The Inject node is used to pulse the logic.

By double-clicking on the bigssh node, an Edit configuration window opens. In the myssh field, you enter the username, host, and ssh-keygen
password. The bigssh node passes its first output (commandLine) to a Debug node. The Debug node sends message and payload information to the Debug tab. If the Debug node does not show the expected SSH command result, then the bigssh third output (minError) shows the error output.
After I was able to get all my SSH commands working successfully in the test logic, I changed the logic to use a bigtimer node for scheduling and some dashboard nodes for display (Figure 4). The bigtimer node has a good selection of scheduling and timing functions. Of the three Big Timer outputs, the middle output pin generates a pulse every minute.

You have the choice of a number of dashboard presentations. For a simple first pass, I used gauge and chart nodes. Double-click on each of these dashboard nodes to edit properties like labels and scales.
After the logic is complete, click the Deploy button on the right side of the menubar to run your updated project. The Node-RED web dashboard is at http://<your-node-red-ip>:1880/ui/ (Figure 5).

Final Comment
In this article, I only looked at three command-line utilities; however, many others commands could use this technique.
Infos
- iostat: http://man7.org/linux/man-pages/man1/iostat.1.html
- lm-sensors: https://github.com/lm-sensors/lm-sensors
- hddtemp: https://linux.die.net/man/8/hddtemp
- Node-RED documentation: https://flows.nodered.org/
- Getting started with Node-RED: https://nodered.org/#get-started
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
News
-
KaOS 2022.06 Now Available With KDE Plasma 5.25
The newest iteration of KaOS Linux not only adds the latest KDE Plasma desktop but sets LibreOffice as the default.
-
Manjaro 21.3.0 Is Now Available
Manjaro “Ruah” has been released and includes the latest Calamares installer, GNOME 42, and much more.
-
SpiralLinux is a New Linux Distribution Focused on Simplicity
A new Linux distribution, from the creator of GeckoLinux, is a Debian-based operating system with a focus on simplicity and ease of use.
-
HP Dev One Linux Laptop is Now Available for Pre-Order
The System76/HP collaboration Dev One laptop, geared toward developers, is now available for pre-order.
-
NixOS 22.5 Is Now Available
The latest release of NixOS with a much-improved package manager and a user-friendly graphical installer.
-
System76 Teams up with HP to Create the Dev One Laptop
HP and System76 have come together to develop a new laptop, powered by Pop!_OS and aimed toward developers.
-
Titan Linux is a New KDE Linux Based on Debian Stable
Titan Linux is a new Debian-based Linux distribution that features the KDE Plasma desktop with a focus on usability and performance.
-
Danielle Foré Has an Update for elementary OS 7
Now that Ubuntu 22.04 has been released, the team behind elementary OS is preparing for the upcoming 7.0 release.
-
Linux New Media Launches Open Source JobHub
New job website focuses on connecting technical and non-technical professionals with organizations in open source.
-
Ubuntu Cinnamon 22.04 Now Available
Ubuntu Cinnamon 22.04 has been released with all the additions from upstream as well as other features and improvements.