Alert when a Service stops running?

Hi everyone,

Is it possible to set up an alert (email) for when a particular services stops running?

I have alerts set up for when the MySQL or Apache goes down (set from System and Server Status), but there is a particular Service that keeps stopping every now and then and I’d like to be alerted when it does, so I can check log files at the time to see why. The service is rh-redis5-redis.service.

If anyone can advise, that would be brill!


Should be possible with Virtualmin (better to say webmin). Browse to:
Webmin -> Other -> System and Server Status.

As long as its installed and managed via Virtualmin/Webmin.
Not sure, but I think thats it.

It doesn’t appear in the list on that page.

I believe I installed this myself via SSH from softwarecollections.

I only see it really from Bootup and Shutdown

Hmm, if its not directly managed via webmin then I think you need to write a little script which checks the status every few minutes (via cron). There are quite some out there, which you can find easily with a quick google/whatever search.
Something like:
systemctl check if the wanted service gives back an “ok”. If not, automatically restart via systemctl command.
You could easily send a mail with that too.


There is a way to create a monitor for arbitrary process using Check Process from drop down in System and Server Status page:

… on that page you will be able to define a command to check on the given monitor:

1 Like

Thanks for that, would I just put ‘rh-redis5-redis.service’ in the command to check for?

Yes, correct.

Doesn’t appear to be detecting it properly.
The service is running, but its displaying down on the Check Process I have created.

THis is what I have created:

No, the systemd unit file is not a process that can be detected.

You can either use a monitor type of Bootup Action or Check Process. For Check Process, you need to give it the exact process name of the program (I don’t know what that is, but it’s definitely not the systemd unit file…that’s a configuration file that tells systemd how to start the process, it is not the process). Bootup action may be simpler, but it’s not always reliable…depends on how well the systemctl status command or service _name_ status command woks.

Bootup Action is what you want, if you want to specify the systemd unit file (because it uses systemd to check the status).

Ah, thats looking promising!

I get to select it from the list as well.

Thanks very much!

Duh, right, my bad. Sorry!

Thanks for that, would I just put ‘rh-redis5-redis.service’ in the command to check for?

I would just try redis-server, based on the start command. Considering there are no other redis services running on the server, it should be pretty precise.

Why not simply use monit ? I use it to alert me and restart anything that fails, check it out here

If you search for examples you can find con’f for lots of things.

As a last resort, there is this free monitoring service which I can offer:

I believe the agent for the service can monitor redis. Contact me privately if you wish to try it out.

Thanks for the replies everyone.

Choosing bootup action and selecting it from there has done the trick.

It went down over night and I got the alert.

Now to work out what caused it to go down. It reached its memory limit and crashed, rather than deleting keys as I thought I had configured.

I notice I can run a command when it detected the service goes down, what command is used to start redis. Is there a way I can find out? Then I could just get it to auto start.

Take a look at this monit configuration file, there is a redis entry at the bottom to alert and restart if it fails.

That monit example uses initscripts, which is no longer used on any system currently supported by Virtualmin (though it’s possible your redis configuration is using an initscript, I dunno…Webmin still has an initscript, but it’s just that we haven’t had time to update it). You’d want to use systemctl commands, most likely.

Thanks for the advice everyone.
I’ve got it alerting me when it does go down now, but the bit that isn’t working is running the command to start it.

When I manually stop, start or restart via ssh, I use these commands.

systemctl sudo start redis.service
systemctl sudo stop redis.service

In the run command if monitor goes down box, I’ve tried the start command above, with and without sudo, but it doesn’t start it.

I’ve got the run command on option set to this server, rather than remote host.

Can anyone point me in the right direction to check or any tips?

That’s not a command. You probably mean sudo systemctl start redis.service, but that isn’t necessary. It’s going to run as root, unless you tell it otherwise, so just use systemctl start redis.service

Hi Joe.

Thanks for the reply. Yes I put sudo in the wrong place on this post.

The command you have suggested I have also tried but it doesn’t start it.

systemctl start redis.service