PerfPMR Part 4: Adding Custom Scripts
This is the final installment in a four-part series on using PerfPMR. Read part one here, part two here and part three here.
In my concluding article on PerfPMR, I’ll introduce you to one of the simplest, yet most useful customizations you can make to the utility.
If you list the scripts that PerfPMR placed in your installation directory, you’ll see one called perfxtra.sh. Viewing this file, you’ll see it looks like a script that specifies a couple trace commands, one a form of the tprof command and the other for filemon. Both commands are commented out. The rest of the script declares things like timings and data locations.
Ignore everything you see in the perfxtra.sh file. These stanzas are examples of perfxtra.sh customizations. They show you one way to add your own commands to PerfPMR; I’ll show you another. What we’re after is a way to execute our own scripts during a PerfPMR run, and do it simply.
The only thing you need to know when adding your own commands to PerfPMR is how to concatenate them. The nice thing about perfxtra.sh is that you can get as fancy – or keep it as simple – as you’d like to get the job done, so the best way to show you how to do this is by example.
CURT and SPLAT
As you know by now, PerfPMR does a whole lot of stuff. It runs many of the stats commands, along with different forms of traces and configuration listings. But there are some important things that PerfPMR doesn't do. To my mind, two critical performance diagnostic routines that aren't invoked during a PerfPMR run are a CURT (the CPU Usage Reporting Tool) and a SPLAT (the Simple Performance Lock Analysis Tool). I imagine at some point the PerfPMR developers had to draw a line regarding their feature set to prevent application bloat. If this is the reason these two reports were left out of PerfPMR, I can see the logic behind it. However, I don't know anyone who does a performance deep dive without CURTs and SPLATs, so let’s see how we can get these two back into the mix.
First, we'll only work with the most basic Korn shell syntax. My best advice is to keep your PerfPMR customizations – whether they’re in the perfxtra.sh file or elsewhere – as simple as possible. That way, if something goes wrong, you’ll be much more likely to track down the cause. Next, any shell script customizations you do add to perfxtra.sh will go to the bottom of that file. Don’t add them in the existing text, and don’t delete the existing text – you’ll mess up your PerfPMR run if you do. Lastly, and this is important, always declare the full path to any command you add in the perfxtra.sh file in shell syntax. So as I said, we'll tell PerfPMR to generate a CURT and a SPLAT for this example. Editing your perfxtra.sh file, add this line to the bottom of the file (you don’t need a newline character; remember, keep it simple):
/usr/bin/gensyms > gensyms.out ;
/usr/bin/curt -i trace.raw -n gensyms.out -o curt.all -Ptse ;
/usr/bin/splat -i trace.raw.lock -n gensyms.out -da -sa -o splat.all
Like what you just read? To receive technical tips and articles directly in your inbox twice per month, sign up for the EXTRA e-newsletter here.
comments powered by