Application Counters in Linux? (And Osx)

Daemon monitoring / logging on linux (application counters)

statsD is a good place to start to collect metrics.

statsD will let you send counters directly from your application without incurring any significant overhead. Your code generates counters as it executes and you need not keep track of it in your code.

If you want a package that has all-in-one (but no persistence), you can use pup

If you need persistence and graphing you may want to look at graphite.

graphite will connect to statsd and let your graph any of the counters you generate. It's fairly lightweight and the combination is arguable easier to deploy and maintain than something like Nagios (which is much closer to cacti in terms of deployment and learning curve).

If you want something more integrated with persistence and an API, there a number of services to do the graphing for you. I've limited myself to open-source software here.

Concept of Performance Counters in Linux/Unix

Take a look at:

  • OProfile
  • perfctr
  • perfmon2

Finding an installed application on Mac/Linux

Generally, on UNIX systems you can expect all programs to reside in $PATH instead of being distributed in a hodge-podge collection of stupidly named and partially localized directories. So, essentially you don't need to find any dependency path - you just call the other "app" (program) via execvp, and the libc takes care of walking through the entries of $PATH and finding the executable.

In the classic UNIX model, you don't check anything in an installer, but just check at runtime whether an executable is available (with which, for example) or not.

Is there anyway to read performance counters on OS X Mountain Lion?

Yes. It's there, but difficult to find and clumsy to use (ver.4.5).

  • Launch Instruments.
  • You are greeted by the Wizard
  • Choose "Blank" template for OS X
  • Press cmd+L to display the Library
  • Add "Counters" instrument to your Instruments document
  • Press cmd+shf+P -- you are presented with the PM Events floating window.
  • Let's evaluate "Divide Operations executed" -- Add "Divide Operations executed" to the PM Events window's search field.
  • Now set the "State" of "Divide Operations executed" to "Visible"
  • Now back to the main document window, press cmd+I to display the info popover of the "Counters" instrument.
  • Press the + button
  • Set the new Counter's event to "Divide Operations executed"
  • Begin sampling...
  • End sampling...

You will see the results in Instruments' table columns. Of course, there are many events you could record -- So find the L1 cache events you are interested in and add them instead of divides.

Also be prepared for system freezes (one happened while writing this up).



Related Topics



Leave a reply



Submit