Skip to content

fix #78 astra-linuxmonit #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions content/3.misc/1.tools-and-utilities/4.utilities/monit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: "Monit"
date: 2023-02-23
---

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.

## Install

<details><summary>for Centos 7-8</summary>

To install, run the command on the server:

```sh
yum install epel-release
yum update
yum install monit
systemctl enable monit
systemctl start monit
```

</details>

<details><summary>for Debian-like system:</summary>

To install, run the command on the server:

```sh
sudo apt install monit
```

</details>

Recommended configuration file `/etc/monit/monitrc`:

```
set daemon 1
with start delay 1

set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state

set httpd port 2812 and
use address localhost
allow localhost

include /etc/monit/conf.d/*
```

<details><summary>Configuration file for Astra service</summary>

`/etc/monit/conf.d/astra.conf`

```
check process astra with pidfile /var/run/astra.pid
start program = "/etc/init.d/astra start"
stop program = "/etc/init.d/astra stop"
```

</details>

OR

<details><summary>Configuration file for simple Astra process</summary>

`/etc/monit/conf.d/astra.conf`

```
check process astra.pid with pidfile /var/run/astra.pid
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'"
stop program = "/bin/sh -c 'kill `cat /var/run/astra.pid`'"
```

</details>

Restart monit to apply changes:

```sh
systemctl restart monit
```

or

```sh
sudo /etc/init.d/monit restart
```

## Commands:

- `monit reload` — reload configuration files
- `monit summary` — short information
- `monit start astra` — start Astra
- `monit stop astra` — stop Astra
- `monit restart astra` — restart Astra