Script to monitor values in Java melody

379 views
Skip to first unread message

tharu...@gmail.com

unread,
Jun 20, 2017, 2:43:59 AM6/20/17
to javamelody
Hi all,

Can someone please help me in writing a groovy script that can monitor for values in RED in mean time (ms) and mean cpu time (ms)  request columns ?

 Couldn't find the script at the below link.



Thanks!!


evernat

unread,
Jun 21, 2017, 9:29:58 AM6/21/17
to javamelody
Hi,

I have added a script example to display those requests in particular.
See https://github.com/javamelody/javamelody/wiki/ScriptsAndAlerts#display-requests-having-mean-time-greater-than-severe-threshold

bye,
Emeric

tharuni kota

unread,
Jun 22, 2017, 4:51:58 PM6/22/17
to javam...@googlegroups.com
Thanks a lot for your response.  I created a Jenkins jobs and ran the groovy script above. Below is the error log. I am using the Jenkins monitoring plugin ( version 1.65.1) 

FATAL: tried to access class net.bull.javamelody.Counter from class Script1

java.lang.IllegalAccessError: tried to access class net.bull.javamelody.Counter from class Script1

        at Script1.run(Script1.groovy:7)

        at groovy.lang.GroovyShell.evaluate(GroovyShell.java:663)

        at groovy.lang.GroovyShell.evaluate(GroovyShell.java:650)

        at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:118)

        at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:74)

        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)

                at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)

        at hudson.model.Build$BuildExecution.build(Build.java:206)

        at hudson.model.Build$BuildExecution.doRun(Build.java:163)

        at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)

        at hudson.model.Run.execute(Run.java:1728)

        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)

        at hudson.model.ResourceController.execute(ResourceController.java:98)

        at hudson.model.Executor.run(Executor.java:405)

 


Thanks!!


--

---
You received this message because you are subscribed to the Google Groups "javamelody" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javamelody+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

evernat

unread,
Jun 23, 2017, 4:46:21 PM6/23/17
to javamelody
Hi,

Is it better with the following script?

import net.bull.javamelody.*;
import net.bull.javamelody.internal.model.*;

url = "http://myserver:8080/mywebapp/monitoring";
list = new RemoteCall(url).collectData();
for (object in list) {
   if (object.getClass().getSimpleName().equals("Counter")) {
      aggreg = new CounterRequestAggregation(object);
      if (aggreg.isTimesDisplayed()) {
         for (request in aggreg.getRequests()) {
            if (request.getMean() >= aggreg.getSevereThreshold() 
               || request.getCpuTimeMean() >= aggreg.getSevereThreshold()) {
                println(request.getName()
                   + " hits=" + request.getHits()
                   + " mean=" + request.getMean()
                   + " max=" + request.getMaximum()
                   + " stddev=" + request.getStandardDeviation()
                   + " cpuTimeMean=" + request.getCpuTimeMean()
                   + " systemErrorPercentage=" + request.getSystemErrorPercentage());
            }
         }
      }
   }
}

bye,
Emeric


Le jeudi 22 juin 2017 22:51:58 UTC+2, tharuni kota a écrit :
Thanks a lot for your response.  I created a Jenkins jobs and ran the groovy script above. Below is the error log. I am using the Jenkins monitoring plugin ( version 1.65.1) 

FATAL: tried to access class net.bull.javamelody.Counter from class Script1

java.lang.IllegalAccessError: tried to access class net.bull.javamelody.Counter from class Script1

        at Script1.run(Script1.groovy:7)

        at groovy.lang.GroovyShell.evaluate(GroovyShell.java:663)

        at groovy.lang.GroovyShell.evaluate(GroovyShell.java:650)

        at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:118)

        at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:74)

        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)

                at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)

        at hudson.model.Build$BuildExecution.build(Build.java:206)

        at hudson.model.Build$BuildExecution.doRun(Build.java:163)

        at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)

        at hudson.model.Run.execute(Run.java:1728)

        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)

        at hudson.model.ResourceController.execute(ResourceController.java:98)

        at hudson.model.Executor.run(Executor.java:405)

 


Thanks!!

tharuni kota

unread,
Jun 27, 2017, 1:21:23 PM6/27/17
to javam...@googlegroups.com
Thank you for our response. Attached is the jenkins job output from the script above. 






Jenkins_job_output.txt

evernat

unread,
Jun 27, 2017, 1:39:48 PM6/27/17
to javamelody
Good, and so it works !
Note that if you just want to have stats about http requests without the other stats in the output, you can add a test : if (object.getName().equals("http")) { ... }

And, I have not understood before your last mail that the app for which you want monitoring stats is apparently a Jenkins instance.
In that case, you may also be interested by monitoring scripts written specifically for Jenkins when using the Jenkins monitoring plugin. See here for those scripts:
https://wiki.jenkins.io/display/JENKINS/Monitoring+Scripts

bye,
Emeric

tharuni kota

unread,
Jul 5, 2017, 11:18:27 AM7/5/17
to javam...@googlegroups.com
Yes it does. Thanks for your response.

Bye,
Tharuni

Reply all
Reply to author
Forward
0 new messages