This example demonstrate the HTTP-API using the cURL command-line utility.

First, create a directory with restricted access for storing the session cookie safely.

mkdir -m 0700 ~/.mmonit

Fetch the zsessionid cookie and store it in our cookie store

curl -c ~/.mmonit/cookie \
 http://127.0.0.1:8080/index.csp

Login with username and password (the zsessionid cookie is read from the file). We also add z_csrf_protection=off as a parameter to turn CSRF-protection off for this session. Otherwise we would have to obtain and send a CSRF-token with every POST method when accessing /admin/* resources.

curl -b ~/.mmonit/cookie \
 -d z_username=admin \
 -d z_password=swordfish \
 -d z_csrf_protection=off \
 http://127.0.0.1:8080/z_security_check

After login, we can start querying for data. For instance, the host status list

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

Logout (invalidate the given zsessionid cookie).

curl -b ~/.mmonit/cookie \
 http://127.0.0.1:8080/login/logout.csp

Note:

For simplicity, the login example above shows password used on the command line, in practice it is more secure to store credentials in a protected file which is used with the -d option to curl.

curl -b ~/.mmonit/cookie \
 -d @/home/myusername/.mmonit/credentials \
 http://127.0.0.1:8080/z_security_check