Highlighted
Super Contributor.
Super Contributor.
656 views

Calculated Metrics and conditionals

Jump to solution

Hi, I'm trying to use the calculated metrics to get the avalilable tread on a tomcat.
I have configured the JMX monitor and I got the counters.

What I would like to do is something like this:

 

if (<<Catalina/ThreadPool/"http-nio-8080"/maxThreads>> == '-1') {
	availableThreads = 200 - (<<Catalina/ThreadPool/"http-nio-8080"/currentThreadsBusy>> + <<Catalina/ThreadPool/"http-nio-8080"/currentThreadCount>>);
} else {
	availableThreads = <<Catalina/ThreadPool/"http-nio-8080"/maxThreads>> - (<<Catalina/ThreadPool/"http-nio-8080"/currentThreadsBusy>> + <<Catalina/ThreadPool/"http-nio-8080"/currentThreadCount>>);
}

Basically if the maxThread == -1 then use 200 as maxThreads by default otherwise use the maxThreads provided and obtaine the availableThreads at the moment.

I tried to use javaScript to set up the expression but it seems its not working.

Any idea?

Thanks

 

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Super Contributor.
Super Contributor.

There is a way to use a condition on the expression.

<condtion> ? <then result> :  <else result>

In the tomcat request this is the expression.

<<Catalina/ThreadPool/"http-nio-8080"/maxThreads>> == -1 ? 200 - (<<Catalina/ThreadPool/"http-nio-8080"/currentThreadsBusy>> + <<Catalina/ThreadPool/"http-nio-8080"/currentThreadCount>>) : <<Catalina/ThreadPool/"http-nio-8080"/maxThreads>> - (<<Catalina/ThreadPool/"http-nio-8080"/currentThreadsBusy>> + <<Catalina/ThreadPool/"http-nio-8080"/currentThreadCount>>

View solution in original post

0 Likes
2 Replies
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Hello Daniel,

Actually conditionals are not available in calculated metrics. What is the expression you're using in the calculated metrics field?

Regards,

Allan Delgado Calderon
Customer Support Engineer

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
0 Likes
Highlighted
Super Contributor.
Super Contributor.

There is a way to use a condition on the expression.

<condtion> ? <then result> :  <else result>

In the tomcat request this is the expression.

<<Catalina/ThreadPool/"http-nio-8080"/maxThreads>> == -1 ? 200 - (<<Catalina/ThreadPool/"http-nio-8080"/currentThreadsBusy>> + <<Catalina/ThreadPool/"http-nio-8080"/currentThreadCount>>) : <<Catalina/ThreadPool/"http-nio-8080"/maxThreads>> - (<<Catalina/ThreadPool/"http-nio-8080"/currentThreadsBusy>> + <<Catalina/ThreadPool/"http-nio-8080"/currentThreadCount>>

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.