Browse Source

add load average classes

master
Georg Hopp 12 years ago
parent
commit
429425fca5
  1. 36
      gatherer/misc_information.sh
  2. 2
      gatherer/system_information.sh
  3. 58
      notes/cf-engine-classes.txt
  4. 3
      run.sh

36
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 ";";
}' </proc/loadavg)
}
export UPTIME LOAD_1 LOAD_5 LOAD_15
}
# vim: set ts=4 sw=4:

2
gatherer/system_information.sh

@ -5,12 +5,14 @@ include_once utils/classes.sh
include_once gatherer/host_information.sh include_once gatherer/host_information.sh
include_once gatherer/dist_information.sh include_once gatherer/dist_information.sh
include_once gatherer/cpu_information.sh include_once gatherer/cpu_information.sh
include_once gatherer/misc_information.sh
include_once gatherer/interface_information.sh include_once gatherer/interface_information.sh
gather_information() { gather_information() {
gather_host_info gather_host_info
gather_dist_info gather_dist_info
gather_cpu_info gather_cpu_info
gather_uptime_info
gather_interface_info gather_interface_info
} }

58
notes/cf-engine-classes.txt

@ -17,6 +17,17 @@
=test /// (hostname) /// =test /// (hostname) ///
=x86_64 =x86_64
/// network classes ///
-ipv4_127
-ipv4_127_0
-ipv4_127_0_0
-ipv4_127_0_0_1
-ipv4_192
-ipv4_192_168
-ipv4_192_168_120
-ipv4_192_168_120_40
/// instead of doing this I add the valid networks of the host ///
/// time control classes /// /// time control classes ///
?Day15 ?Day15
?Evening ?Evening
@ -30,24 +41,15 @@
?Saturday ?Saturday
?Yr2014 ?Yr2014
Lcycle_1
PK_MD5_1cc0a2b13599f57ebb17df5abdc45ae1
agent
any
cfengine_3
cfengine_3_5
cfengine_3_5_3
community_edition
compiled_on_linux_gnu
inform_mode
verbose_mode
/// threshold classes /// /// threshold classes ///
cpu0_high
cpu1_high
cpu2_high
cpu3_high
cpu_high
-cpu0_high
-cpu1_high
-cpu2_high
-cpu3_high
-cpu_high
/// I replaced these with informations about the current average load
/// My assumption here is that the average is by far more useful.
diskfree_high_normal diskfree_high_normal
entropy_misc_in_low entropy_misc_in_low
entropy_misc_out_low entropy_misc_out_low
@ -59,12 +61,16 @@ rootprocs_high
ssh_in_high ssh_in_high
users_high users_high
/// network classes ///
ipv4_127
ipv4_127_0
ipv4_127_0_0
ipv4_127_0_0_1
ipv4_192
ipv4_192_168
ipv4_192_168_120
ipv4_192_168_120_40
/// I guess that these are cfengine specific so I ignore these. ///
Lcycle_1
PK_MD5_1cc0a2b13599f57ebb17df5abdc45ae1
agent
any
cfengine_3
cfengine_3_5
cfengine_3_5_3
community_edition
compiled_on_linux_gnu
inform_mode
verbose_mode

3
run.sh

@ -30,6 +30,9 @@ ${PRINTF} "%15s : %s\n" "# CPUS" "${NCPUS}"
${PRINTF} "%15s : %s\n" "BYTE_ORDER" "${BYTE_ORDER}" ${PRINTF} "%15s : %s\n" "BYTE_ORDER" "${BYTE_ORDER}"
${PRINTF} "%15s : %s\n" "OP_MODES" "${OP_MODES}" ${PRINTF} "%15s : %s\n" "OP_MODES" "${OP_MODES}"
${PRINTF} "%15s : %s\n" "CPU_VIRT" "${CPU_VIRT}" ${PRINTF} "%15s : %s\n" "CPU_VIRT" "${CPU_VIRT}"
${PRINTF} "%15s : %s\n" "LOAD_1" "${LOAD_1}"
${PRINTF} "%15s : %s\n" "LOAD_5" "${LOAD_5}"
${PRINTF} "%15s : %s\n" "LOAD_15" "${LOAD_15}"
${PRINTF} "%15s : %s\n" "# INTERFACES" "${NINTERFACES}" ${PRINTF} "%15s : %s\n" "# INTERFACES" "${NINTERFACES}"
NO=1 NO=1

Loading…
Cancel
Save