Netdata Tomcat執行情況監控外掛
一: 背景
1.伺服器 阿里雲 CentOS
2.Tomcat 8.0.24
3.該外掛透過tomcat的 進行監控
二:Tomcat配置
1.tomcat-users.xml配置
2.開啟tomcat manager應用
三: 安裝外掛xmlstarlet
yum install xmlstarlet
四:tomcat監控外掛指令碼 tomcat.chart.sh
1.指令碼存放路徑 /usr/local/netdata/usr/libexec/netdata/charts.d
2.指令碼下載路徑
3.綠色背景標示的地方,是需要根據自己的tomcat進行調整
五:tomcat監控截圖
1.伺服器 阿里雲 CentOS
2.Tomcat 8.0.24
3.該外掛透過tomcat的 進行監控
二:Tomcat配置
1.tomcat-users.xml配置
點選(此處)摺疊或開啟
-
<?xml version='1.0' encoding='utf-8'?>
-
<!--
-
Licensed to the Apache Software Foundation (ASF) under one or more
-
contributor license agreements. See the NOTICE file distributed with
-
this work for additional information regarding copyright ownership.
-
The ASF licenses this file to You under the Apache License, Version 2.0
-
(the "License"); you may not use this file except in compliance with
-
the License. You may obtain a copy of the License at
-
-
http://www.apache.org/licenses/LICENSE-2.0
-
-
Unless required by applicable law or agreed to in writing, software
-
distributed under the License is distributed on an "AS IS" BASIS,
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
See the License for the specific language governing permissions and
-
limitations under the License.
-
-->
-
<tomcat-users xmlns=""
-
xmlns:xsi=""
-
xsi:schemaLocation=" tomcat-users.xsd"
-
version="1.0">
-
<!--
-
NOTE: By default, no user is included in the "manager-gui" role required
-
to operate the "/manager/html" web application. If you wish to use this app,
-
you must define such a user - the username and password are arbitrary.
-
-->
-
<!--
-
NOTE: The sample user and role entries below are wrapped in a comment
-
and thus are ignored when reading this file. Do not forget to remove
-
<!.. ..> that surrounds them.
-
-->
-
<!--
-
<role rolename="tomcat"/>
-
<role rolename="role1"/>
-
<user username="tomcat" password="tomcat" roles="tomcat"/>
-
<user username="both" password="tomcat" roles="tomcat,role1"/>
-
<user username="role1" password="tomcat" roles="role1"/>
-
-->
-
<role rolename="admin-gui"/>
-
<role rolename="admin-script"/>
-
<role rolename="manager-gui"/>
-
<role rolename="manager-script"/>
-
<role rolename="manager-jmx"/>
-
<role rolename="manager-status"/>
-
<user username="tomcat" password="tomcat1" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
- </tomcat-users>
2.開啟tomcat manager應用
三: 安裝外掛xmlstarlet
yum install xmlstarlet
四:tomcat監控外掛指令碼 tomcat.chart.sh
1.指令碼存放路徑 /usr/local/netdata/usr/libexec/netdata/charts.d
2.指令碼下載路徑
3.綠色背景標示的地方,是需要根據自己的tomcat進行調整
點選(此處)摺疊或開啟
-
#!/bin/bash
-
-
# Description: Tomcat netdata charts.d plugin
-
# Author: Jorge Romero
-
-
# the URL to download tomcat status info
-
tomcat_url=""
-
-
# _update_every is a special variable - it holds the number of seconds
-
# between the calls of the _update() function
-
tomcat_update_every=1
-
-
tomcat_priority=60000
-
-
# convert tomcat floating point values
-
# to integer using this multiplier
-
# this only affects precision - the values
-
# will be in the proper units
-
tomcat_decimal_detail=1000000
-
-
# used by volume chart to convert bytes to KB
-
tomcat_decimal_KB_detail=1000
-
-
tomcat_check() {
-
-
require_cmd xmlstarlet || return 1
-
-
tomcat_get
-
if [ $? -ne 0 ]
-
then
-
echo >&2 "tomcat: cannot find stub_status on URL '${tomcat_url}'. Please set tomcat_url=''"
-
return 1
-
fi
-
-
# this should return:
-
# - 0 to enable the chart
-
# - 1 to disable the chart
-
-
return 0
-
}
-
-
tomcat_get() {
-
# Collect tomcat values
-
mapfile -t lines < <(curl -u tomcatUser:tomcatPassword -Ss "$tomcat_url" |\
-
xmlstarlet sel \
-
-t -m "/status/jvm/memory" -v @free \
-
-n -m "/status/connector[@name='\"http-nio-8080\"']/threadInfo" -v @currentThreadCount \
-
-n -v @currentThreadsBusy \
-
-n -m "/status/connector[@name='\"http-nio-8080\"']/requestInfo" -v @requestCount \
-
-n -v @bytesSent -n -)
-
-
tomcat_jvm_freememory="${lines[0]}"
-
tomcat_threads="${lines[1]}"
-
tomcat_threads_busy="${lines[2]}"
-
tomcat_accesses="${lines[3]}"
-
tomcat_volume="${lines[4]}"
-
-
return 0
-
}
-
-
# _create is called once, to create the charts
-
tomcat_create() {
-
cat <<EOF
-
CHART tomcat.accesses '' "tomcat requests" "requests/s" statistics tomcat.accesses area $((tomcat_priority + 8)) $tomcat_update_every
-
DIMENSION accesses '' incremental
-
CHART tomcat.volume '' "tomcat volume" "KB/s" volume tomcat.volume area $((tomcat_priority + 5)) $tomcat_update_every
-
DIMENSION volume '' incremental divisor ${tomcat_decimal_KB_detail}
-
CHART tomcat.threads '' "tomcat threads" "current threads" statistics tomcat.threads line $((tomcat_priority + 6)) $tomcat_update_every
-
DIMENSION current '' absolute 1
-
DIMENSION busy '' absolute 1
-
CHART tomcat.jvm '' "JVM Free Memory" "MB" statistics tomcat.jvm area $((tomcat_priority + 8)) $tomcat_update_every
-
DIMENSION jvm '' absolute 1 ${tomcat_decimal_detail}
-
EOF
-
return 0
-
}
-
-
# _update is called continiously, to collect the values
-
tomcat_update() {
-
local reqs net
-
# the first argument to this function is the microseconds since last update
-
# pass this parameter to the BEGIN statement (see bellow).
-
-
# do all the work to collect / calculate the values
-
# for each dimension
-
# remember: KEEP IT SIMPLE AND SHORT
-
-
tomcat_get || return 1
-
-
# write the result of the work.
-
cat <<VALUESEOF
-
BEGIN tomcat.accesses $1
-
SET accesses = $((tomcat_accesses))
-
END
-
BEGIN tomcat.volume $1
-
SET volume = $((tomcat_volume))
-
END
-
BEGIN tomcat.threads $1
-
SET current = $((tomcat_threads))
-
SET busy = $((tomcat_threads_busy))
-
END
-
BEGIN tomcat.jvm $1
-
SET jvm = $((tomcat_jvm_freememory))
-
END
-
VALUESEOF
-
-
return 0
- }
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28624388/viewspace-2094935/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【SQL】Oracle資料庫監控sql執行情況SQLOracle資料庫
- Centos效能監控工具——netdata配置CentOS
- 容器雲環境,你們如何監控應用執行情況? ---JFrog 雲原生應用監控實踐
- WGCLOUD部署筆記 配置監測redis的執行情況GCCloud筆記Redis
- SVN外掛和Tomcat外掛地址Tomcat
- 監控 SQL Server 的執行狀況SQLServer
- 在Ubuntu上使用Netdata設定實時效能監控Ubuntu
- 一鍵配置開源伺服器監控工具 NetData伺服器
- tomcat 監控工具probeTomcat
- jvisualvm.exe監控工具安裝外掛LVM
- openwrt,狀態監測netdata
- OushuDB 檢視查詢執行情況
- 商務部:2018年1-7月我國外貿執行情況
- 09 . Prometheus監控tomcat+jvmPrometheusTomcatJVM
- Linux效能監測皮膚 | NETDATALinux
- jProfiler遠端連線Linux監控jvm、tomcat執行狀態LinuxJVMTomcat
- metricbeat 監控 nginx 情況Nginx
- 新版本釋出,新增監控外掛與驅動
- Java監控神器之psi-probe監控Tomcat和應用JavaTomcat
- prepareStatement和Statement執行批處理的執行情況REST
- 寫一個監控採集公眾號文章的外掛
- Rainbond外掛擴充套件:基於Mysql-Exporter監控MysqlAI套件MySqlExport
- Fundebug釋出Vue外掛,簡化BUG監控接入程式碼Vue
- 使用 tideways_xhprof + xhgui 分析 PHP 執行情況IDEGUIPHP
- Linux上監控Tomcat Down掉後自動重啟TomcatLinuxTomcat
- beta版 tomcat 應用監控指標Tomcat指標
- jvisualvm遠端監控Linux下的tomcatLVMLinuxTomcat
- Fundebug後端Java異常監控外掛更新至0.2.0,支援Spri後端Java
- 工信部:2021年鋁行業執行情況行業
- 工信部:2021年焦化行業執行情況行業
- Pytest系列(30)- 使用 pytest-xdist 分散式外掛,如何保證 scope=session 的 fixture 在多程式執行情況下仍然能只執行一次分散式Session
- 監控 Python 記憶體使用情況和程式碼執行時間!Python記憶體
- JVM調優——JVM監控工具jvisualvm的使用及GC外掛安裝JVMLVMGC
- 監控 redis 執行命令Redis
- 安泰科:2021年鎳鈷鋰行業執行情況行業
- 工信部:2021年鋼鐵行業執行情況行業
- 2019年5月份金融市場執行情況
- Maven外掛執行方式Maven
- 得得指數行情監控,BTC短線跌破40000美元CDB