Home > OS >  Zabbix monitor Windows more tomcat scripts
Zabbix monitor Windows more tomcat scripts

Time:10-02

Windows server, deploy the multiple tomcat
Now using all tomcat zabbix monitoring running state
Acquire the tomcat named: jvm_name. Bat
@ echo off & amp; Setlocal EnableDelayedExpansion
The set j=0
For/f "delims=" "" % % I in (jvm_name. TXT) do (
The set/a j +=1
The set con! J!=% % I
Call the set tomcat_name=% % con! J! % %
The echo! Tomcat_name!
)

Then the jstat. Bat to obtain the status of each process
@ echo off & amp; Setlocal EnableDelayedExpansion
The set j=0
For/f "delims=" "" % % I in (E: \ soft \ jvm_name. TXT) do (
The set/a j +=1
The set con! J!=% % I
Call the set tomcat_name=% % con! J! % %
The echo! Tomcat_name!
)
Wmic process where (name="Java. Exe and CommandLine" like "I % % % %") get Handle | gawk -f "Handle" '{print $NF}' & gt; E: \ soft \ t_id TXT
The set j=0
For/f "skip=1" % % a in (E: \ soft \ t_id. TXT) do (
The set/a + b=1
The set con! b!=% % a
Call the set t_id=% % con! b! % %
The echo! T_id!
)
The set jstat_home=% java_home %
Pushd jstat_home % %
Bin \ jstat - gc t_id "% %" & gt; E: \ soft \ "% % tomcat_name" gc

Last monitor client values: jvm_status. Bat
@ echo off
The set t=$1
The set jvm_key=$2
Cat E: \ soft \ zabbix_agent \ logs \ $t.g c | grep -w "$jvm_key" | gawk '{print $2}


Timing task jstat. Bat per minute to get a state
Then the zabbix agent - configuration monitoring
UserParameter=JVM. Name, E: \ soft/jvm_name sh
UserParameter=JVM. Status, E: \ soft/jvm_status sh $1, $2


Now have a few problems, due to my poor foundation, modify the script for a few days, still can't solve
Free for help, and hope you can help us see
Problem a: bin \ jstat - gc t_id "% %" & gt; E: \ soft \ "% tomcat_name %". Gc here two variables can take to the value of the last on the variable assignment and executed within an error
Problem two: E: \ soft \ "% tomcat_name %". Gc to parameters of the problem, is the data of two side-by-side, how to change to two vertical placement of data
Question 3: wmic process where (name="Java. Exe and CommandLine" like "I % % % %") get Handle | gawk -f "Handle" '{print $NF}' & gt; E: \ soft \ t_id TXT
To obtain the value of the end of each line and in the end, there are Spaces and blank lines
For/f "skip=1" % % a in (E: \ soft \ t_id. TXT), skip the first line limits, finally there is a line (if the first problem to solve, this is can be ignored, as long as the first problem, can put the two variables associated assignment in execution is successful, the last blank lines should not affect)

CodePudding user response:

Baidu search relevant keywords,
  • Related