fachinformatiker-wiki

it's easy when it's here

User Tools

Site Tools


linux:monit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux:monit [2023/03/22 23:56] – created adminlinux:monit [2024/02/17 19:03] (current) – external edit 127.0.0.1
Line 5: Line 5:
 sudo apt update sudo apt update
 sudo apt install monit sudo apt install monit
-sudo systemctl start monit 
-sudo systemctl enable monit 
-sudo systemctl status monit 
 </code> </code>
  
 +==== Monit als Dienst einrichten ====
 +
 +Unit File erstellen:
 +<code bash>
 +sudo nano /lib/systemd/system/monit.service
 +</code>
 +
 +''/lib/systemd/system/monit.service''
 +<code>
 +# This file is systemd template for monit service. To
 +# register monit with systemd, place the monit.service file
 +# to the /lib/systemd/system/ directory and then start it
 +# using systemctl (see below).
 +#
 +# 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-online.target
 +Documentation=man:monit(1) https://mmonit.com/wiki/Monit/HowTo 
 +
 +[Service]
 +Type=simple
 +KillMode=process
 +ExecStart=/bin/monit -I
 +ExecStop=/bin/monit quit
 +ExecReload=/bin/monit reload
 +Restart = on-abnormal
 +StandardOutput=null
 +
 +[Install]
 +WantedBy=multi-user.target
 +</code>
 +
 +Monit aktivieren und starten:
 +<code>
 +sudo systemctl enable monit.service
 +sudo systemctl start monit.service
 +sudo systemctl status monit.service
 +</code>
 ===== Konfiguration ===== ===== Konfiguration =====
 +
 +Monit Config File bearbeiten:
 +<code bash>
 +sudo nano /etc/monit/monitrc
 +</code>
 +
 ''/etc/monit/monitrc'' ''/etc/monit/monitrc''
 +<code>
 +# reporting to mmonit
 +set mmonit http://agent:monit@localhost:8080/collector
 +
 +# webservice
 +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'
 +</code>
 +
 +give the appropriate permissions
 +<code>
 +sudo chmod 600 /etc/monit/monitrc
 +</code>
 +
 +===== Befehle =====
 +
 +<code>
 +sudo monit reload
 +sudo monit status
 +</code>
 +
 +''monit''
 <code bash> <code bash>
-sudo cp /etc/monit/monitrc /etc/monit/conf-enabled/monit.conf+Usage: monit [options]+ [command] 
 +Options are as follows: 
 + -c file       Use this control file 
 + -d n          Run as a daemon once per n seconds 
 + -g name       Set group name for monit commands 
 + -l logfile    Print log information to this file 
 + -p pidfile    Use this lock file in daemon mode 
 + -s statefile  Set the file monit should write state information to 
 + -I            Do not run in background (needed when run from init) 
 + --id          Print Monit's unique ID 
 + --resetid     Reset Monit's unique IDUse with caution 
 + -B            Batch command line mode (do not output tables or colors) 
 + -t            Run syntax check for the control file 
 + -v            Verbose mode, work noisy (diagnostic output) 
 + -vv           Very verbose mode, same as -v plus log stacktrace on error 
 + -H [filename] Print SHA1 and MD5 hashes of the file or of stdin if the 
 +               filename is omitted; monit will exit afterwards 
 + -V            Print version number and patchlevel 
 + -h            Print this text 
 +Optional commands are as follows: 
 + start all             - Start all services 
 + start <name>          - Only start the named service 
 + stop all              - Stop all services 
 + stop <name>           - Stop the named service 
 + restart all           - Stop and start all services 
 + restart <name>        - Only restart the named service 
 + monitor all           - Enable monitoring of all services 
 + monitor <name>        - Only enable monitoring of the named service 
 + unmonitor all         - Disable monitoring of all services 
 + unmonitor <name>      - Only disable monitoring of the named service 
 + reload                - Reinitialize monit 
 + status [name]         - Print full status information for service(s) 
 + summary [name]        - Print short status information for service(s) 
 + report [up|down|..]   - Report state of services. See manual for options 
 + quit                  - Kill the monit daemon process 
 + validate              - Check all services and start if not running 
 + procmatch <pattern>   - Test process matching pattern
 </code> </code>
linux/monit.1679525778.txt.gz · Last modified: 2024/02/17 19:03 (external edit)