Jboss Status Scripts

Create a management user and make a simple script which include the following line:

jboss@grajuelinux:~$ curl -u monitor:Monit0r\@dmin --digest -L -D - http://localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-attribute","name":"server-state","json.pretty":1}'
HTTP/1.1 401 Unauthorized
Www-authenticate: Digest realm="ManagementRealm",nonce="be7ee56c0c8145a652494b3e24bb4762"
Date: Tue, 06 Mar 2018 08:25:14 GMT
Content-length: 0

HTTP/1.1 200 OK
Date: Tue, 06 Mar 2018 08:25:14 GMT
Transfer-encoding: chunked
Content-type: application/json

{
    "outcome" : "success",
    "result" : "running"
}jboss@grajuelinux:~$

When the server is down…:

jboss@grajuelinux:~$ curl -u monitor:Monit0r\@dmin --digest -L -D - http://localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-attribute","name":"server-state","json.pretty":1}'
curl: (7) Failed to connect to localhost port 9990: Conexión rehusada
[1]+  Salida 143              nohup EAP-6.4.0/bin/standalone.sh
jboss@grajuelinux:~$ echo $?
7
jboss@grajuelinux:~$