4

I'm just wondering whether monit has an API, which we could poll-regularly (perhaps something that is http-based) ?

It would be very useful to create an integrated monitoring solution across multiple servers. Or perhaps there is no other option other than m/monit?

giosakti
  • 149
  • 1
  • 3
  • What is your final purpose? How about this http://mmonit.com/wiki/MMonit/HTTP-API? – quanta Sep 26 '12 at 07:20
  • 2
    I'm looking for open-source alternatives other than m/monit.. – giosakti Sep 26 '12 at 10:43
  • You really need to give a bit more detail about what exactly you want to monitor and how, since there are a LOT of server monitoring tools out there besides Monit. If you have looked over a few of these and none of them meet your needs then you must be doing something unusual, and need to say so. – dunxd Oct 05 '12 at 23:20
  • FWIW, I know this thread is old but as I didn't find any satisfactory answer to this question myself I wrote this https://imil.net/blog/2016/03/16/Fetch-monit-status-in-JSON/ HTH – iMil Mar 16 '16 at 20:51

2 Answers2

8

This is old, I know, but monit has a basic API, found at:

http://SERVER_IP:2812/_status?format=xml

There also appears to be a JSON format as well (change format to json from XML). You can parse the XML for everything you need (I've done it in python easily). However, I can't seem to find any documentation on this, so you have to discover what you can.

Some of the m/monit documentation details some of the monit codes, so you should get some help from there.

You can also check out monittr https://github.com/karmi/monittr.

That is a ruby implementation of monitoring multiple monit instances.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
deranjer
  • 181
  • 1
  • 6
  • How did you get JSON format? I'm running latest official build 5.16 and it looks like there only plaintext status and XML status are available and no JSON. – timurb Feb 20 '16 at 11:21
  • Hmm, it works on my version (5.9) with this url: http://SERVERIP:2812/_status?format=json I assume it may have been removed in the later versions? – deranjer Feb 20 '16 at 17:17
  • Update: I've checked all my hosts, and the latest monit version I have running is 5.14, and JSON works on that. – deranjer Feb 20 '16 at 17:25
  • Could you be running custom patched version? Or are you referring to M/Monit? I've found a ticket in Monit bugtracker with such feature request but it's dated back to only few months ago and is unresolved: https://bitbucket.org/tildeslash/monit/issues/240/feature-request-implement-json-formatted – timurb Feb 22 '16 at 19:04
  • The monit version running on my openmediavault server might be patched, but my debian/ubuntu monit's are running direct from the default repos. Also, not referring to M/Monit. – deranjer Feb 23 '16 at 01:09
0

For the record and for future seekers, here's the monit http API

ptheofan
  • 381
  • 1
  • 3
  • 5
  • 6
    The link you posted is to the API documentation of M/Monit, the commercial SaaS that makes use of Monit, the open source watchdog software. (I agree that the naming is confusing). The OP wanted an API to interact with Monit, specifically to build an alternative to M/Monit. – Kenny Rasschaert Jul 28 '17 at 13:54