bitnami / gonit

Drop-in replacement for monit written in Go, with Apache 2.0 license
https://bitnami.com
Apache License 2.0
77 stars 13 forks source link

Cannot trigger memory checks #31

Closed cardillos closed 1 year ago

cardillos commented 1 year ago

What steps will reproduce the bug?

We are trying to get a notification when the system is in "Out of Memory" state.

This is our system.conf configuration,

check system localhost
  if memory usage > 10% for 2 cycles then alert

oom checker:

/**
oom.c
allocate chunks of 10MB of memory indefinitely until you run out of memory
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define TEN_MB 10 * 1024 * 1024

int main(int argc, char **argv){

        int c = 0;
        int counter1=0;
        while (1){
                char *b = malloc(TEN_MB);
                memset(b, TEN_MB, 0);
                printf("Allocated %d MB\n", (++c * 10));
                counter1++;

                if (counter1 %1000 == 0){
                        sleep (5);
                }
        }
        return 0;
}

/etc/gonit/gonitrc

set httpd port 2812 and
    use address localhost
    allow localhost

set daemon 30  #120            # check services at 2-minute intervals
set log /var/log/gonit.log

include /etc/gonit/conf.d/*.conf

What is the expected behavior?

Expecting alert on logs

What do you see instead?

executed this command tail -f /var/log/gonit.log /var/log/messages

time="2023-02-22T09:39:08+08:00" level=info msg="Performing checks"
time="2023-02-22T09:39:08+08:00" level=info msg="Performing check%!(EXTRA string=localhost)"
time="2023-02-22T09:41:08+08:00" level=info msg="Performing checks"
time="2023-02-22T09:41:08+08:00" level=info msg="Performing check%!(EXTRA string=localhost)"
time="2023-02-22T09:43:08+08:00" level=info msg="Performing checks"
time="2023-02-22T09:43:08+08:00" level=info msg="Performing check%!(EXTRA string=localhost)"

Additional information

Gonit 0.2.8 Built on: 2023-01-25 05:10:10 UTC Git Commit: 66756d06008c97febc1266cd9254ea2d4acd13b5

marcosbc commented 1 year ago

Hi @cardillos, unfortunately that feature is not supported by gonit, and we are not expecting to add new features at the moment.

However, we are open for contributions, so feel free to send a PR implementing this feature. The team would be glad to help with the review and release.