monit gives error when starting

I’ve installed monit and monit-docusing zypper on the most recent (fully zypper dup up to date).

When trying to start, it gives this error:

**revue:~ #** rcmonit startredirecting to systemctl start monit.service
Failed to start monit.service: Unit monit.service failed to load: No such file or directory.
**revue:~ #** systemctl start monit.service
Failed to start monit.service: Unit monit.service failed to load: No such file or directory.**revue:~ #** monit statusStatus not available -- the monit daemon is not running
**revue:~ #** rcmonit status
Checking for service monit                                                                                                                           **unused**
● monit.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

I tried getting around this by editing /etc/monitrc as described by http://www.itzgeek.com/how-tos/linux/opensuse/install-monit-on-opensuse-13-2.html:

edit /etc/monitrc and un comment the following pid entry.

set pidfile /var/run/monit.pid

It doesn’t help: still the same error.

What am I missing here?

–jeroen

Monit does not have a .service file, where did you install it from?

Post the output of; rpm -qi monit

What is a .service file?

Output:

 
revue:~ # rpm -qi monit
Name        : monit
Version     : 5.10
Release     : 1.2
Architecture: x86_64
Install Date: Wed Jun  3 07:03:11 2015
Group       : System/Monitoring
Size        : 633819
License     : AGPL-3.0
Signature   : RSA/SHA256, Sat Jan 31 00:54:14 2015, Key ID b88b2fd43dbdc284
Source RPM  : monit-5.10-1.2.src.rpm
Build Date  : Sat Jan 31 00:53:51 2015
Build Host  : build21
Relocations : (not relocatable)
Packager    : http://bugs.opensuse.org
Vendor      : openSUSE
URL         : http://mmonit.com/monit/download/
Summary     : Service Manager and Monitor System
Description :
Monit is a utility for managing and monitoring processes, files,
directories, and devices on a Unix system.  Monit conducts automatic
maintenance and repair and can execute meaningful causal actions in
error situations.  For example, monit can start a process if it does
not run, restart a process if it does not respond, and stop a process
if it uses too many resources.  You can use monit to monitor files,
directories, and devices for changes, such as time stamp changes,
checksum changes, or size changes. You can even use monit to monitor
remote hosts: monit can ping a remote host and check port connections.
Distribution: openSUSE Factory
revue:~ #

Hi
For use with systemd, they have a template it’s just not packaged (plus it needs tweaking).

Create a file called monit.service and put in /etc/systemd/system/;


# This file is a systemd template for the monit service. To
# register monit with systemd, place this file in
# /etc/systemd/system/ and start monit using systemctl:
#
# Enable monit to start on boot:
#         systemctl enable monit.service
#
# Start monit immediately:
#         systemctl start monit.service
#
# Stop monit:
#         systemctl stop monit.service
#
# Status:
#         systemctl status monit.service

[Unit]
Description=Pro-active monitoring utility for unix systems
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/monit -I -c /etc/monitrc
ExecStop=/usr/bin/monit -c /etc/monitrc quit
ExecReload=/usr/bin/monit -c /etc/monitrc reload

[Install]
WantedBy=multi-user.target

Thanks. Will try when home. Where did you get it from?

Any good docs that teach me more about .service files?

–jeroen

On Thu 04 Jun 2015 05:16:01 PM CDT, jpluimers wrote:

Thanks. Will try when home. Where did you get it from?

Any good docs that teach me more about .service files?

–jeroen

Hi
The 5.10 source tarball… :wink:

All part of systemd, this is probably a good starting point…
http://www.freedesktop.org/software/systemd/man/systemd.service.html


Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
SUSE Linux Enterprise Desktop 12 GNOME 3.10.1 Kernel 3.12.39-47-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

(****; the forum logged me out and deleted what I had typed, very brief recap)

Thanks.
Found the script (bitbucket isn’t indexed by Google, github is, so with some twidding, found it).

Created a fix script:


#! /bin/sh
#
# Fixes this error:
#    revue:~ # rcmonit restart
#    redirecting to systemctl restart monit.service
#    Failed to restart monit.service: Unit monit.service failed to load: No such file or directory.
SERVICE_TARGET=monit.service
pushd /etc/systemd/system/
# http://stackoverflow.com/questions/13735051/curl-and-capturing-output-to-a-file
curl https://bitbucket.org/tildeslash/monit/raw/master/system/startup/monit.service.in -o $SERVICE_TARGET
# escape slashes in arguments: http://www.grymoire.com/Unix/Sed.html#uh-62
## might need to get rid of the backtick and replace \\ by \, see:
# http://unix.stackexchange.com/questions/5778/whats-the-difference-between-stuff-and-stuff/5782#5782
LOG_TARGET_EXPANDED=`echo "$(which monit)" | sed 's:]\\^\$\.\*\/]:\\\\&:g'`
#echo "/^LOGDIR=\"\$HOME\/logs\"$/ s/\"\$HOME\/logs\"$/\"${LOG_TARGET}\"/"
#echo "/^LOGDIR=\"\$HOME\/logs\"$/ s/\"\$HOME\/logs\"$/\"${LOG_TARGET_EXPANDED}\"/"
#sed -e "/^LOGDIR=\"\$HOME\/logs\"$/ s/\"\$HOME\/logs\"$/\"${LOG_TARGET_EXPANDED}\"/" $SERVICE_TARGET > $SERVICE_TARGET.tmp && mv $SERVICE_TARGET.tmp $SERVICE_TARGET
echo SERVICE_TARGET=$SERVICE_TARGET
echo LOG_TARGET_EXPANDED=$LOG_TARGET_EXPANDED


echo old:
sed -n "/@prefix@\/bin\/monit/ p" $SERVICE_TARGET
# replace @prefix@ with the directory where monit resides
# replace @sysconfigdir@ with etc
sed -e "/@prefix@\/bin\/monit/ s/@prefix@\/bin\/monit/${LOG_TARGET_EXPANDED}/" $SERVICE_TARGET > $SERVICE_TARGET.tmp && mv $SERVICE_TARGET.tmp $SERVICE_TARGET
sed -e "/@sysconfdir@/ s/@sysconfdir@/etc/" $SERVICE_TARGET > $SERVICE_TARGET.tmp && mv $SERVICE_TARGET.tmp $SERVICE_TARGET
echo new:
sed -n "/monitrc/ p" $SERVICE_TARGET


chmod 755 $SERVICE_TARGET
popd
systemctl enable monit.service
systemctl status monit.service
systemctl start monit.service