deltamind106
deltamind106

Reputation: 707

Accessing Tomcat Status from the Command-Line

I am looking for a simple REST API that will provide the status of the various web application that are deployed in a Tomcat container.

The information I'm looking for is easily obtained by pointing your browser at:

http://localhost:8080/manager/html

This shows the web applications that are loaded, and whether each web app is running or stopped.

I would like to access this same information using "curl" from the command line. It is not a problem to hard-code the Tomcat username/password credentials in the curl command-line, as this is a secure server where no one has an active account. Is there a REST API that would allow me to do this easily?

Thank you.

Upvotes: 0

Views: 3505

Answers (1)

stdunbar
stdunbar

Reputation: 17455

The manager webapp has the /text URL too and it has many options. For example, a simple list of the applications:

$ curl -u tomcat:tomcat http://localhost:8080/manager/text/list
OK - Listed applications for virtual host [localhost]
/:running:0:ROOT
/examples:running:0:examples
/host-manager:running:0:host-manager
/servlet_example_war:running:0:servlet_example_war
/manager:running:1:manager
/docs:running:0:docs

Note that you need to add additional roles to Tomcat (often in conf/tomcat-users.xml) to use the "text" commands. See Configuring Manager Application Access first for the roles you need to add and then Supported Manager Commands for all of the things you can do with the text portion of the manager web app.

Upvotes: 2

Related Questions