Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

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.

question from:https://stackoverflow.com/questions/66048304/accessing-tomcat-status-from-the-command-line

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...