yaoweibin/nginx_upstream_check_module — pull request #39 by lusis (2014-09-05 20:26:17+00:00)
Title: Feature/json check status

Warning: My C experience is sorely lacking but this was something I've wanted for a while despite working around it for now.

We use the check_status page here to handle alerting. Currently it's painful to consume via scripts because it requires parsing the html. Part of our automated testing workflow also depends on programatic consumption of this information.

This patch allows you to return the status results as json vs html. It's controlled via standard headers (`Accept: application/json`). The format looks like this:

```json
{
"num_servers": 5,
"generation": 1,
"upstreams": [
{
"upstream": "vagrant.vm_wss",
"name": "127.0.0.1:16309",
"status": "up",
"rise_count": 17,
"fall_count": 0,
"check_type": "tcp"
},
{
"upstream": "vagrant.vm_api",
"name": "127.0.0.1:15000",
"status": "up",
"rise_count": 17,
"fall_count": 0,
"check_type": "http"
},
{
"upstream": "vagrant.vm_console",
"name": "127.0.0.1:8080",
"status": "up",
"rise_count": 17,
"fall_count": 0,
"check_type": "http"
},
{
"upstream": "vagrant.vm_idp",
"name": "127.0.0.1:8090",
"status": "up",
"rise_count": 16,
"fall_count": 0,
"check_type": "http"
},
{
"upstream": "vagrant.vm_dispatcher",
"name": "127.0.0.1:8081",
"status": "up",
"rise_count": 17,
"fall_count": 0,
"check_type": "http"
}
]
}
```

I don't know if I got all the nuances of nginx-isms correct or if it's the most efficient. Please let me know.

Thanks!