API XML

Issue #736 closed
Former user created an issue

Hello, i've got a little question about API monit.

The "monit status" command line give some textual informations about status, monitoring status, monitoring mode. These informations is different if it's about service or filesystem.

The API (http://192.168.151.237:2812/_status?format=json) doesn't give result json format, then i use this one instead : http://192.168.151.237:2812/_status?format=xml.

Is there a way to get information about different values of these elements :

monitorstate (Monitoring Status) monitormode (Monitoring mode) status (Status)

I mean, api give 0, 1, 2, 3.... code, what is the correspondence in text ?

Thanks for your help

Comments (13)

  1. Tildeslash repo owner

    Hello,

    the XML interface is documented just in the source code, you can check the src/http/xml.c file and related header files (src/monit.h).

    Best regards, The Monit team

  2. plegrand

    Sorry to insist but i cant find the different value that can take the "status" element. In "monit service manager", i can see for example "Running" or "Accessible". But in the xml it's only number.

    In fact i found on internet that :

    service[$i]->monitor
    0: Off
    1: On
    2: Initializing
    3: Waiting
    
    service[$i]->monitormode
    0: Active
    1: Passive
    2: Manual
    

    I would like to know the same for System, Process, FileSystem service[$i]->status

    and i cant find it inside the file you propose. Thanks for your help

  3. plegrand

    Thanks for your answer but in this function, i cant see the strings

    "Running" for system status
    "Running " for process status
    "Accessible" for FileSystem status
    

    Where these strings are defined and where the correspondence between codes and strings are defined also.

    Thanks again for your help

  4. Tildeslash repo owner

    you have probably older monit version, the latest prints just "OK" if the service has no errors. If you need to see how it's generated, see the source code of the corresponding monit version

  5. plegrand

    Yes i've got 5.20 version. I see in "monit-5.20.0/src/monit.c" on line 142 the different value of "statusname" :

    char *statusnames[] = {"Accessible", "Accessible", "Accessible", "Running", "Online with all services", "Running", "Accessible", "Status ok", "UP"};
    

    Does it means that status is always "positive" ?

    Thanks again

  6. plegrand

    thanks again for your answers. just the last ;-) what is the meaning of "bitmap", my English is little poor. Is there a list of events status ?
    i understand that "<status>0</status>" means status OK. But status can have other value ?

    It will be my last question Thanks again for your help

  7. Tildeslash repo owner

    no, the s->error is uint32_t variable and is used as a 32-bit bitmap, where each bit corresponds to specific event. If that bit is set to 1, the given error is active (0 = no problem).

    In the case that the service has some error, monit walks this bitmap and add the event description to the status text. You can see the event definition in src/event.c and src/event.h

  8. Log in to comment