

#Monit file install

Monitoring of running services, and the ability to start, kill or restart.Capability to act on out-of-bounds values for CPU, RAM, disk, file size, age and more.Automatic process maintenance in a lightweight package.Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations, for example, Monit can prevent your services from getting stopped.īelow are some of the main benefits of using Monit:
#Monit file free
so I wrapped into a bash script and then got it.Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. So basically I was not able to access monit enviroment variable from Python. R = retval = fun(*args, **kwargs)#012 File \"/usr/lib/python2.7/dist-packages/celery/app/trace.py\", line 438, in _protected_call_#012 return n(*args, **kwargs)\n.\n" "pd_error": "content match:\nMay 16 18:07:08 ams01 MainProcess: ERROR Task .gather_and_send_telemetry_info raised unexpected: ConnectionError()#012Traceback (most recent call last):#012 File \"/usr/lib/python2.7/dist-packages/celery/app/trace.py\", line 240, in trace_task#012
#Monit file code
If CONTENT = "ERROR" then exec "/bin/bash /opt/scripts/bin/wrapper.sh"Īnd on 'wrapper.sh' code I have: /usr/bin/python /opt/scripts/bin/dd_notify.py pd_error Then I tried to call my program using a bash wrapper like: check file pd-error with path /var/log/testmonit.log If CONTENT = "ERROR" then exec "/usr/bin/python /opt/scripts/bin/dd_notify.py pd_error "Īnd from dd_notify.py I was trying to do :īut I always got 'key_error' because 'MONIT_DESCRIPTION' wasn't accesible from python Thing is as DevOps says, there's a variable MONIT_DESCRIPTION that in fact has the error string, but this variable is only "reachable" at bash environment.Īs I was doing: check file pd-error with path /var/log/testmonit.log Thanks for DevOps for put me on the rigth track to finish with this issue, I've finally succeed on what I wanted to do, and also can explain (from my understanding) why it wasn't working for me before debug : 'pd-error' Pattern 'ERROR' match on content line : celĮry.worker.job ERROR Task _and_send_telemetry_info fail]īut I'm not having any luck at the moment. What I want is $MONIT_DESCRIPTION content which is actually: What I want is pass the content that has been matched as an additional argument for dd_notify.py program īut what i get is (which is the result of executing dd_notify.py):

If CONTENT = "ERROR" then exec "/usr/bin/python /opt/scripts/bin/dd_notify.py pd_error " $MONIT_DESCRIPTION All Rights Reserved.įollowing DevOps reccommendation, I've upgraded monit version.Īnd tried to use MONIT_DESCRIPTION or $MONIT_DESCRIPTION without success rule file is like this:Ĭheck file pd-error with path /var/log/testmonit.log Sorry I forgot to say that I'm running this on: Ubuntu 16.04 LTS andīuilt with ssl, with ipv6, with compression, with pam and with large filesĬopyright (C) 2001-2017 Tildeslash Ltd. Please if you think this has been addressed before feel free to point me to right direction. I'd a look into google several times (and also here) but I can't find the answer. (I've tried $DESCRIPTION, $HOST.etc but this seems to work only for email) There's any monit variable(like $DESCRIPTION for mail) that refer to MATCH line that trigger the rule? To send this string into my monitoring system (DataDog) I can't find any documentation that actually allows me to use the MATCH content, or groups (which I can see is being supported by the MATCH regex) info : 'testmonit' exec: /usr/bin/python On monit logs I can see: error : 'testmonit' content match This config make what I want, it actually raise the alarm I wantedīut now I need to know "What caused this alarm" so for example if this line appears on the log: ERROR failure to complete process due lock file. Montirc file: check file testmonit with path /var/log/testmonit.logĮxec "/usr/bin/python /opt/scripts/bin/dd_notify.py test-error" Using a very simple rule I'm able to catch line on log that provoke this error and run the specific script to alert until here all ok:

I'm using monit to scan logs for errors and then push those alert into a monitoring system called DataDog.Īll seem to work as expected but now I've need to grab what is causing the alarm. I've asked this question around a week a go at StackOverflow but no answer just yet, probably is no possible but don't know where to look for that answer, I hope someone can help over here.
