How to add custom monitor dataFrom nGrinder 3.1.3, we provided support for the custom monitor data for target monitoring. It can be used if you want to check some monitor data of target server in the test report. All you need to do, is to use any tools you like to generate the monitor data with some internal time. (The best practice is to set the internal time as same as the sampling interval of nGrinder test.) And the data should be saved in: ${ngrinder_agent}/monitor/custom.data And the content of this file should be the several values of monitoring, seporated with “,”. And it only contains the current value with only one line. As below: 315630613,1123285602,1106612131 And then, you need to make sure the file is being updated during the test running. nGrinder monitor will get its content and send to nGrinder controller. After the test finished, you can see the target monitoring chart page in test report: Be noticed that the chart name is “CUSTOM MONITOR DATA 1”, “CUSTOM MONITOR DATA 2” .., till “CUSTOM MONITOR DATA 5”. And there will be at most 5 custom data. You can save the meaning of this fileds as the test comment.
So, the next, we need to use some tool to get the monitor data and save into that file with some interval. To do that, the first thing on Linux you may think about is “cron”. We can create a script and run it with “cron”. But with “cron”, the minimal interval is minute. But for nGrinder monitoring, at the most of time the interval is one second. So in this guide, I will use java to get the java VM running information with JMX. If the target server is a java application like tomcat, we can use the way in this guide to get the VM running information of tomcat, and display the data in chart in the final report. As I said above, I will use JMX to get the VM data. But in the normal we will not enable the JMX server of tomcat. So we will use attach API to attach to the target process, and enable the “management-agent”, and then we can connect with JMX to the target process. You can find the VMMonitor.java from gist. Be aware about the code that, in java VM, for different java version and different GC setting, the GC names will be different. So in this code, I get the GC names of current Java VM, and using these names to get target process GC information with JMX. So the Java environment you use to run this code should be same as that you run the target tomcat. And the VM option like “-server” or GC setting should also be same. Otherwise, you can not get the GC names of target tomcat process. And below, we will use this code to get the GC information of target process and save into custom.data file. The new code is as below:
Some comments about the code are: a) We need to pass the target process ID as arguments to run. b) This code should be run under same java environment and VM option with the target process. Otherwise, the attaching will properly fail. And if the target tomcat process is running with “-server” option, also be aware to set “-server” option to run this java code. Becasue under different java version and setting, the GC names will be different, I founded some names and their types(monior GC or full). They are not complete and maybe not very correct. If you use IBM JVM, you should modify the code by yourself. c) The custom values format is “minorGCCount,minorGCTime,fullGCCount,fullGCTime”. d) This java code should be run in “${ngrinder_agent}/monitor/” directory. Becasue in the code, it will create custom.data file in current directory. e) To compile the code, it needs “tools.jar” of JDK. You need to compile it like this:
Then you should see the output in console as below:
And in custom.data file, the content is:
Then, create a new test on nGrinder and set the target host properly. You can see the chart in test report: (Becasue the GC count is not changed very much, so we can not see much difference from the chart.)
In this way, you can add any kind of custom monitor data and check it from test report. |
Free forum by Nabble | Edit this page |