Mahesh Wabale
3 min readFeb 9, 2020

Monitoring dashboard for Jenkins memory usage analysis.

This article will give details about installing monitoring plugin for monitoring Jenkins health and use cases.

pre-requisites :

You should have basic knowledge about Jenkins , also have some basic idea about java memory management before installing this plugin for monitoring your jenkins setup .

Why to install monitoring dashboard for Production Jenkins setup?

To have live debugging details about what happens with Jenkins setup internally . It will help to debug Jenkins performance issues related to :

  • Java config .
  • Memory param .
  • Slowness .
  • CPU consumption .
  • To check deadlock threads .
  • User can download heap dump from ui .
  • User can download thread dump of application without impacting running setup .
  • Active and logged-in users details .

Here are the steps to integrate monitoring dashboard:

  • Install monitoring plugin .
  • Manage Jenkins
  • Manage Plugins
  • Search Monitoring plugin
  • Install monitoring plugin

Use case :

With help of monitoring plugin , you can see below dashboard which is showing details of RAM , CPU, Heap memory usage , active user sessions , thread details , error logs which will help us to have run time or live debugging information for entire setup .

Monitoring groovy scripts Examples :

you can execute groovy scripts in Jenkins UI (http://localhost:8080/script)

1)Execute GC manually :

import net.bull.javamelody.*;

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

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

before = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();

System.gc();

after = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();

println I18N.getFormattedString("ramasse_miette_execute", Math.round((before - after) / 1024));

2.Display some memory data

import net.bull.javamelody.*;

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

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

memory = new MemoryInformations();

println "\nused memory:\n " + Math.round(memory.usedMemory / 1024 / 1024) + " Mb";

println "\nmax memory:\n " + Math.round(memory.maxMemory / 1024 / 1024) + " Mb";

println "\nused perm gen:\n " + Math.round(memory.usedPermGen / 1024 / 1024) + " Mb";

println "\nmax perm gen:\n " + Math.round(memory.maxPermGen / 1024 / 1024) + " Mb";

println "\nused non heap:\n " + Math.round(memory.usedNonHeapMemory / 1024 / 1024) + " Mb";

println "\nused physical memory:\n " + Math.round(memory.usedPhysicalMemorySize / 1024 / 1024) + " Mb";

println "\nused swap space:\n " + Math.round(memory.usedSwapSpaceSize / 1024 / 1024) + " Mb";

You can also configure job and schedule cron to monitor jenkins setup by adding groovy script in job , configure mail , slack alerting based on threshold config and failure scenarios .

Check below reference URL for more details for other available scripts supported by monitoring plugin , you do modifications as per your requirement and use this scripts for actively monitoring your setup .

Help URL :

https://wiki.jenkins.io/display/JENKINS/Monitoring+Scripts

Add comment it this tutorial helpful to you .

Mahesh Wabale

Technology enthusiast with interest in DevOps, CICD , Microservices architecture [+91 9158093734]