'Running 'monit restart all' gives invalid action

error: invalid action action= restart monit


Server Info

Ubuntu 16.04.4 LTS monit: Installed: 1:5.16-2ubuntu0.1



Solution 1:[1]

This issue is for these monit commands

$ monit restart tomcat
$ monit stop tomcat
$ monit start tomcat
$ monit monitor tomcat
$ monit unmonitor tomcat

Reason:

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in monit (Ubuntu): status: New ? Confirmed

for the time being, you need to revert the monit package to 1:5.16-2, try manually in a server with

sudo apt-get install monit=1:5.16-2

If your servers are automatically provisioned with some third party tool (chef, puppet, bash scripts, etc) then you would need to update them accordingly.

Source: https://bugs.launchpad.net/ubuntu/+source/monit/+bug/1786910

NOTE

In case you're facing this issue again even after downgrading Monit version, please blacklist it from unattended-upgrades service. It runs daily to fetch latest security updates for relative packages.

To blacklist monit, open "/etc/apt/apt.conf.d/50unattended-upgrades" and under "Unattended-Upgrade::Package-Blacklist" block, add "monit".

@TomDavies suggested a better solution than blacklisting, see the comments.

Do remember it to remove from blacklist once the issue is solved. You would need to run the above command again to revert back to older patch.

Solution 2:[2]

This is an extension to answer given by Ninad.

If you are using Chef to automatically configure your servers, then the following code change will help you install the previous version of monit in all your servers running Ubuntu 16.04

if 'ubuntu' == node['platform'] && '16.04' == node['platform_version']
  Chef::Log.info "******** Installing monit version '1:5.16-2' ********"
  execute 'apt-get -y install monit=1:5.16-2 --allow-downgrades'
else
  Chef::Log.info "******** Installing latest monit ********"
  package 'monit'
end

Make sure to revert this once the bug is fixed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Shriram Balakrishnan