You can easily monitor and manage multiple Linux computers with Cockpit, a browser-based administration and dashboard tool. It̵
Managing multiple Linux servers
If you have to monitor multiple Linux computers or servers, you have a challenge. This is especially true if some of them run as headless systems without a monitor attached. For example, you have rack-mounted or remote servers in different buildings or a collection of Raspberry Pis scattered around your house.
How can you monitor the health and performance of all of these?
If you are using Secure Shell (SSH) to connect to this, you can
top or another terminal-based monitoring tool. You will get some useful information, but each tool has its own specific area of interest. It’s a pain to have to move from tool to tool to view the various statistics of your remote Linux computer.
Unfortunately, there is no easy way to jump between the different tools that give you some of that information. And if you need to perform any remedial or administrative tasks, you must create a new connection to the remote computer or close the monitoring application. Then you need to use your existing SSH session to perform your management commands.
Cockpit ties many common monitoring and management requirements to a browser-based console, making it easier to monitor and maintain multiple Linux computers.
Cockpit gets its information from Application Programming Interfaces (APIs) that already exist within Linux. Because the information comes directly from the source, there is no custom collection or generation of the information, so it can be considered unadulterated.
Cockpit and User Accounts
Cockpit uses your Linux credentials, so you don’t need to configure users in it. To log in to Cockpit, simply use your username and current password. If you have accounts on different Linux computers that use the same username and password, Cockpit uses those credentials to connect to the remote machines.
Using the same password on different computers is of course a security risk and considered bad practice. However, if you only work with local computers that are not exposed to the Internet, you could conclude that the risk is small enough.
However, a much better solution is to set up SSH keys on each computer and then let Cockpit use them to connect to the remote computers.
RELATED: Create and install SSH keys from the Linux shell
Cockpit is in the core repositories for the major Linux families. To install Cockpit on Ubuntu, type the following:
sudo apt-get install cockpit
On Fedora the command is:
sudo dnf install cockpit
On Manjaro you have to install Cockpit and a package called
packagekit. This cross-platform package sits on top of the native package management system of a Linux distribution. It provides a consistent API for application software.
Developers can write software that works with
packagekit, and their software can then talk to the package manager of any Linux distribution. This means that they don’t have to write a version they are working with
dnf, another for
pacman, and so on.
packagekit is already installed on Ubuntu and Fedora, so just type the following two commands:
sudo pacman -Sy cockpit
sudo pacman -Sy packagekit
To use Cockpit, open your browser, type the following in the address bar and press Enter:
You should then see the Cockpit login screen. If an error message appears stating that the site cannot be reached or the connection is refused, you may need to type the following commands to enable and start the Cockpit daemon:
sudo systemctl enable cockpit
sudo systemctl start cockpit
When Cockpit is started, the login screen appears; just log in with your existing Linux credentials.
If you want to connect to other computers with the same credentials, select the check box next to “Reuse my password for remote connections.” If you use SSH keys to connect to remote computers or do not want to monitor other machines remotely at all, you can leave this box unchecked.
The Cockpit webpage is fully responsive and will resize sensibly if you resize your browser window.
The main screen contains a list of task categories in a sidebar on the left, while the rest of the window contains information related to the selected category. The default view is ‘Overview’.
Cockpit also adapts when you use it on a phone.
On our test computer, we see that an error has been flagged because a service has failed.
We click on the link “1 service failed” to go to the System Services view. The System Security Services Daemon (SSSD) has not started, so we click the “sssd” link to go to the SSSD control page.
We click on ‘Start service’.
Now that the service is up and running, we can explore more of our monitored system.
You can click on “Overview” if it is visible in the sidebar; if not, click on the system icon and then click on ‘Overview’.
CPU and memory charts
In the CPU and Memory Usage pane, click “View Graphs”.
The following graphs are displayed:
- “CPU usage”: The combined CPU usage for the total number of CPUs.
- “Memory and exchange”: The RAM and the use of swap.
- Disk I / O: Hard disk reads and writes.
- “Network traffic”: All traffic in and out of the computer.
However, clicking on the name of each chart will reveal more detailed information:
- If you click on “Disk I / O”, you will see the same information listed under “Storage” in the sidebar.
- If you click on “Network Traffic”, you will see the same information listed under “Networks” in the sidebar.
You can click “Software Updates” in the sidebar to see a list of available updates.
To install them, just click on ‘Install all updates’.
Monitor multiple computers
Before trying to check another computer, complete the following steps:
- Install Cockpit on the other computer and then log in to Cockpit to check if it works. You do not need to run the browser interface on the remote computer when monitoring it remotely. However, doing so proves that Cockpit is properly installed and fully operational.
- Use SSH to remotely connect to the other computer from the computer you are monitoring it on. Confirm that you can use SSH on the remote computer, then log in with your current ID and password or with SSH keys.
Making sure these two steps work as expected makes monitoring a remote computer a breeze. Remember, if you connect to remote hosts with the same username and password as your monitoring computer, you must select the “Reuse my password for remote connections” box.
On the monitoring computer, click the drop-down arrow next to the host.
Click on ‘Add New Host’.
Type the details of the remote computer (an IP address or host name). A color marker will appear at the top of the browser to help you identify which computer you are looking at.
Click “Add” when you are done. You should now see the remote computer in the list of available hosts; click the drop-down arrow next to it.
Click on the new remote computer to check it.
The name of the host you are monitoring is displayed. The color marker at the top of the browser window is also the one you selected when you added that host.
Many more functions
There is much more you can do with Cockpit, including the following:
- Get the general health status of a computer.
- Track performance with CPU, memory, disk and network activities.
- Change the host name.
- Connect the host to a domain.
- Open a terminal window.
- Manage software updates, user accounts, services and daemons, partition tables, network connections and bridges, and IP addresses.
- Create a RAID device.
More features are also coming. The developers have a working proof-of-concept version that displays a combined view of multiple hosts at once. Cockpit is not the most advanced management tool, but it is richly featured, easy to use, and meets most needs.