Home » Home Server » Monit: Monitor qBittorrent process status

Monit: Monitor qBittorrent process status

Monit can monitor qBittorrent and notify you if it stops running for some reason. Setting up a completely automated home server is awesome. But what if one of your apps fails and you did not even know? You may be waiting for your movie or episode to be downloaded but it never happens because the app has stopped functioning. Monit is an automatic monitoring, maintenance, and repair utility for Unix systems. If your qBittorrent WebUI fails, Monit can send you an email alert. It can even try to restart qBittorrent-nox (daemon). In this Monit tutorial, I will describe how to monitor qBittorrent with Monit system monitoring app. I am assuming that you have already installed and configured Monit following my previous guide.

Monitor qBittorrent

On my recently built energy-efficient home server, I test and run several apps including qBittorrent. I use Monit to monitor several services listed below:

Monitor your home server with Monit:

In this guide, I will show you how to monitor qBittorrent 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 qBittorrent 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 /etc/monit/conf.d folder.

1. Find qBittorrent Port

First, you will need to find what port your qBittorrent daemon setup is listening on. If you find this guide interesting, you probably already know your port. In case, you do not know your port number there are couple of ways to find it. If you installed qBittorrent using AtoMiC ToolKit then you can use the “Access Details” feature from within AtoMiC ToolKit qBittorrent submenu.

qBittorrent Access Details on AtoMiC ToolKit
qBittorrent Access Details on AtoMiC ToolKit

Alternatively, you can open qBittorrent settings file and look for the port. If you followed our qBittorrent WebUI installation guide then you can open settings file using the following command:

nano ~/.config/qBittorrent/qBittorrent.conf

Then, look for the port number. Find the line similar to:

WebUI\Port=8086

In this guide, we are going to assume you are using port 8086, which is the qBittorrent daemon default port.

Setup Monit qBittorrent Monitoring Script

To monitor qBittorrent with Monit, create a Monit configuration file using the following command:

sudo /etc/monit/conf.d/qbittorrent

Copy the following contents to it, save, and exit (press Ctrl X, press Y, and press ENTER).

check process qBittorrent matching "qbittorrent-nox"
    start program = "/etc/init.d/qbittorrent-nox-daemon start"
    stop program = "/etc/init.d/qbittorrent-nox-daemon stop"
    if failed host 127.0.0.1 port 8086 type TCP for 2 cycles then restart
    if 2 restarts within 3 cycles then unmonitor

If you are using qBittorrent 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 qBittorrent 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.

Monit Alerts - Process Not Found and Auto Restart
Monit Alerts – Process Not Found and Auto Restart

A cycle is 1 monitoring period as set in /etc/monit/monitrc. If 2 restarts occur within 3 monitoring cycles, Monit will stop monitoring qBittorrent process status instead of bombarding you with email alerts. You can customize the above rules as you please. [Read: What is Usenet and why is it better than Torrents?]

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.

Monit Test and Reload
Monit Test and Reload

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://localhost:2812
  • http://IPADDRESS:2812 (local network IP)
  • http://domain.com:2812 (if you have domain name pointing to your server)

Right now, I do not have qBittorrent running. If it was running, you should see qBittorrent process status in the Monit status shown in the picture below.

Monitor qBittorrent Process Status with Monit
Monitor qBittorrent Process Status with Monit

That is it for qBittorrent 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.

We Are Hiring: Familiar with Media Streaming, HTPC, Home Server, Smart Home, and Home Automation topics? Write about it and earn money. No writing experience needed. APPLY HERE.

Get 20% OFF with IPVanish VPN:

♦   Hide your browsing and streaming activity: No logs and no tracking
♦   Access geo-restricted content from anywhere
♦   Encrypt and anonymize: Kodi, Plex, Downloads, Personal Info
♦   Windows, Mac, Linux, Android, iOS, Router, and more.
♦   Money back guarantee - Sign Up Now

About the author

Anand

Anand is a self-learned computer enthusiast, a part-time blogger, and a Food Scientist by career. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs on htpcbeginner.com and smarthomebeginner.com.

Archives

Join the other 110,000 followers

Don’t Miss Out!