// 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 CPU Group
//

delta = 2 sec;	// more often for demonstration purposes

// common prefixes
//
percpu	= "kernel.percpu";
all	= "kernel.all";

// Unusual usr-sys split when some CPU is more than 20% in usr mode
//
// 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/
//
// and sys mode is at least 1.5 times usr mode
//
cpu_usr_sys =
    some_inst (
	$percpu.cpu.sys > $percpu.cpu.user * 1.5 && $percpu.cpu.user > 0.2
    )
	->  alarm "Unusual sys time: " "%i ";

// Over all CPUs, syscall_rate > 1000 * no_of_cpus
//
// 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/
//
//
cpu_syscall =
    $all.syscall > 1000 count/sec * hinv.ncpu
    ->  print "high aggregate syscalls: %v";

// Sustained high syscall rate on a single CPU
//
delta = 30 sec;
percpu_syscall =
    some_inst (
	$percpu.syscall > 2000 count/sec
    )
	-> syslog "Sustained syscalls per second? " "[%i] %v ";

// the 1 minute load average exceeds 5 * number of CPUs on any host
//
// 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/
//
//

hosts = ":gonzo :moomba";	// change as required
delta = 1 minute;		// no need to evaluate more often than this
high_load =
    some_host (
	$all.load $hosts #'1 minute' > 5 * hinv.ncpu $hosts
    ) -> alarm "High Load Average? " "%h: %v ";

