Monitoring resource use of executable started by Jenkins batch job

45 views
Skip to first unread message

paul...@annapmicro.com

unread,
Jun 8, 2017, 10:25:11 AM6/8/17
to Jenkins Users

Hello,

 

I am trying to find a way to view the physical memory usage of a command line application started by a build step in a Jenkins job on a Windows operating system while it is running.

 

I tried using the Monitoring and Disk Usage plug-ins, however, the closest I was able to do was to use Monitoring’s View OS Processes to view the virtual memory and process ID.  Neither of which allowed me to either see the physical memory use nor determine which build the running executable I was looking at was associated with.   The purpose of this is basically to have several parameterized jobs that run command line executables on the master with the ability to monitor and manually stop them remotely if necessary.  I could view the information by remotely logging into the computer the master is running on and using Windows Task Manager to view the running processes, but I am looking for a way that does it within the Jenkins web interface.

 

Basically the idea is when this type of job is run:

Step 1: Jenkins job takes a number of parameters and starts a build which runs an executable with the parameters given

Step 2: While the executable is running a user logs in to Jenkins and uses <something> to view how much physical memory the job/executable is currently using

Step 3: If too much memory is being used the user cancels the build, else the user does nothing and it runs to completion


I have not found anything that can act as the <something> in step 2.  Is there some plugin to do physical memory monitoring of everything on the computer that the master was setup on or a way to setup a Jenkins job to monitor the executables it started for their resource use?   

jer...@bodycad.com

unread,
Jun 8, 2017, 2:14:04 PM6/8/17
to Jenkins Users
You may want to take a look at Job Object and cook this limitation right inside the application you run into the batch script

https://msdn.microsoft.com/en-us/library/windows/desktop/ms684161(v=vs.85).aspx

example C++
#include <Windows.h>
#define BYTES_PER_GIGABYTE ((size_t)1073741824);
...

JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
info.ProcessMemoryLimit = mem_limit_gb * BYTES_PER_GIGABYTE;
...


This way you application will end right away if it reach that limits. It's always a good idea to make this code for any platform not just Windows

For Linux you can go ulimit way:



Paul West

unread,
Jun 8, 2017, 6:28:58 PM6/8/17
to Jenkins Users
I am unable to change the applications that will be run, so there is no way for me to add limitations to them, nor will the people who can modify them do so for me, unfortunately.  Thank you for the suggestion, though, I had not considered adding a limitation to end the application automatically instead of manually, and will need to look at if it is possible to do within a batch script, and if so if it is an allowed option for me.
Reply all
Reply to author
Forward
0 new messages