diff options
Diffstat (limited to 'src/pmieconf/check-rules')
-rwxr-xr-x | src/pmieconf/check-rules | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/pmieconf/check-rules b/src/pmieconf/check-rules new file mode 100755 index 0000000..b61421d --- /dev/null +++ b/src/pmieconf/check-rules @@ -0,0 +1,82 @@ +#!/bin/sh +# +# 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 + + +# Once the "rules" directory is populated, extract all the PCP metric +# names and make sure they are available on the current host or the +# host specified by -h hostname +# + +_usage() +{ + echo "Usage: $0 [-h hostname]" + exit 1 +} + +source='' +while getopts "h:?" c +do + case $c + in + h) + source="-h $OPTARG" + ;; + ?) + _usage + # NOTREACHED + ;; + esac +done +shift `expr $OPTIND - 1` +if [ $# -ne 0 ] +then + _usage + # NOTREACHED +fi + +if [ ! -d rules ] +then + echo "$0: cannot find \"rules\" directory!" + exit 1 +fi + +find rules -follow -type f -print \ +| LC_COLLATE=POSIX sort \ +| while read rule +do + badrule=false + ./xtractnames <$rule \ + | while read metric + do + + probe=`pmprobe $source $metric` + numval=`echo $probe | awk '{print $2}'` + if [ $numval -lt 0 ] + then + if $badrule + then + : + else + echo + echo "$rule" + echo "#" + echo "# rule: `basename $rule`" + badrule=true + fi + echo "# $probe" + fi + done +done |