Skip to content

Commit a3a7080

Browse files
committed
fix #78
1 parent dc575d2 commit a3a7080

File tree

1 file changed

+95
-0
lines changed
  • content/3.misc/1.tools-and-utilities/4.utilities

1 file changed

+95
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: "Monit"
3+
date: 2023-02-23
4+
---
5+
6+
Monit is free and open source software that helps you keep track of processes. It can restart services that are not responding or that have crashed. You can use Systemd or daemontools for the same purpose. In this article, we'll show you how to install and configure monit to control processes on Debian or Ubuntu Linux.
7+
8+
## Install
9+
10+
<details><summary>for Centos 7-8</summary>
11+
12+
To install, run the command on the server:
13+
14+
```sh
15+
yum install epel-release
16+
yum update
17+
yum install monit
18+
systemctl enable monit
19+
systemctl start monit
20+
```
21+
22+
</details>
23+
24+
<details><summary>for Debian-like system:</summary>
25+
26+
To install, run the command on the server:
27+
28+
```sh
29+
sudo apt install monit
30+
```
31+
32+
</details>
33+
34+
Recommended configuration file `/etc/monit/monitrc`:
35+
36+
```
37+
set daemon 1
38+
with start delay 1
39+
40+
set logfile /var/log/monit.log
41+
set idfile /var/lib/monit/id
42+
set statefile /var/lib/monit/state
43+
44+
set httpd port 2812 and
45+
use address localhost
46+
allow localhost
47+
48+
include /etc/monit/conf.d/*
49+
```
50+
51+
<details><summary>Configuration file for Astra service</summary>
52+
53+
`/etc/monit/conf.d/astra.conf`
54+
55+
```
56+
check process astra with pidfile /var/run/astra.pid
57+
start program = "/etc/init.d/astra start"
58+
stop program = "/etc/init.d/astra stop"
59+
```
60+
61+
</details>
62+
63+
OR
64+
65+
<details><summary>Configuration file for simple Astra process</summary>
66+
67+
`/etc/monit/conf.d/astra.conf`
68+
69+
```
70+
check process astra.pid with pidfile /var/run/astra.pid
71+
start program = "/bin/sh -c 'ulimit -n 65536; /usr/bin/astra -c /etc/astra/astra.conf -p 8000 --pid /var/run/astra.pid --log /var/log/astra.log --daemon'"
72+
stop program = "/bin/sh -c 'kill `cat /var/run/astra.pid`'"
73+
```
74+
75+
</details>
76+
77+
Restart monit to apply changes:
78+
79+
```sh
80+
systemctl restart monit
81+
```
82+
83+
or
84+
85+
```sh
86+
sudo /etc/init.d/monit restart
87+
```
88+
89+
## Commands:
90+
91+
- `monit reload` — reload configuration files
92+
- `monit summary` — short information
93+
- `monit start astra` — start Astra
94+
- `monit stop astra` — stop Astra
95+
- `monit restart astra` — restart Astra

0 commit comments

Comments
 (0)