The status resource can be used to retrieve hosts status.

Available methods:

GET POST /api/2/status/hosts/list Status overview
GET POST /api/2/status/hosts/get Details for a specific host
GET POST /api/2/status/hosts/summary Status summary

list

Returns the current status of all hosts registered in M/Monit.

Arguments

hostid number optional Show only hosts with matching host id. The argument can be used multiple times to select multiple hosts
hostpattern string optional Show only hosts that contain the specified substring. Only one hostpattern argument can be used.
hostgroupid number optional Show only hosts which are member of the given hostgroupid. The argument can be used multiple times to select multiple hosts groups
led number optional Show only hosts with matching led. Possible values: 0=red, 1=orange, 2=green, 3=gray. The argument can be used multiple times to select multiple leds
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/status/hosts/list

Output

id The internal id assigned by M/Monit to the host when a new entry is created
led The status LED. Possible values: 0=red, 1=orange, 2=green, 3=gray
hostname The host name
events The number of events stored for this host
cpu The CPU usage [%]
mem The memory usage [%]
status The status description
statusid The status id. Possible values: 0=active, 1=inactive, 2=ignored
heartbeat The heartbeat status. Possible values: 0 = host dead, 1 = host ok
recordsReturned The number of hosts in the result set
pageSize The maximum number of hosts to return (page size)
totalRecords The total number of hosts which match the selection. If the totalRecords exceeds the pageSize value, the result is paginated
startIndex The page index (position) in the selection
sort The sort key. Possible values: "led", "hostname", "events", "cpu", "mem", "status"
dir The sort direction. Possible values: "desc" (descending), "asc" (ascending)
{
    "records": [
        {
            "id": 185,
            "led": 1,
            "hostname": "myhost",
            "events": 17,
            "cpu": 5.6,
            "mem": 46.1,
            "status": "6 out of 10 services are available",
            "statusid": 0,
            "heartbeat": 1
        }
    ],
    "pageSize":15,
    "recordsReturned":15,
    "totalRecords":50,
    "startIndex":0,
    "sort":"hostname",
    "dir":"asc"
}

get

Returns detailed status of the given host.

Arguments

id number required Show the host with the matching id
led number optional Show only services with matching led. Possible values: 0=red, 1=orange, 2=green, 3=gray. The argument can be used multiple times to select multiple leds
servicepattern string optional Show only services that contain the specified substring. Only one servicepattern argument can be used.
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/status/hosts/get?id=185

Output

serviceactions True if the user may perform service actions, false if not
host
id The internal id assigned by M/Monit to the host when a new entry is created
name The host name
led The status LED. Possible values: 0=red, 1=orange, 2=green, 3=gray
status The status description
statusid The status id. Possible values: 0=active, 1=inactive, 2=ignored
heartbeat The heartbeat status. Possible values: 0 = host dead, 1 = host ok
platform
name The name of the platform corresponding to `uname -s` output
release The platform release corresponding to `uname -r` output
version The platform version corresponding to `uname -v` output
machine The platform machine corresponding to `uname -m` output
cpu
count The number of CPUs as seen by the system
memory
size The memory size available to the system [kB]
swap
size The swap size available to the system [kB]
monit
id The monit id
version The monit version
controlfile The monit configuration file path
poll The monit poll cycle length [seconds]
startdelay The monit start delay [seconds]
uptime The monit uptime
services
id The internal service id assigned by M/Monit
name The service name
nameid A unique id assigned to the name string (shared by any instance of the same string)
type The service type. Possible values: 0=filesystem, 1=directory, 2=file, 3=process, 4=remote host, 5=system, 6=fifo, 7=program
typeid The service type id
monitorstate The service monitoring state bitmap. Possible values (can be combined with logical OR): 0x0=off, 0x1=on, 0x2=initializing, 0x4=waiting
monitormode The service monitoring mode. Possible values: 0=active, 1=passive, 2=manual
onreboot The service onreboot mode. Possible values: 0=start, 1=nostart, 2=laststate
status The service status description
led The service status LED. Possible values: 0=red, 1=orange, 2=green, 3=gray
events The number of events stored for this service
every A service check schedule
statistics
id The statistics id
type The statistics type. Possible values: 0=load average, 1=CPU usage percent user, 2=CPU usage percent system, 3=CPU usage percent wait, 4=memory usage percent, 5=memory usage kilobyte, 6=swap usage percent, 7=swap usage kilobyte, 8=process CPU usage percent, 9=process CPU usage percent total, 10=process memory usage percent, 11=process memory usage percent total, 12=process memory usage kilobyte, 13=process memory usage kilobyte total, 14=children, 15=port response time, 16=unix socket response time, 17=ping response time, 18=space usage percent, 19=space usage megabyte, 20=space total, 21=inode usage percent, 22=inode usage count, 23=inode total, 24=program status, 25=flags, 26=mode, 27=UID, 28=GID, 29=size, 30=PID, 31=parent PID, 32=checksum, 33=timestamp, 34=uptime, 35=ProgramOutput, 36=NetState, 37=NetSpeed, 38=NetDuplex, 39=NetBytesIn, 40=NetBytesInTotal, 41=NetPacketsIn, 42=NetPacketsInTotal, 43=NetErrorsIn, 44=NetErrorsInTotal, 45=NetBytesOut, 46=NetBytesOutTotal, 47=NetPacketsOut, 48=NetPacketsOutTotal, 49=NetErrorsOut, 50=NetErrorsOutTotal, 51=Downtime, 52=Threads, 53=FilesystemType, 54=FilesystemReadBytes, 55=FilesystemReadBytesTotal, 56=FilesystemReadOperations, 57=FilesystemReadOperationsTotal, 58=FilesystemWriteBytes, 59=FilesystemWriteBytesTotal, 60=FilesystemWriteOperations, 61=FilesystemWriteOperationsTotal, 62=FilesystemServiceTimeRead, 63=FilesystemServiceTimeWrite, 64=FilesystemServiceTimeWait, 65=FilesystemServiceTimeRun, 66=FilesystemServiceTime, 67=ProcessReadBytes, 68=ProcessReadBytesTotal, 69=ProcessReadOperations, 70=ProcessReadOperationsTotal, 71=ProcessWriteBytes, 72=ProcessWriteBytesTotal, 73=ProcessWriteOperations, 74=ProcessWriteOperationsTotal, 75=CertificateValidDays, 76=TimestampAccess, 77=TimestampChange, 78=TimestampModify
descriptor The statistics descriptor (used to differentiate statistics of the same type within context of the same service)
value The statistics value (latest)
recordsReturned The number of hosts in the result set
pageSize The maximum number of services to return (page size)
totalRecords The total number of services which match the selection. If the totalRecords exceeds the pageSize value, the result is paginated
startIndex The page index (position) in the selection
sort The sort key. Possible values: "led", "type", "name", "status", "events"
dir The sort direction. Possible values: "desc" (descending), "asc" (ascending)
{
    "records": {
        "is_user_admin": true,
        "host": {
            "id": 185,
            "name": "trilobite.local",
            "led": 1,
            "status": "6 out of 10 services are available",
            "statusid": 0,
            "heartbeat": 1,
            "platform": {
                "name": "Darwin",
                "release": "12.4.0",
                "version": "Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64",
                "machine": "x86_64"
            },
            "cpu": {
                "count": 8
            },
            "memory": {
                "size": 16777216
            },
            "swap": {
                "size": 2097152
            },
            "monit": {
                "id": "87ae6fba82cca9d16e9d791b9e6f78dd",
                "version": "5.6",
                "controlfile": "/etc/monitrc",
                "poll": 5,
                "startdelay": 0,
                "uptime": "2d, 14h, 15m"
            },
            "services": [
                {
                    "id": 240,
                    "name": "myhost",
                    "nameid": 5,
                    "type": "System",
                    "typeid": 5,
                    "monitorstate": 1,
                    "monitormode": 0,
                    "onreboot": 0,
                    "status": "Running",
                    "led": 2,
                    "events": 0,
                    "every": "Every cycle",
                    "statistics": [
                        {
                            "id": 186,
                            "type": 0,
                            "descriptor": "",
                            "value": 1.58
                        },
                        {
                            "id": 187,
                            "type": 1,
                            "descriptor": "",
                            "value": 4.4
                        },
                        {
                            "id": 188,
                            "type": 2,
                            "descriptor": "",
                            "value": 2.1
                        },
                        {
                            "id": 189,
                            "type": 4,
                            "descriptor": "",
                            "value": 46
                        },
                        {
                            "id": 190,
                            "type": 5,
                            "descriptor": "",
                            "value": 7718052
                        },
                        {
                            "id": 191,
                            "type": 6,
                            "descriptor": "",
                            "value": 65.4
                        },
                        {
                            "id": 192,
                            "type": 7,
                            "descriptor": "",
                            "value": 1373368
                        }
                    ]
                }
            ]
        }
    },
    "pageSize":10000,
    "recordsReturned":50,
    "totalRecords":50,
    "startIndex":0,
    "sort":"type",
    "dir":"desc"
}

summary

Returns hosts status summary.

Arguments

hostid number optional Show only hosts with matching host id. The argument can be used multiple times to select multiple hosts
hostgroupid number optional Show only hosts which are member of the given hostgroupid. The argument can be used multiple times to select multiple hosts groups
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/status/hosts/summary

Output

label The host state
data The number of hosts in the given state
{
    "status": [
        {
            "label": "failed",
            "data": 0
        },
        {
            "label": "services failed",
            "data": 0
        },
        {
            "label": "some services failed/unmonitored",
            "data": 1
        },
        {
            "label": "ok",
            "data": 0
        },
        {
            "label": "inactive",
            "data": 1
        },
        {
            "label": "ignored",
            "data": 0
        }
    ]
}