Monitor your web-based servers with Linux Dash and Cockpit

Home Monitor

Article from Issue 177/2015
Author(s):

Linux Dash and Cockpit are small-scale solutions for monitoring a cloud-hosted virtual server from home.

More and more computer users are operating a cloud-based server, which they manage from a home or local network. A well-configured cloud-hosted server that is equipped with the right Linux distribution hardly requires any work; however, an occasional glance at the system's status is compulsory.

The big players in the monitoring industry, such as Nagios, Icinga, or Munin, support monitoring for complex IT infrastructures – and are correspondingly complex to set up. But a heavy-hitting monitoring solution is overkill for a small home server – or for the many Raspberry Pi servers that now populate many home networks. If you are looking for monitoring on a small and intimate scale, the PHP-based tool known as Linux Dash [1] might be a better choice.

Linux Dash

Linux Dash uses PHP and only needs a single web server – Apache in the simplest case, although Nginx [2] also works. You will also need Node.js [3] – a web application platform built on Chrome's JavaScript runtime.

This article describes how to set up Linux Dash on an Ubuntu server with Apache 2.4. The procedures for other systems are similar.

First, make sure the required components are running on the server. You can update the package source using the first command from Listing 1 and then install Apache with PHP5 and Git (line 2). Unlike what various manuals on the network would have you believe, Linux Dash does not require a MySQL database. Load the source code into the web server document root (/var/www/html, or for Apache 2.2, /var/www) as shown in line 4.

Listing 1

Installing Linux Dash

$ sudo apt-get update
$ sudo apt-get install apache2 php5 php5-json git
$ cd /var/www/html
$ sudo git clone https://github.com/afaqurk/linux-dash.git

If the browser and the web server are running on the same machine, you can access Linux Dash after installing the web script via the URL http://localhost/linux-dash. If the server is on your home network or on the Internet, replace the localhost with the IP address or the host name of the computer. If the page still does not load, even when the correct address is specified, it could be that PHP is still missing the correct settings (see the box titled "Shell Exec").

Shell Exec

If Apache only acknowledges the call from Linux Dash with an error message, check the PHP settings in the /etc/php5/apache2/php.ini file. Open the file with root privileges in any editor and make sure the disable_functions line does not run the exec and shell_exec functions. The page should work after restarting the web server using sudo service apache2 restart.

Securing Linux Dash

A first glance usually suffices for a functional test. If you can reach the server from the Internet, you should promptly limit access to Linux Dash for security reasons (see the "Security" box): You need to maintain the web server with this function because the application itself does not offer user management.

Security

Some versions of the PHP function shell_exec(), which executes a command in the shell and returns the output as a string, pose security issues for Linux Dash. If an intruder manages to access the server, s/he will be able to use the shell_exec() function for more hacks because the function will give execute rights for any code that is smuggled in. To avoid this problem, always use the latest version of PHP.

Edit default.conf or 000-default.conf in /etc/apache2/sites-available/ with root privileges, depending on the distribution and the Apache version, and use an editor to add the content from Listing 2 in front of the final </VirtualHost> at the end of the file. Adapt the path to your Linux Dash installation in the directory line.

Listing 2

Tweaking the Config File

<Directory /var/www/html/linux-dash>
  Options FollowSymLinks
  AllowOverride All
  Order allow,deny
  allow from all
</Directory>

Then, drop the .htaccess file with the contents of Listing 3 into the Linux Dash directory on the web server (/var/www/html/linux-dash). Last of all, create the password file .htpasswd (Listing 4, line 1) in the same directory and restart Apache (line 2). The application should then query the login data the next time you call up Linux Dash in the browser.

Listing 3

.htaccess

AuthType Basic
AuthName "Linux Dash"
AuthUserFile .htpasswd
Require valid-user

Listing 4

.htpasswd

$ sudo htpasswd -c .htpasswd <I>User<I>
$ sudo service apache2 restart

Linux Dash monitors your server's vital signs. The menu at the top of the page divides the output into categories System Status, Basic Info, Network, Accounts, and Apps. You will see the CPU and RAM capacity (Figure 1) and the hard disk partitioning at a glance under System Status. Basic Info shows information about the operating system, technical data for the CPU, the memory usage, and planned Cron jobs (Figure 2).

Figure 1: The Linux Dash System Status view offers an overview of RAM and CPU usage.
Figure 2: Basic Info view adds more system details.

The Network link provides information about network devices, existing connections, ping times, bandwidth, and Internet speed. Linux Dash lists the user registered on the system with their last logon time and the system accounts under Accounts. Finally, Apps shows some common applications, their installation status, and the location of the matching binary in the directory tree.

Other tabs only display contents after additional programs or services have been installed. You will also find links for the NoSQL database Redis or the Memcache daemon. You can individually update the way individual tabs are displayed. You will find a search box for filtering the displayed information at the top of some tabs.

Linux Dash is officially tested and supported for Arch, Debian (from version 6), Ubuntu (from 11.04), Linux Mint (from version 16), and CentOS (from version 5). You can, however, also use Dash with other Linux distributions.

Cockpit

The Red-Hat-sponsored Cockpit Management Console [4] allows more than just pure monitoring and is similar in scope to the popular Webmin [5]. Red Hat officially introduced the Cockpit web front end with the Fedora 21 Server edition.

Cockpit is included by default with Fedora Server; you will need to install it manually for Fedora Workstation; a simple sudo yum install cockpit or sudo dnf install cockpit from Fedora 22 onwards will install Cockpit. The package manager also installs the Docker container manager at the same time. After the installation, you need to introduce Cockpit to Systemd using the commands in Listing 5.

Listing 5

Enabling Cockpit

$ sudo systemctl enable cockpit.socket
$ sudo systemctl start cockpit

In Fedora 21 Workstation, it was still necessary to open the firewall for Cockpit and disable the SELinux security extension.

Access the main view of Cockpit (Figure 3) locally using the URL http://localhost:9090 or on a remote computer via http://IP:9090. Enter root for the user; the password is the previously specified root password.

Figure 3: Cockpit, like Linux Dash, presents the history of important system information as a graph.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News