systemctl not enable monit

Issue #776 closed
Former user created an issue

problem systemctl not enable monit, What would be the problem?

Comments (10)

  1. Henning Bopp

    Could you describe your problem a little bit more?

    Is it not enabled by default (you can do it with sudo systemctl enable monit.service) or is it not willing to start on system boot even it was enabled? systemctl status monit.service should give a hint why it was not able to startup. If that even will not give a hint, try sudo journalctl -b -r -u "monit.service" to get any info monit wrote to the journal (-u "monit.service") since last boot (-b), starting with the newest entry (-r).

  2. juanpvh

    I configured the systemd using this tutorial https://mmonit.com/wiki/Monit/Systemd, and following its instructions I get the following message, as below.

    root@localhost:~# sudo systemctl enable monit.service
    Synchronizing state of monit.service with SysV init with /lib/systemd/systemd-sysv-install...
    Executing /lib/systemd/systemd-sysv-install enable monit
    Failed to execute operation: Too many levels of symbolic links
    
    
    root@localhost:~# sudo journalctl -b -r -u "monit.service"
    -- Logs begin at Fri 2018-09-28 23:30:32 UTC, end at Sat 2018-09-29 10:37:Sep 29 02:49:41 localhost monit[29152]: Denied connection from non-authoriSep 29 02:49:37 localhost monit[29152]: Awakened by User defined signal 1
    Sep 29 02:42:20 localhost monit[29152]: Denied connection from non-authoriSep 29 02:42:11 localhost monit[29152]: 'localhost' Monit 5.25.2 started
    Sep 29 02:42:11 localhost monit[29152]: Starting Monit 5.25.2 daemon withSep 29 02:42:11 localhost systemd[1]: Started Pro-active monitoring utilitSep 29 02:40:17 localhost monit[29099]: Monit daemon with PID 28921 awakenSep 29 02:40:17 localhost systemd[1]: Started Pro-active monitoring utilitSep 29 01:35:48 localhost systemd[1]: monit.service: Failed with result 'eSep 29 01:35:48 localhost systemd[1]: monit.service: Unit entered failed sSep 29 01:35:48 localhost systemd[1]: monit.service: Control process exiteSep 29 01:35:48 localhost systemd[1]: monit.service: Main process exited,Sep 29 01:35:48 localhost systemd[1]: Started Pro-active monitoring utilitSep 29 01:33:38 localhost systemd[1]: monit.service: Failed with result 'eSep 29 01:33:38 localhost systemd[1]: monit.service: Unit entered failed sSep 29 01:33:38 localhost systemd[1]: monit.service: Control process exiteSep 29 01:33:38 localhost systemd[1]: monit.service: Main process exited,Sep 29 01:33:38 localhost systemd[1]: Started Pro-active monitoring utilitlines 1-19/19 (END)
    
    root@localhost:~# systemctl status monit.service
    ● monit.service - Pro-active monitoring utility for unix systems
       Loaded: loaded (/lib/systemd/system/monit.service; enabled; vendor pres   Active: active (running) since Sat 2018-09-29 02:42:11 UTC; 8h ago
         Docs: man:monit(1)
               https://mmonit.com/wiki/Monit/HowTo
     Main PID: 29152 (monit)
       CGroup: /system.slice/monit.service
               └─29152 /usr/local/bin/monit -I
    
    Sep 29 02:42:11 localhost systemd[1]: Started Pro-active monitoring utilitSep 29 02:42:11 localhost monit[29152]: Starting Monit 5.25.2 daemon withSep 29 02:42:11 localhost monit[29152]: 'localhost' Monit 5.25.2 started
    Sep 29 02:42:20 localhost monit[29152]: Denied connection from non-authoriSep 29 02:49:37 localhost monit[29152]: Awakened by User defined signal 1
    Sep 29 02:49:41 localhost monit[29152]: Denied connection from non-authorilines 1-15/15 (END)
    
  3. Henning Bopp

    That's weird... On my Debian (default repo, not self compiled!) it states:

    # systemctl enable monit.service 
    monit.service is not a native service, redirecting to systemd-sysv-install.
    Executing: /lib/systemd/systemd-sysv-install enable monit
    

    Still hasn't got a .service at all. Even after creating such a file it still states that it is using the sysv script.

    This leads me to the question: Is it possible that you have installed monit from your OS' repo AND from source and it now tries some weird mixing?

    Because on my Arch Desktop - where I compiled it myself - I do not get any messages regarding sysv...


    Beside that your monit seems to run! It says "Loaded: loaded" and should show a gray Bullet before "monit.service" that means the service is running, but currently sleeping. That's in fact what it should do. It loops through sleeping, waking up, checking your system, sleeping again. If configured with http, you should be able to see http://127.0.0.1:2812 with information regarding your system. The Denied connection from non-authori might tell that you tried to access the web frontend.

    PS: If you are running monit on your localhost (not virtual or remote) you might use journalctl -b -r -u "monit.service" | xclip -selection clipboard in order to copy the output to your clipboard to avoid truncation. You might also use journalctl -b -r -u "monit.service" --no-pager to avoid truncation... Since you are already logged in as root you do not need to sudo anything here...

  4. juanpvh

    I made the installation via source code manually, it shows that the monit is working, but I can not access the web (internal error - server connection terminated) it displays the error and also "monit status" displays the following error: Error receiving data - Conecction reset by peer.

    Henning Bopp do you have a how to for source code monit? I see that I'm doing something wrong at some stage of the installation.

    Thank you for your great help so far. thank you so much

  5. Henning Bopp

    It should be as simple as outlined in the Systemd-Wiki entry you mentioned.

    I just installed a fresh Debian to a Virtual machine. What I did to make it work was as described by @tildeslash in #763:

    wget https://bitbucket.org/tildeslash/monit/get/master.tar.gz
    tar -xzf master.tar.gz
    cd tildeslash*
    ./bootstrap
    ./configure
    make
    
    # Plus additional step:
    make install
    

    I created a /etc/monitrc File with

    set daemon 60
    set log /var/log/monit.log
    set pidfile /tmp/monit.pid
    set statefile /tmp/monit.state
    
    set httpd port 2812 and
          use address localhost  # only accept connection from localhost (drop if you use M/Monit)
          allow localhost        # allow localhost to connect to the server and
          allow admin:monit      # require user 'admin' with password 'monit'
    
    check host pingpong with address boppy.eu
        if failed ping4 then alert
    

    And for sure the systemd file as mentioned in the wiki entry.

    root@debian-motest:/home/boppy# systemctl enable monit
    Created symlink /etc/systemd/system/multi-user.target.wants/monit.service → /lib/systemd/system/monit.service.
    

    That's it. Works like it should.

    What OS do you use?

  6. juanpvh

    I'm using linode.com servers, ubuntu 16.04 lts. I am doing what you have described and still have some tuning because some libs are missing on the linode server so I run this line (apt-get install -y git build-essential libtool automake byacc flex zlib1g-dev libssl-dev autoconf bison libpam0g-dev) before to start the installation so everything is correct.

  7. Henning Bopp

    Sorry, but it there has to be something messed up on that machine. Just got myself a 16.04 LTS VM.

    My (kind of) full ~/.bash_history is:

    root@ubu-motest:~# cat .bash_history 
    
    # install deps (skip pam/ssl support for testing)
    apt install build-essential libtool m4 autotools-dev automake bison flex zlib1g-dev
    
    # Get the files, configure, and compile
    wget https://bitbucket.org/tildeslash/monit/get/master.tar.gz
    tar xf master.tar.gz 
    cd tildes*
    ./bootstrap
    ./configure --without-pam --without-ssl
    make
    make install
    
    # Create config
    nano /etc/monitrc
    chmod 0600 /etc/monitrc 
    
    # Create Systemd Service:
    nano /lib/systemd/system/monit.service
    
    # Enable and run:
    systemctl enable monit
    
    ### OUTPUT:
    ### Created symlink from /etc/systemd/system/multi-user.target.wants/monit.service to /lib/systemd/system/monit.service.
    
    systemctl start monit
    systemctl status monit.service 
    

    I think there have to be some dead monit bodies in your basement... ;-) So, let's grab a broom. First of all lets watch out what monit-files your system knows:

    find / -name monit* ! \( -path '*/cgroup/*' -o -path '/home/*' \)
    

    Mine shows (if you didn't do the compiling inside /home/ you get a bunch more files...):

    # Created by me. Configuration
    /etc/monitrc
    
    # Created by systemd on "enable"
    /etc/systemd/system/multi-user.target.wants/monit.service
    
    # Created by Monit on runtime
    /tmp/monit.state
    /tmp/monit.pid
    
    # Not monit related...
    # /usr/src/linux-headers-4.4.0-131-generic/include/config/net/drop/monitor.h
    # /usr/src/linux-headers-4.4.0-131-generic/include/config/proc/page/monitor.h
    # /usr/src/linux-headers-4.4.0-131-generic/include/config/ipw2200/monitor.h
    # /usr/src/linux-headers-4.4.0-131-generic/include/config/ipw2100/monitor.h
    # /usr/share/sosreport/sos/plugins/monit.py
    # /usr/share/sosreport/sos/plugins/__pycache__/monit.cpython-35.pyc
    
    # Created by make install
    /usr/local/share/man/man1/monit.1
    /usr/local/bin/monit
    
    # Not monit related
    # /run/mdadm/monitor.pid
    
    # Created by monit on runtime
    /var/log/monit.log
    
    # Created by me. Systemd Service config
    /lib/systemd/system/monit.service
    

    I think there might be some more on your machine, right?

    EDIT: Since I think this will be some back and forth, you can also drop me a message at https://t.me/boppy_de - It should be easier to get that done side-by-side...

  8. Henning Bopp

    Okay, we got that one fixed. The problem was, that there had been an installation from the Ubuntu Repo that had some init.d files with it.

    So to fix this, it was not enough to remove the package (apt remove monit), but one has to clean up after apt because the init files have been left on device. I did with (I'm not good at deleting... ;)):

    root@localhost:~# mkdir oldMonitFiles.bak
    root@localhost:~# mv /etc/init/monit.conf oldMonitFiles.bak/etc_init_monit.conf
    root@localhost:~# mv /etc/init.d/monit.dpkg-dist oldMonitFiles.bak/etc_init.d_monit.dpkg-dist
    root@localhost:~# mv /etc/init.d/monit oldMonitFiles.bak/etc_init.d_monit
    

    After a reboot everything works. Even the previously created systemd service started up on first try.

  9. Log in to comment