Simple distributed management of nmon ant for performance monitoring

Article Directory

I. Introduction

When doing performance monitoring, we need to collect some indicators of the operating system to facilitate analysis. If there are multiple servers, how do we use one command to batch start nmon to collect indicators? In fact, there are many ways to use Python, Java and other programming methods, and there are also the most primitive ant deployment tools.

Two, install ant

Install ant and configure environment variables (there are many examples on the Internet), so I won't repeat them here.

The following figure is what it looks like after successful deployment:

Insert picture description here

Three, deploy nmon

Put nmon in a folder of the Linux operating system and give executable permissions such as:

chmod a+x nmon
Insert picture description here

Preparation of build.xmldocuments:

<project  name="AntHome" basedir="../" default="main">
 <property name="user"  value="root"/>   <!--用户名-->
 <property name="passwd"  value="123456"/>  <!--密码-->
 <property name="app30"  value="被测ip地址"/>   <!--IP地址-->
 <property name="app29"  value="被测ip地址"/>   <!--IP地址-->
 <property name="DB88"  value="被测ip地址"/>   <!--IP地址-->
 <property name="targetDir" value="/home/nmon"/>   <!—liunx中nmon路径-->
 <property name="nmon_cmd"  value="./nmon -f -t -r –name(可以修改) -s 5  -c 216 -F "/>   <!—nmon位置确定是否可以运行-->
 <property name="nmon_filename"  value="20170911_300vu_"/>   <!--结果命令规则-->
 <property name="nmon_filename_30"  value="${nmon_filename}30.nmon"/>
 <property name="nmon_filename_29"  value="${nmon_filename}29.nmon"/>
 <property name="nmon_filename_88" value="${nmon_filename}88.nmon"/>
 <property name="resultDir"  value="E:/syswin/nmon_report"/>    <!--保存结果-->
 <target  name="main"> 
 </target>

 <target name="run-nmon">   <!—运行方式-->
 <sshexec host="${app30}"  username="${user}" password="${passwd}"  trust="true" command="cd ${targetDir}; ${nmon_cmd} ${nmon_filename_30}"  />
 <sshexec host="${app29}"  username="${user}" password="${passwd}"  trust="true" command="cd ${targetDir}; ${nmon_cmd} ${nmon_filename_29}"  />
 <sshexec host="${DB88}"   username="${user}" password="${passwd}"  trust="true" command="cd ${targetDir}; ${nmon_cmd} ${nmon_filename_88}"  />  
 </target>

 <target name="copy-file">   <!—拷贝方式-->
  <scp  file="${user}:${passwd}@${app30}:${targetDir}/${nmon_filename_30}"  todir="${resultDir}"   trust="true"/>
  <scp  file="${user}:${passwd}@${app29}:${targetDir}/${nmon_filename_29}"  todir="${resultDir}"   trust="true"/>
  <scp  file="${user}:${passwd}@${DB88}:${targetDir}/${nmon_filename_88}"  todir="${resultDir}"   trust="true"/>
 </target>

 <target name="clean" >  <!—清除方式-->
   <sshexec host="${app30}"  username="${user}" password="${passwd}"  trust="true" command="rm  ${targetDir}/${nmon_filename_30}" />
   <sshexec host="${app29}"  username="${user}" password="${passwd}"  trust="true" command="rm  ${targetDir}/${nmon_filename_29}" />  
   <sshexec host="${DB88}"   username="${user}" password="${passwd}"  trust="true" command="rm  ${targetDir}/${nmon_filename_88}" />   
 </target>
</project>

Enter the build.xmlfile directory:

Insert picture description here


use the command to start:

ant run-nmon
Insert picture description here


Copy the nmon file generated by the server to the local machine:

ant copy-file
Insert picture description here


Clear remote nmon files:

ant clean
Insert picture description here


Simple way to open:

 nmon analyser for office_64.xls 

Suggest:

In general, when nmon is running, the scene will be started 15 to 30 seconds earlier, which is convenient for analysis and report writing.

Four, summary

In this way, several to dozens of servers can be enabled only after the machine is configured, which can save a lot of operation time, but there are still limitations. If you are interested, you can use Pyhon or Java multi-threaded programming to achieve.