From 429425fca5175618e90fb94eee43744b70429ce7 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Mon, 17 Mar 2014 21:45:53 +0000 Subject: [PATCH] add load average classes --- gatherer/misc_information.sh | 36 +++++++++++++++++++++ gatherer/system_information.sh | 2 ++ notes/cf-engine-classes.txt | 58 +++++++++++++++++++--------------- run.sh | 3 ++ 4 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 gatherer/misc_information.sh diff --git a/gatherer/misc_information.sh b/gatherer/misc_information.sh new file mode 100644 index 0000000..ba9f3f6 --- /dev/null +++ b/gatherer/misc_information.sh @@ -0,0 +1,36 @@ +gather_uptime_info() { + [ -z "${UPTIME}" ] || return + + export UPTIME="" + export LOAD_1="" + export LOAD_5="" + export LOAD_15="" + + has_class "Linux" && { + eval $(${AWK} -v ncpus=${NCPUS} '{ + print "LOAD_1=\"" $1 "\";LOAD_5=\"" $2 "\";LOAD_15=\"" $3 "\";"; + for(i=1; i<4; i++) { + if($i<=0.0) { + load="LOW" + } else { + inv_load=ncpus/$i; + if (inv_load > (ncpus/2)) { + load="LOW"; + } else { + load="MODERATE"; + } + if (inv_load <= 0) load="HIGH"; + } + + if(i==1) { classes=classes "LOAD_1_" load " " } + if(i==2) { classes=classes "LOAD_5_" load " " } + if(i==3) { classes=classes "LOAD_15_" load " "; } + } + print "set_class " classes ";"; + }'