// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// Examples from the pmie(1) man page
//

delta = 1 sec;		// force evaluation once per second

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// If total syscall rate exceeds 10000/second times number of CPUs, then
// display an alarm notifier
//
kernel.all.syscall > 10 Kcount/sec * hinv.ncpu
    -> alarm "high syscall rate";

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
all_sample
    (kernel.all.syscall @0..4 > 10 Kcount/sec * hinv.ncpu)
	-> shell 5 min "xwsh -e 'top'";


// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
delta = 5 sec;		// force evaluation once every 5 seconds from here on

// If for any disk, for all 4 samples (20 seconds), the disk is performing
// more than 40 I/Os per second, then print a message to standard output and
// then launch dkvis(1)
//
some_inst all_sample
    disk.dev.total @0..3 > 40 count/sec
	-> print "disk busy for 20 sec" &
	   shell 5 min "dkvis";

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// Refine the preceding rule to apply only between the hours of 9am and 5pm,
// and to require that just 3 of the four samples exceed the threshold
//
$hour >= 9 && $hour <= 17 && some_inst 75 %_sample
    disk.dev.total @0..3 > 40 count/sec
	-> print "disk busy for 20 sec" &
	   shell 5 min "dkvis";

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// Refine the preceding rule further to print the host name and disk name
// for which the threshold is exceeded
//
$hour >= 9 && $hour <= 17 && some_inst 75 %_sample
    disk.dev.total @0..3 > 40 count/sec
	-> print "disk %i on host %h busy for 20 sec";

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// Macro for use ...
//
bc = "buffer_cache";
// Using the above macro; If the buffer cache is in use (more than 50 read
// requests) with hit ratio less than 90%, then popup an alarm
//
$bc.getblks > 50 && $bc.getfound / $bc.getblks < 0.9
    -> alarm "poor buffer cache hit rate";

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
delta = 10 mins;	// force evaluation once every 10 minutes from here on

// If either the / or the /usr filesystem is more than 95% full, display
// an alarm popup, but not if it has already been displayed during the last
// 24 hours
//
filesys.free #'/dev/root' / filesys.capacity #'/dev/root' < 0.05
    -> alarm 24 hour "root filesystem (almost) full";
filesys.free #'/dev/usr' / filesys.capacity #'/dev/usr' < 0.05
    -> alarm 24 hour "/usr filesystem (almost) full";

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// The following rule requires a machine that supports the PCP environment
// metrics. If the machine environment temperature rises more than 2
// degrees over a 10 minute interval, write an entry in the system log
//
environ.temp @1 - environ.temp @0 > 2
    -> alarm "temperature rising fast" &
       syslog "machine room temperature rise alarm";

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// Something interesting if you have performance problems with
// your Oracle data base ...
//
db = "oracle.ptg1";
host = ":moomba.melbourne.sgi.com";
lru = "#'cache buffers lru chain'";
gets = "$db.latch.gets $host $lru";
total = "$db.latch.gets $host $lru + $db.latch.misses $host $lru +
	$db.latch.immisses $host $lru";

$total > 100 && $gets / $total < 0.2
    -> alarm "high LRU latch contention";

// Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// Busy disk?

delta = 20 sec;		// force evaluation once every 5 seconds from here on

// If any disk is performing more than 60 I/Os per second, then
// print a message to standard output and launch dkvis(1)
//
some_inst
    disk.dev.total > 60 count/sec
	-> print "disk busy for 20 sec" "%v IOPS %i@%h" &
	   shell 5 min "dkvis";

