// Some Common Performance Monitoring Scenarios
//
// Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of version 2 of the GNU General Public License as
// published by the Free Software Foundation.
// 
// This program is distributed in the hope that it would be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// 
// Further, this software is distributed without any warranty that it is
// free of the rightful claim of any third person regarding infringement
// or the like.  Any license provided herein, whether implied or
// otherwise, applies only to this software file.  Patent licenses, if
// any, provided herein do not apply to combinations of this program with
// other software, or any other product whatsoever.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write the Free Software Foundation, Inc., 59
// Temple Place - Suite 330, Boston MA 02111-1307, USA.
// 
// Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
// Mountain View, CA  94043, or:
// 
// http://www.sgi.com 
// 
// For further information regarding this notice, see: 
// 
// http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
//
//
// The Disk Group
//

delta = 15 sec;		// often enough for disks?

// common prefixes
//
disk	= "disk";

// Any disk performing more than 40 I/Os per second, sustained over
//
// Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of version 2 of the GNU General Public License as
// published by the Free Software Foundation.
// 
// This program is distributed in the hope that it would be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// 
// Further, this software is distributed without any warranty that it is
// free of the rightful claim of any third person regarding infringement
// or the like.  Any license provided herein, whether implied or
// otherwise, applies only to this software file.  Patent licenses, if
// any, provided herein do not apply to combinations of this program with
// other software, or any other product whatsoever.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write the Free Software Foundation, Inc., 59
// Temple Place - Suite 330, Boston MA 02111-1307, USA.
// 
// Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
// Mountain View, CA  94043, or:
// 
// http://www.sgi.com 
// 
// For further information regarding this notice, see: 
// 
// http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
//
// at least 30 seconds is probably busy
//
delta = 30 seconds;
disk_busy =
    some_inst (
	$disk.dev.total > 40 count/sec
    )
    -> shell 15 mins "Mail -s 'Heavy sustained disk traffic' sysadm </dev/null";

// Try and catch bursts of activity ... more than 60 I/Os per second
// for at least 25% of 8 consecutive 3 second samples
//
delta = 3 sec;
disk_burst =
    some_inst (
	25%_sample (
	    $disk.dev.total @0..7 > 60 count/sec
	)
    )
    -> alarm 5 mins "Disk Burst? " "%i ";

// any SCSI disk controller performing more than 3 Mbytes per sec is busy
//
some_inst $disk.ctl.blktotal * 0.5 > 3 Mbyte/sec
    -> alarm "Busy Disk Controller: " "%i ";


// A subset of the disks on a particular host are either busy
//
// Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of version 2 of the GNU General Public License as
// published by the Free Software Foundation.
// 
// This program is distributed in the hope that it would be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// 
// Further, this software is distributed without any warranty that it is
// free of the rightful claim of any third person regarding infringement
// or the like.  Any license provided herein, whether implied or
// otherwise, applies only to this software file.  Patent licenses, if
// any, provided herein do not apply to combinations of this program with
// other software, or any other product whatsoever.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write the Free Software Foundation, Inc., 59
// Temple Place - Suite 330, Boston MA 02111-1307, USA.
// 
// Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
// Mountain View, CA  94043, or:
// 
// http://www.sgi.com 
// 
// For further information regarding this notice, see: 
// 
// http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
//
// (more than 30 I/Os per second averaged over these disks) or one
// disk is busy (more than 50 I/Os per second) with write-dominated
// (more than 75%) activity

delta = 10 sec;

myhost = "moomba";			// the host of interest
mydisks = "#dks1d1 #dks1d2 #dks3d2";	// the disks of interest on this host

metric = "disk.dev";

disk_group_busy =
    (
	avg_inst ( $metric.total :$myhost $mydisks ) > 10 count/sec ||
	some_inst (
	    $metric.total :$myhost $mydisks > 50 count/sec &&
	    $metric.write :$myhost $mydisks >
		3 * $metric.write :$myhost $mydisks
	)
    )
	    -> alarm "Busy disks: $mydisks on host: $myhost)"; 

// Assume the / and /usr file systems are on different partitions
//
// Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of version 2 of the GNU General Public License as
// published by the Free Software Foundation.
// 
// This program is distributed in the hope that it would be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// 
// Further, this software is distributed without any warranty that it is
// free of the rightful claim of any third person regarding infringement
// or the like.  Any license provided herein, whether implied or
// otherwise, applies only to this software file.  Patent licenses, if
// any, provided herein do not apply to combinations of this program with
// other software, or any other product whatsoever.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write the Free Software Foundation, Inc., 59
// Temple Place - Suite 330, Boston MA 02111-1307, USA.
// 
// Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
// Mountain View, CA  94043, or:
// 
// http://www.sgi.com 
// 
// For further information regarding this notice, see: 
// 
// http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
//
// of the same disk (/dev/dsk0d1 in the example below).
// Add an entry to the file /var/adm/pcplog/NOTICES when this disk is
// busy and either of the file systems is more than 90% full.
//
// Suggestion from: Steve Daniels (steve@houdini.denver.sgi.com)

delta = 60;

( filesys.full #'/dev/root' > 90 || filesys.full #'/dev/usr' > 90 )
&& disk.dev.total #'dks0d1' > 40 count/sec
    -> shell 15min "/usr/pcp/bin/pmpost 'dks0d1 busy when / or /usr nearly full'";

