Read Monit status from the command line using html2text
I have a Monit instance managing several daemons and processes on a VPS. I don't want to expose the Monit endpoint over the internet but I do want to be able to quickly view my system's status. Monit serves their status page as HTML which isn't the easiest thing to read from the console. So I installed html2text
and now I can curl
the HTML response into html2text
and see a pretty formatted text output that is close enough to the HTML layout to be useful.
curl -sSB http://localhost:2812 | html2text -ascii
```
`curl -s` silences the progress bar output.
`curl -S` allows for showing errors.
`curl -B` converts the output to ASCII.
`html2text` seemed to have issues with rendering Unicode/UTF-8 output and since that support wasn't necessary for me I chose to simply go with the ASCII character set and avoid any warnings from `html2text`.
`html2text -ascii` let's it know to expect ASCII format.
Now instead of a mangled mess of HTML I see a nicely formatted table.
![html2text example output](https://www.evernote.com/shard/s13/sh/fd3e904f-6c14-420a-96d5-4beb7414af9c/bee17e88262a784be21e76239029010c/deep/0/1.-ugtastic@ugtastic----(ssh).png)
Written by Mike Hall
Related protips
3 Responses
Install html2text
on Ubuntu using sudo apt-get -y install html2text
.
Did you try "monit summary"? That gives you a nice overview as well...
In case anyone stumbles on this post: you don't need to use html2text anymore. Just make a request to "/_status" instead of "/":
curl -sSB http://127.0.0.1:2812/_status
You can also get it in XML format by adding "?format=xml". To get a very brief summary, append "?level=summary".
That page has several other parameters to customize the output, but they don't seem to be documented. Here's a link to the source.