本文共 2369 字,大约阅读时间需要 7 分钟。
[root@localhost handle_tomcat_status]# cat handle.sh #!/bin/shawk '/Free memory:/{print "Free memory: " $4}' a.txt awk '/Total memory:/{print "Total memory: " $8}' a.txtawk '/Max memory:/{print "Max memory: " $12}' a.txt for n in 'Eden Space' 'Survivor Space' 'Tenured Gen' 'Code Cache' 'Compressed Class Space' 'Metaspace'do awk -F"($n)+" '/Eden Space/{ print $2}' a.txt |awk -v name="$n" -F'[()]+' '{print name ": " $5 " "$7 " "$9 " "$11}'done
html内容:
curl http://tomcat:s3cret@192.168.10.12:8080/manager/status?JSON=true
/manager
Server Status Manager | List Applications | HTML Manager Help | Manager Help | Complete Server Status Server Information | Tomcat Version | JVM Version | JVM Vendor | OS Name | OS Version | OS Architecture | Hostname | IP Address | Apache Tomcat/7.0.53 | 1.8.0_91-b14 | Oracle Corporation | Linux | 2.6.32-431.el6.x86_64 | amd64 | localhost | 127.0.0.1 JVM Free memory: 27.21 MB Total memory: 58.00 MB Max memory: 928.00 MB Memory PoolTypeInitialTotalMaximumUsedEden SpaceHeap memory16.00 MB16.00 MB256.00 MB10.50 MB (4%)Survivor SpaceHeap memory2.00 MB2.00 MB32.00 MB0.82 MB (2%)Tenured GenHeap memory40.00 MB40.00 MB640.00 MB19.45 MB (3%)Code CacheNon-heap memory2.43 MB6.62 MB240.00 MB6.49 MB (2%)Compressed Class SpaceNon-heap memory0.00 MB2.12 MB1024.00 MB1.95 MB (0%)MetaspaceNon-heap memory0.00 MB18.37 MB-0.00 MB17.73 MB "ajp-bio-8009" Max threads: 200 Current thread count: 0 Current thread busy: 0 Max processing time: 0 ms Processing time: 0.0 s Request count: 0 Error count: 0 Bytes received: 0.00 MB Bytes sent: 0.00 MB StageTimeB SentB RecvClient (Forwarded)Client (Actual)VHostRequest P: Parse and prepare request S: Service F: Finishing R: Ready K: Keepalive "http-bio-8080" Max threads: 200 Current thread count: 10 Current thread busy: 1 Max processing time: 166 ms Processing time: 0.552 s Request count: 47 Error count: 6 Bytes received: 0.00 MB Bytes sent: 0.27 MB StageTimeB SentB RecvClient (Forwarded)Client (Actual)VHostRequest S1 ms0 KB0 KB192.168.10.12192.168.10.12 192.168.10.12 | GET /manager/status?JSON=true HTTP/1.1 R?????? R?????? R?????? P: Parse and prepare request S: Service F: Finishing R: Ready K: Keepalive Copyright © 1999-2014, Apache Software Foundation | | | | |
转载于:https://blog.51cto.com/lvnian/1859894