Using jstat to report custom JVM metric sets

I've always been missing possibility to configure custom headers in JStat. Of course there are a lot of predefined data sets, but it'll be nicer if we could create our own data set. And as you probably already devised I'm writing this post because such functionality is of course available :) Unfortunately I haven't found it in any documentation so now I'll try to fill this gap.

First thing we have to do is to provide custom descriptor with possible JStat options. This descriptor is just a text file containing something we'll call "jstat specification language". To make this custom file available to JStat we should place it in the following path: $HOME/.jvmstat/jstat_options
If you want to view the bundled options please refer to file in OpenJDK repository.

The specification language is pretty similar to json files, and it contains the group of option elements. Each option should be threaten as a set of columns that can be shown in single jstat execution. Just to name some of the predefined options: gcnew, gccause or printcompilation.

Each option element consists of several column segments. I think it's quite obvious what column means :) And whats the most important in this descriptor is just a column specification.

Each column must contain at least two nodes: header and data. Header is used to describe the column and can be aligned using special char ^ which I'll call "the grip". Grip means that it sticks the header with particular side of the column, so:
  • ^Name will be aligned to the left,
  • ^Name^ will be centered,
  • Name^ will be aligned to the right.
The next important node is the data column. It uses PerfCounter metrics and is able to make some basic arithmetic operations - like add, minus, divide and multiply as well as use parenthesis to group operations . You can also group If you want to see all metrics that are available via this mechanism just can invoke
$jcmd <PID> PerfCounter.print
and see the output values.

Sample minimum file content can be like that:
option customgc {
  column {
    header "Tenuring"
    data sun.gc.policy.tenuringThreshold
  }
}
When we'll invoke it using
$jstat -customgc <PID> 1s 3
we'll see something like:
Tenuring
6
4
5

We can also use the operations to show for example joint young generation usage:
option customgc {
  column {
    header "YoungC"
    data sun.gc.generation.0.space.0.used + sun.gc.generation.0.space.1.used + sun.gc.generation.0.space.2.used
  }
}

There are also four additional columns that are used to setup layout for our column.
  1. First is for alignments setting. We can choose if we want to align our data to left, center or right by setting align element to one of above values. 
  2. In the case of number metrics we can specify string used as DecimalFormat input by entering it in the format node.
  3. We're also able to specify the size of the column by adding width element with particular length.
  4. Last but not least is a scaling functionality. Because most of the metrics contain just raw output from JVM we need to transform it a little bit to make if useful for human eye. This can be done with the use of scale attribute set to one of the below values (token column).
    tokenfactordesc
    raw1no scaling
    percent1/100convert to percentage
    K1024kilo
    M1024*1024mega
    G1024*1024*1024giga
    n10^-9nano
    u10^-6micro
    m10^-3milli
    us10^-6microseconds
    ms10^-3milliseconds
    s1seconds
    min1/60minutes
    h1/3600hour

Now let's see the polished example that will show how we can use additional properties:
option customgc {
  column {
    header "YoungC^"
    data sun.gc.generation.0.space.0.used + sun.gc.generation.0.space.1.used + sun.gc.generation.0.space.2.used
    align right
    scale M
    width 7
    format "0.0"
  }
  column {
    header "OldC^"
    data sun.gc.generation.1.space.0.used
    align right
    scale M
    width 7
    format "0.0"
  }
}
Which produces
 YoungC    OldC
   67.7   161.0
   37.8   165.4
   92.2   182.8

End of topic :) Good luck!

Comments

Unknown said…
If you are looking for getting the best data scientist than this activewizards.com/ is available for you to get you hire the best data scientist, these data scientists are highly professional and skilled and they can easily solve your all data related problems in a few days or hour it depends on the data size and complexity.
priya said…
Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
Data Science training in chennai
Data Science training in OMR
Data Science training in chennai
Data Science Training in Chennai
Data Science training in Chennai
Data science training in bangalore
Aditi Ray said…
Thank you so much for sharing this article.
check out the best furniture sale
deepika said…
thanks for this post it really helped me alot
block chain training in bangalore
Tech Guy said…
Nice Blog.
For the Best Python training in Bangalore, Visit:
Python training in Bangalore
Unknown said…
This blog are more informative contents step by step. I here by attached mt site would you see this blog.

7 tips to start a career in digital marketing

“Digital marketing is the marketing of product or service using digital technologies, mainly on the Internet, but also including mobile phones, display advertising, and any other digital medium”. This is the definition that you would get when you search for the term “Digital marketing” in google. Let’s give out a simpler explanation by saying, “the form of marketing, using the internet and technologies like phones, computer etc”.

we have offered to the advanced syllabus course digital marketing for available join now

more details click the link now.

https://www.webdschool.com/digital-marketing-course-in-chennai.html
Unknown said…
Amazing blog useful information.

Web designing trends in 2020

When we look into the trends, everything which is ruling today’s world was once a start up and slowly begun getting into. But Now they have literally transformed our lives on a tremendous note. To name a few, Facebook, Whats App, Twitter can be a promising proof for such a transformation and have a true impact on the digital world.

we have offered to the advanced syllabus course web design and development for available join now.

more details click the link now.

https://www.webdschool.com/web-development-course-in-chennai.html
offpageseo70 said…

Nice blog,I understood the topic very clearly,And want to study more like this.
Data Scientist Course
nikhil reddy said…
I found a lot of information here to create this actually best for all newbie here. Thank you for this information.
Artificial Intelligence Training In Hyderabad

Artificial Intelligence Course In Hyderabad
lionelmessi said…
Hi, Thanks for sharing wonderful stuff...

For More:

AI Training In Hyderabad
lionelmessi said…
Hi, Thanks for sharing nice articles...

DevOps Training In Hyderabad
lionelmessi said…
Hi, Thanks for sharing nice articles...

AI Training In Hyderabad
I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.

data science course
reshma said…
thanks for sharing nice information....
more : https://www.kellytechno.com/Hyderabad/Course/AI-Training-In-Hyderabad
nikhil reddy said…
Hi, Thanks for sharing wonderful articles...

Machine Learning Training In Hyderabad
Great writing! You have a flair for informational writing. Your content has impressed me beyond words. I have a lot of admiration for your writing. Thank you for all your valuable input on this topic.
SAP training in Mumbai
Best SAP training in Mumbai
SAP training institute Mumbai
I'm not one of those readers that comments on articles often, but yours really compelled me. There's a lot of interesting content in this article that is interesting and bold.
SAP training in Kolkata
Best SAP training in Kolkata
SAP training institute in Kolkata
reshma said…
thanks for sharing nice information.....
python Training in Hyderabad
Anebellyliza said…
Thank you so much for this incredible guide. This has given me so much information
AI Training in Hyderabad
Anonymous said…
Hey, i liked reading your article. You may go through few of my creative works here
Marhabapilates
Poppriceguide
nikhil reddy said…
Hi, Thanks for sharing excellent content...

Data Science Training in Hyderabad
jony blaze said…
Thanks for sharing nice information....
AI Training in Hyderabad
priyash said…
Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
Correlation vs Covariance
Simple linear regression
data science interview questions
jony blaze said…
Thanks for sharing nice information....
AI Training in Hyderabad
EXCELR said…
Thanks for sharing nice information data science training Hyderabad
Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
blockchain online training
best blockchain online training
top blockchain online training
nikhil reddy said…
This is the information that ive been looking for. Great insights & you have explained it really well. Thank you & looking forward for more of such valuable updates.
Artificial Intelligence Training In Hyderabad

Artificial Intelligence Course In Hyderabad
Morgan said…
There has always been a need to record the data made by people which will help in predicting the future and also in studying the evolution of people's way of living. data science course in hyderabad
Priya Rathod said…
Highly informative article. This site has lots of information and it is useful for us. Thanks for sharing your views.
Data Science Training in Hyderabad
Data Science Course in Hyderabad
hrithiksai said…
Very nice blogs!!! i have to learning for lot of information for this sites…Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing, data sciecne course in hyderabad
rstrainings said…
I am really happy to say it’s an interesting post to read . I learn new information from your article , you are doing a great job . Keep it up

Devops Training in Hyderabad

Hadoop Training in Hyderabad

Python Training in Hyderabad
William Jessie said…
This article contains a lot of valuable info. I am amazed by the quality of the info and also it is a beneficial article for us, Thanks for share it.drone
Terrific post thoroughly enjoyed reading the blog and more over found to be the tremendous one. In fact, educating the participants with it's amazing content. Hope you share the similar content consecutively.

360DigiTMG Data Analytics Course
I want to leave a little comment to support and wish you the best of luck.we wish the best best of luck in all your blogging endeavors.
data science course bangalore

rstrainings said…

I am really happy to say it’s an interesting post to read . I learn new information from your article , you are doing a great job . Keep it up

Devops Training in Hyderabad

Hadoop Training in Hyderabad

Python Training in Hyderabad

Tableau Training in Hyderabad

Selenium Training in Hyderabad
Truly mind blowing blog went amazed with the subject they have developed the content. These kind of posts really helpful to gain the knowledge of unknown things which surely triggers to motivate and learn the new innovative contents. Hope you deliver the similar successive contents forthcoming as well.

data science in bangalore
Maneesha said…
We are a group of volunteers and starting a new scheme in our community. Your website provided us with valuable information to work on. You have done a formidable job and our entire community will be grateful to you.
data scientist training in hyderabad
Maneesha said…
This was not just great in fact this was really perfect your talent in writing was great.
data scientist training and placement
Maneesha said…
wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. I’ve bookmark your site and also add rss. keep us updated.
data scientist course in hyderabad
Impressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.

data science certification in bangalore
data science said…
I was just examining through the web looking for certain information and ran over your blog.It shows how well you understand this subject. Bookmarked this page, will return for extra. data science course in vadodara

Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one.
data scientist training and placement

lionelmessi said…
Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.

DevOps Training in Hyderabad
This data is magnificent. I am impressed with your writing style and how properly you define this topic. After studying your post, my understanding has improved substantially.

Best Online Oracle Training Institute in Delhi, NCR
Certified Online Python Training Institute in Delhi, NCR
Such a great articles in my carrier, It's wonderful commands like easiest understand words of knowledge in information's.

Core to Advanced Digital Marketing Training Course in Delhi, India
Learn Complete Advanced Excel Training Course in Delhi, NCR
data science said…
I was basically inspecting through the web filtering for certain data and ran over your blog. I am flabbergasted by the data that you have on this blog. It shows how well you welcome this subject. Bookmarked this page, will return for extra. data science course in jaipur
Highly appreciable regarding the uniqueness of the content. This perhaps makes the readers feels excited to get stick to the subject. Certainly, the learners would thank the blogger to come up with the innovative content which keeps the readers to be up to date to stand by the competition. Once again nice blog keep it up and keep sharing the content as always.

data science course in faridabad
Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. A debt of gratitude is in order for sharing. data scientist course in delhi
dataanalytics said…
Took me time to understand all of the comments, but I seriously enjoyed the write-up. It proved being really helpful to me and Im positive to all of the commenters right here! Its constantly nice when you can not only be informed, but also entertained! I am certain you had enjoyable writing this write-up.
data scientist training and placement
dataanalytics said…
I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
data scientist training and placement in hyderabad

Thanks for bringing such an innovative content which truly attracts the readers towards you. Certainly, your blog competes with your co-bloggers to come up with the newly updated info. Finally, kudos to your efforts.

Data Science Course in Varanasi
dataanalytics said…
Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing.
data scientist training and placement in hyderabad

dataanalytics said…
I will really appreciate the writer's choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more.
data scientist course in hyderabad
aaronssd said…
The information you've provided is useful because it provides a wealth of knowledge that will be highly beneficial to me. Thank you for sharing that. Keep up the good work. Best blockchain research journal
Maneesha said…
This is my first time visiting here. I found so much entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the good work. I have been meaning to write something like this on my website and you have given me an idea.
data scientist training in hyderabad
Maneesha said…
Hello! I just wish to give an enormous thumbs up for the nice info you've got right here on this post. I will probably be coming back to your weblog for more soon!
data scientist training in hyderabad
Maneesha said…
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.
data scientist course in hyderabad
Stupendous blog huge applause to the blogger and hoping you to come up with such an extraordinary content in future. Surely, this post will inspire many aspirants who are very keen in gaining the knowledge. Expecting many more contents with lot more curiosity further.

Data Science Certification in Bhilai
Extraordinary blog went amazed with the content that they have developed in a very descriptive manner. This type of content surely ensures the participants to explore themselves. Hope you deliver the same near the future as well. Gratitude to the blogger for the efforts.

Data Science Training
Maneesha said…
Your content is nothing short of brilliant in many ways. I think this is engaging and eye-opening material. Thank you so much for caring about your content and your readers.
data scientist course in hyderabad
Maneesha said…
I’ve read some good stuff here. Definitely worth bookmarking for revisiting. I surprise how much effort you put to create such a great informative website.
data scientist training and placement

Arnold DK said…
Nice Post , thank you so much for sharing the informative article share with us, your blog was creative writing ability has inspired me. whatsapp mod

Popular posts from this blog

Understanding Spring Web Initialization

Spring integration testing with Spock