Checking the server status

In this recipe, we will learn how to check the state of a running WildFly instance, by invoking a command to the CLI.

Getting ready

Remember I'm running WildFly remotely, bound to 192.168.59.103 as IP. WildFly is already up and running.

How to do it…

Open a new terminal window and execute the following:

$ cd $WILDFLY_HOME
$ ./bin/jboss-cli.sh -c --controller=192.168.59.103:9990 --user=wildfly --password=cookbook.2015 --command=":read-attribute(name=server-state)"
{
    "outcome" => "success",
    "result" => "running"
}

You can extract just the information you need by using the awk command in the output (you can use whichever tool you are comfortable with), as follows:

$ ./bin/jboss-cli.sh -c --controller=192.168.59.103:9990 --user=wildfly ...

Get WildFly Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.