The status resource can be used to retrieve hosts status.

Available methods:

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

list

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

curl -b ~/.mmonit/cookie \
 http://127.0.0.1:8080/status/hosts/list

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
led number optional Show only hosts with matching led. Possible values: 0=red, 1=orange, 2=green, 3=gray

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
totalRecords The number of hosts in the selection
{
    "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
        }
    ],
    "totalRecords": 1
}

get

Returns detailed status of the given host.

curl -b ~/.mmonit/cookie \
 http://127.0.0.1:8080/status/hosts/get?id=185

Arguments

id number required Show the host with the matching id

Output

is_user_admin True if the user is admin, 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
descriptor The statistics descriptor (used to differentiate statistics of the same type within context of the same service)
value The statistics value (latest)
{
    "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
                        }
                    ]
                }
            ]
        }
    }
}

summary

Returns a status summary of all hosts.

curl -b ~/.mmonit/cookie \
 http://127.0.0.1:8080/status/hosts/summary

Arguments

none

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
        }
    ]
}