Uptime
The uptime resource can be used to get hosts and services uptime.
Available methods:
GET POST | 
                /api/2/reports/uptime/list | Hosts uptime overview | 
GET POST | 
                /api/2/reports/uptime/get | Services uptime overview | 
list
Returns hosts uptime overview. If a custom range is used, the difference between datefrom and dateto should be in minutes, not in seconds since 1 minute is the lowest data resolution in M/Monit.
Arguments
| range | number | optional | The range id. Possible values: 0=today, 5=week, 6=month, 7=three months, 8=six months, 9=year and 12=custom range. Default is 0=today | 
| datefrom | number | optional | A unix-timestamp (seconds since the epoch, January 1, 1970, 00:00:00 GMT). The timestamp specify the start of a custom uptime range. The range id must also be set to 12, otherwise this argument is ignored. | 
| dateto | number | optional | A unix-timestamp, specifying the end of a custom uptime range. | 
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/reports/uptime/list
Output
| range | Selected time range id. Possible values: 0=today, 5=week, 6=month, 7=three months, 8=six months, 9=year and 12=custom range | 
| datefrom | Selected time range start [unix timestamp] | 
| dateto | Selected time range end [unix timestamp] | 
| uptime | The average hosts uptime [%] | 
| downtime | The average hosts downtime [string representation] | 
| items | |
| id | The internal id assigned by M/Monit to the host when new entry is created | 
| active | The host active flag. Possible values: 0 = host is inactive, 1 = host is monitored | 
| name | The host name | 
| uptime | The host uptime [%] | 
| downtime | The host downtime [string representation] | 
| events | The number of events stored for this host | 
{
    "range": 0,
    "datefrom": 1375048800,
    "dateto": 1375049948,
    "uptime": 100.00,
    "downtime": "0m",
    "items": [
        {
            "id": 185,
            "active": 1,
            "name": "myhost",
            "uptime": 100.00,
            "downtime": "0m",
            "events": 0
        }
    ]
}
get
Returns services uptime for a particular host.
Arguments
| id | number | required | The host id | 
| range | number | optional | The range id. Possible values: 0=today, 5=week, 6=month, 7=three months, 8=six months, 9=year and 12=custom range. Default is 0=today | 
| datefrom | number | optional | A unix-timestamp (seconds since the epoch, January 1, 1970, 00:00:00 GMT). The timestamp specify the start of a custom uptime range. The range id must also be set to 12, otherwise this argument is ignored. | 
| dateto | number | optional | A unix-timestamp, specifying the end of a custom uptime range. | 
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/reports/uptime/get?id=185 \
 -d range=12 \
 -d datefrom=1395014400 \
 -d dateto=1398978058
Output
| range | Selected time range id. Possible values: 0=today, 5=week, 6=month, 7=three months, 8=six months, 9=year and 12=custom range | 
| datefrom | Selected time range start [unix timestamp] | 
| dateto | Selected time range end [unix timestamp] | 
| uptime | The average hosts uptime [%] | 
| downtime | The average hosts downtime [string representation] | 
| items | |
| id | The internal service id assigned by M/Monit | 
| active | The service active flag. Possible values: 0 = service is inactive, 1 = service is monitored | 
| name | The service name | 
| uptime | The service uptime [%] | 
| downtime | The service downtime [string representation] | 
| events | The number of events stored for this service | 
{
    "range": 12,
    "datefrom": 1375048800,
    "dateto": 1375049948,
    "uptime": 63.64,
    "downtime": "6m",
    "items": [
        {
            "id": 240,
            "active": 1,
            "name": "myhost",
            "uptime": 100.00,
            "downtime": "0m",
            "events": 0
        },
        {
            "id": 241,
            "active": 1,
            "name": "rootfs",
            "uptime": 100.00,
            "downtime": "0m",
            "events": 0
        },
        {
            "id": 246,
            "active": 1,
            "name": "binnn",
            "uptime": 0.00,
            "downtime": "19m",
            "events": 0
        }
    ]
}