Monit can monitor ShellInABox and notify you if it stops running for some reason. Setting up a remotely accessible shell with ShellInABox is awesome. But what if ShellInABox process closes and you did not even know? You may not be able to gain shell access on your server through the web browser because the app has stopped functioning. Monit is an automatic monitoring, maintenance, and repair utility for Unix systems. If your ShellInABox WebUI fails, Monit can send you an email alert. It can even try to restart ShellInABox daemon. In this Monit tutorial, I will describe how to monitor ShellInABox with Monit system monitoring app. I am assuming that you have already installed and configured Monit following my previous guide.
Table of Contents
On my recently built energy-efficient home server, I test and run several apps including ShellInABox. I use Monit to monitor several services listed below:
Monitor your home server with Monit:
- Home server system load monitoring (CPU, RAM, Swap)
- Server hard drive storage monitoring (HDD space)
- Motherboard temperature monitoring
- Processor or CPU temperature monitoring
- Monitor Hard drive SMART health and temperature
- Monitor file server status (Samba and NFS)
- Monitor web server status (Apache, NGINX, and MySQL)
- Monitor CouchPotato process status
- Monitor SickBeard process status
- Monitor SickRage process status
- Monitor SABnzbd process status
- Monitor Webmin process status
- Monitor qBittorrent process status
- Monitor Transmission process status
- Monitor ShellInABox process status
In this guide, I will show you how to monitor ShellInABox process status so that the automatic download system you setup keeps running as it should. Just another layer of automation for your home server.
Before enabling ShellInABox monitoring, it is required that you have a working Monit instance with a proper
/etc/monit/monitrc file. Monit configurations for various services are loaded from
1. Find ShellInABox Port
First, you will need to find what port your ShellInABox daemon setup is listening on. Open ShellInABox default settings file and look for the port. If you followed our Ubuntu ShellInABox installation guide, then you can open settings file using the following command:
Then, look for the port number. Find the line similar to
SHELLINABOX_PORT=4200, as shown in the picture below:
In this guide, we are going to assume you are using port 4200, which is the ShellInABox daemon default port.
Setup Monit ShellInABox Monitoring Script
To monitor ShellInABox with Monit, create a Monit configuration file using the following command:
Copy the following contents to it, save, and exit (press Ctrl X, press Y, and press ENTER).
check process ShellInABox matching "shellinaboxd" start program = "/etc/init.d/shellinabox start" stop program = "/etc/init.d/shellinabox stop" if failed host 127.0.0.1 port 4200 type TCP for 2 cycles then restart if 2 restarts within 3 cycles then unmonitor
If you are using ShellInABox behind SSL (HTTPS access) then use
TCPSSL instead of
TCP in the above code block. This code will make Monit send you an email alert when ShellInABox is not running. As example, the picture below shows 2 emails from monit: one when CouchPotato process was found to be not running and another after Monit successfully restarted CouchPotato.
A cycle is 1 monitoring period as set in
/etc/monit/monitrc. If 2 restarts occur within 3 monitoring cycles, Monit will stop monitoring ShellInABox process status instead of bombarding you with email alerts. You can customize the above rules as you please. [Read: 5 Easy steps to Increase Shellinabox Security]
Test and Reload Monit
Once you make any changes you have to test Monit configuration:
sudo monit -t
You should see the following message: Control File Syntax OK. Then, check to see if Monit is already running using the following command:
sudo /etc/init.d/monit status
If Monit is running, reload Monit configurations using the following command:
sudo /etc/init.d/monit reload
If Monit is not running, then start it using
sudo monit command instead. The whole sequence of commands for testing and reloading Monit is shown in the picture below.
Now, fire up your web browser and visit one of the following URLs depending on how your Monit is configured (be sure to use the correct port number):
- http://IPADDRESS:2812 (local network IP)
- http://domain.com:2812 (if you have domain name pointing to your server)
You should see ShellInABox process status in the Monit status page shown in the picture below.
That is it for ShellInABox monitoring with Monit. As you can see Monit allows for automatic server monitoring, which can be a big help for system administrators. Monit Wiki page has several examples. More home server specific Monit examples to follow, so keep checking back.
IPVanish VPN Exclusive Offer - only $3.25/month:
Windows, Android, Ubuntu
OSMC on RPi
♦ Hide your browsing (no logs), Anonymize Streaming and Downloads
♦ Circumvent Geo/Country Restrictions and access worldwide content
♦ Works on Windows, Mac, Linux, Android, iOS, Router, and more
♦ Money back guarantee - Sign Up Now