Please or Zarejestruj się to create posts and topics.

cpu_server_proces - monitoring wykorzystania pamięci ram przez serwer www

Moduł pozwala na wysłanie odpowiedniego alertu, jeśli wykorzystanie pamięci ram przez procesy serwera wzrośnie powyżej ustalonego limitu (standardowo 512mb, można zmienić w pliku źródłowym modułu). Jeśli plik dziennika jest włączony, dodaje także odpowiedni wpis do pliku dziennika journal wraz z datą wystąpienia incydentu.

Moduł jest uzupełnieniem oryginalnej formuły monitorowania obciążenia serwera Apache lub Nginx, ale działa od niego niezależnie. Pozwala na wcześniejsze wykrycie wzrostu zużycia pamięci ram i wysłanie odpowiedniego alertu, zanim wspomniana formuła serwer zrestartuje.

Paczka do pobrania cpu_server_proces_v1.5

Suma kontrolna MD5

Module Setup

1. Extract the package to /etc/monit/custommodules/. If the custommodules directory does not exist, create it.
2. Modify the settings in the config.cpp file if needed.
3. Run the autogen.sh script. This will create the executable file for the module.
4. Add the following entry to the /etc/monit/monitrc file, depending on the web server you are using, Apache or Nginx:

# cpu_server_proces for apache
check program mem_apache_proces_nobuffors with path "/etc/monit/custommodules/cpu_server_proces/cpu_server_proces"
every 1 cycles
if status != 0 then alert

# cpu_server_proces for nginx
check program mem_nginx_proces_nobuffors with path "/etc/monit/custommodules/cpu_server_proces/cpu_server_proces"
every 1 cycles
if status != 0 then alert

5. Reload Monit with the command:
$ systemctl reload monit

Module Update

1. Replace the module files with the newer version.
2. Run the autogen.sh script.
3. Reload Monit with the command:
$ systemctl reload monit

Uruchomienie modułu

1. Rozpakuj paczkę do /etc/monit/custrommodules/ Jeśli nie masz katalogu custommodules, utwórz go
2. Zmień ustawienia w pliku config.cpp jeśli masz taką potrzebę
3. Uruchom plik autogen.sh. Spowoduje to utworzenie pliku wykonywalnego modułu
4. Dodaj do pliku /etc/monit/monitrc poniższy wpis w zależności od posiadanego serwera, apache lub nginx:

# cpu_server_proces for apache
check program mem_apache_proces_nobuffors with path "/etc/monit/custommodules/cpu_server_proces/cpu_server_proces"
every 1 cycles
if status !=0 then alert

# cpu_server_proces for nginx
check program mem_nginx_proces_nobuffors with path "/etc/monit/custommodules/cpu_server_proces/cpu_server_proces"
every 1 cycles
if status !=0 then alert

5. przeładuj monit poleceniem:
$ systemctl reload monit

Aktualizacja modułu

1. Zastąp pliki modułu, jego nowszą wersją
2. Uruchom plik autogen.sh
3. przeładuj monit poleceniem:
$ systemctl reload monit

chanelog

v1.5

- I added the option to display messages in English.
- I reduced the module generation to a single one for Apache and Nginx,
depending on the web server used.
- I modified the content of the displayed messages.
- I changed the module name.

- Dodałem możliwość wyświetlenia komunikatów po angielsku
- Zredukowałem generowanie modułu do jednego, dla Apache i Nginx,
w zależności od posiadanego serwera www
- Zmodyfikowałem treść wyświetlanych komunikatów
- Zmieniłem nazwę modułu

v1.4.1

  • Reorganizacja kodu źródłowego dla lepszej czytelności
  • Przeniesienie zmiennych konfiguracyjnych modułu na sam początek kodu źródłowego

v1.4

  • I added the option to enable a log file where messages are recorded when the defined maximum RAM usage value is exceeded.
  • I added a variable to define the RAM usage threshold that triggers an alert.
  • I improved code readability.
  • I simplified the method for identifying the PHP versions running on the server.

 

  • dodałem możliwość włączenia pliku dziennika, do którego zapisywane są komunikaty w przypadku przekroczenia ustalonej, maksymalnej wartości pamięci Ram.
  • dodałem zmienną, w której można zdefiniować wartość pamięci ram, po przekroczeniu której wysyłany jest alert.
  • poprawiłem czytelność kodu
  • uprościłem sposób wskazania wersji php uruchomionych na serwerze

Test obciążeniowy

% time seconds usecs/call calls errors syscall

0.00 0.000000 0 1 1 faccessat
0.00 0.000000 0 29 openat
0.00 0.000000 0 29 close
0.00 0.000000 0 39 read
0.00 0.000000 0 1 write
0.00 0.000000 0 6 newfstatat
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 1 futex
0.00 0.000000 0 1 set_robust_list
0.00 0.000000 0 3 brk
0.00 0.000000 0 8 munmap
0.00 0.000000 0 1 execve
0.00 0.000000 0 16 mmap
0.00 0.000000 0 10 mprotect
0.00 0.000000 0 1 prlimit64
0.00 0.000000 0 1 getrandom
0.00 0.000000 0 1 rseq

100.00 0.000000 0 149 1 total