#!/bin/probevue /* movinggraph.e - Print a rolling graph of the occourences of some event - Code can be used as is, but is really about modifying to your needs. The things that can be modified are: * modulus - graph scale * interval - update frequency * probe specification - event you wish to watch - Set the modulus value to control the scale of the graph. Set it to 1 for a system that does not fire the watched item frequently. Set it to 10 to reduce the graph by an order of magnitude, etc... - Set the interval in the interval probe to control the update frequency. The current interval is (once) per-minute. That is a rather slow update. Note: the graph updates as the events happen the interval is when we assign a value to the graph bar and begin drawing a new graph bar. - The modulus and the interval are really factors of the numbers of watched events on the system. Set them as appropriate. The default values here are set for an idle system. /* int extotal; int modulus; int hprintd; @@BEGIN { /* Initialize all our variables */ extotal = 0; modulus = 1; /* <---- Modify here to change graph scale. */ hprintd = 0; printf(" ["); /* Leave room for our number */ } /* This paticular event is exec()s system-wide. It is possible to set this to any syscall or uft probe. You only need to change the probe point specification to the desired event. +--- Modify here to change the event to watch | V */ @@syscall:*:execve:entry { extotal++; if ( extotal % modulus == 0 ) { /* The conditionals here prevent us overflowing the graph bars */ if ( hprintd < 60 ) printf("#"); if ( hprintd == 60 ) printf("+"); hprintd++; } } /* Set the interval here. Remember that this value must be divisible by 100, is in ms, and a second is 1000 ms. +----- Modify here to change the interval of the | graph update. V */ @@interval:*:clock:60000 { /* Return to start of line, print the total, then set up the next line for a new graph bar. */ printf("\r%14d\n [", extotal); extotal = 0; hprintd = 0; } /* Print a carriage return when we exit so we get our command prompt in the expected location. */ @@END { printf("\n"); }