Giter VIP home page Giter VIP logo

Comments (3)

jezhumble avatar jezhumble commented on August 15, 2024

Thanks for the bug report.

The quickest way to get this in would be to fork, write a test, write
updated code that makes the test pass, and request a merge.

Jez.

On 22 August 2011 18:19, ebwweb <
[email protected]>wrote:

The parse method throws NumberFormatExceptions if the process name in the
/proc//stat file has spaces (for example the "MpxTestDaemon " (with 2
spaces at the end) process on EMC/StorNext metadata controllers).

Recommend changing the parse method to:

   public ProcessInfo parse() {
       int openParen = stat.indexOf("(");
       int closeParen = stat.lastIndexOf(")");

       //Start splitting after close of proc name
       String[] statElements = stat.substring(closeParen + 2).split(" ");
       String pidStr = stat.substring(0,openParen - 1);

       return new ProcessInfo(Integer.parseInt(pidStr),
               Integer.parseInt(statElements[1]),
               trim(cmdline), getFirstMatch(STATUS_NAME_MATCHER, status),
               (String) uids.get(getFirstMatch(STATUS_UID_MATCHER,
status)),
               Long.parseLong(statElements[11]) * (1000 / userHz),
               Long.parseLong(statElements[12]) * (1000 / userHz),
               Long.parseLong(getFirstMatch(STATUS_VM_RSS_MATCHER, status))
* 1024,
               Long.parseLong(getFirstMatch(STATUS_VM_SIZE_MATCHER,
status)) * 1024);
   }

Reply to this email directly or view it on GitHub:
#10

Jez Humble
Co-author, Continuous Delivery http://continuousdelivery.com/
http://continuousdelivery.com/
http://jezhumble.net/

from javasysmon.

jsankey avatar jsankey commented on August 15, 2024

Having recently adopted javasysmon, we had a customer report this issue. I checked out the Linux source for parsing stat entries and they do it essentially as ebwweb has outlined above - by searching from both ends of the string to find the parens around the process name. This is required as the name can include spaces, parens, numbers, pretty much anything. I've adapted ebwweb's solution into a larger patch which includes tests and handling of various potentially unexpected conditions. The aim is for things to be as lenient as possible (i.e. only require the fields we are trying to use) and to soldier on in the face of problem entries (i.e. skip difficult processes and continue gathering the rest).

from javasysmon.

jezhumble avatar jezhumble commented on August 15, 2024

Thanks for the patch Jason! I merged it in.

from javasysmon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.