Showing
4 changed files
with
73 additions
and
26 deletions
gatherer/misc_information.sh
0 → 100644
| 1 | +gather_uptime_info() { | |
| 2 | + [ -z "${UPTIME}" ] || return | |
| 3 | + | |
| 4 | + export UPTIME="" | |
| 5 | + export LOAD_1="" | |
| 6 | + export LOAD_5="" | |
| 7 | + export LOAD_15="" | |
| 8 | + | |
| 9 | + has_class "Linux" && { | |
| 10 | + eval $(${AWK} -v ncpus=${NCPUS} '{ | |
| 11 | + print "LOAD_1=\"" $1 "\";LOAD_5=\"" $2 "\";LOAD_15=\"" $3 "\";"; | |
| 12 | + for(i=1; i<4; i++) { | |
| 13 | + if($i<=0.0) { | |
| 14 | + load="LOW" | |
| 15 | + } else { | |
| 16 | + inv_load=ncpus/$i; | |
| 17 | + if (inv_load > (ncpus/2)) { | |
| 18 | + load="LOW"; | |
| 19 | + } else { | |
| 20 | + load="MODERATE"; | |
| 21 | + } | |
| 22 | + if (inv_load <= 0) load="HIGH"; | |
| 23 | + } | |
| 24 | + | |
| 25 | + if(i==1) { classes=classes "LOAD_1_" load " " } | |
| 26 | + if(i==2) { classes=classes "LOAD_5_" load " " } | |
| 27 | + if(i==3) { classes=classes "LOAD_15_" load " "; } | |
| 28 | + } | |
| 29 | + print "set_class " classes ";"; | |
| 30 | + }' </proc/loadavg) | |
| 31 | + } | |
| 32 | + | |
| 33 | + export UPTIME LOAD_1 LOAD_5 LOAD_15 | |
| 34 | +} | |
| 35 | + | |
| 36 | +# vim: set ts=4 sw=4: | ... | ... |
| ... | ... | @@ -5,12 +5,14 @@ include_once utils/classes.sh |
| 5 | 5 | include_once gatherer/host_information.sh |
| 6 | 6 | include_once gatherer/dist_information.sh |
| 7 | 7 | include_once gatherer/cpu_information.sh |
| 8 | +include_once gatherer/misc_information.sh | |
| 8 | 9 | include_once gatherer/interface_information.sh |
| 9 | 10 | |
| 10 | 11 | gather_information() { |
| 11 | 12 | gather_host_info |
| 12 | 13 | gather_dist_info |
| 13 | 14 | gather_cpu_info |
| 15 | + gather_uptime_info | |
| 14 | 16 | gather_interface_info |
| 15 | 17 | } |
| 16 | 18 | ... | ... |
| ... | ... | @@ -17,6 +17,17 @@ |
| 17 | 17 | =test /// (hostname) /// |
| 18 | 18 | =x86_64 |
| 19 | 19 | |
| 20 | +/// network classes /// | |
| 21 | +-ipv4_127 | |
| 22 | +-ipv4_127_0 | |
| 23 | +-ipv4_127_0_0 | |
| 24 | +-ipv4_127_0_0_1 | |
| 25 | +-ipv4_192 | |
| 26 | +-ipv4_192_168 | |
| 27 | +-ipv4_192_168_120 | |
| 28 | +-ipv4_192_168_120_40 | |
| 29 | +/// instead of doing this I add the valid networks of the host /// | |
| 30 | + | |
| 20 | 31 | /// time control classes /// |
| 21 | 32 | ?Day15 |
| 22 | 33 | ?Evening |
| ... | ... | @@ -30,24 +41,15 @@ |
| 30 | 41 | ?Saturday |
| 31 | 42 | ?Yr2014 |
| 32 | 43 | |
| 33 | -Lcycle_1 | |
| 34 | -PK_MD5_1cc0a2b13599f57ebb17df5abdc45ae1 | |
| 35 | -agent | |
| 36 | -any | |
| 37 | -cfengine_3 | |
| 38 | -cfengine_3_5 | |
| 39 | -cfengine_3_5_3 | |
| 40 | -community_edition | |
| 41 | -compiled_on_linux_gnu | |
| 42 | -inform_mode | |
| 43 | -verbose_mode | |
| 44 | - | |
| 45 | 44 | /// threshold classes /// |
| 46 | -cpu0_high | |
| 47 | -cpu1_high | |
| 48 | -cpu2_high | |
| 49 | -cpu3_high | |
| 50 | -cpu_high | |
| 45 | +-cpu0_high | |
| 46 | +-cpu1_high | |
| 47 | +-cpu2_high | |
| 48 | +-cpu3_high | |
| 49 | +-cpu_high | |
| 50 | +/// I replaced these with informations about the current average load | |
| 51 | +/// My assumption here is that the average is by far more useful. | |
| 52 | + | |
| 51 | 53 | diskfree_high_normal |
| 52 | 54 | entropy_misc_in_low |
| 53 | 55 | entropy_misc_out_low |
| ... | ... | @@ -59,12 +61,16 @@ rootprocs_high |
| 59 | 61 | ssh_in_high |
| 60 | 62 | users_high |
| 61 | 63 | |
| 62 | -/// network classes /// | |
| 63 | -ipv4_127 | |
| 64 | -ipv4_127_0 | |
| 65 | -ipv4_127_0_0 | |
| 66 | -ipv4_127_0_0_1 | |
| 67 | -ipv4_192 | |
| 68 | -ipv4_192_168 | |
| 69 | -ipv4_192_168_120 | |
| 70 | -ipv4_192_168_120_40 | |
| 64 | +/// I guess that these are cfengine specific so I ignore these. /// | |
| 65 | +Lcycle_1 | |
| 66 | +PK_MD5_1cc0a2b13599f57ebb17df5abdc45ae1 | |
| 67 | +agent | |
| 68 | +any | |
| 69 | +cfengine_3 | |
| 70 | +cfengine_3_5 | |
| 71 | +cfengine_3_5_3 | |
| 72 | +community_edition | |
| 73 | +compiled_on_linux_gnu | |
| 74 | +inform_mode | |
| 75 | +verbose_mode | |
| 76 | + | ... | ... |
| ... | ... | @@ -30,6 +30,9 @@ ${PRINTF} "%15s : %s\n" "# CPUS" "${NCPUS}" |
| 30 | 30 | ${PRINTF} "%15s : %s\n" "BYTE_ORDER" "${BYTE_ORDER}" |
| 31 | 31 | ${PRINTF} "%15s : %s\n" "OP_MODES" "${OP_MODES}" |
| 32 | 32 | ${PRINTF} "%15s : %s\n" "CPU_VIRT" "${CPU_VIRT}" |
| 33 | +${PRINTF} "%15s : %s\n" "LOAD_1" "${LOAD_1}" | |
| 34 | +${PRINTF} "%15s : %s\n" "LOAD_5" "${LOAD_5}" | |
| 35 | +${PRINTF} "%15s : %s\n" "LOAD_15" "${LOAD_15}" | |
| 33 | 36 | ${PRINTF} "%15s : %s\n" "# INTERFACES" "${NINTERFACES}" |
| 34 | 37 | |
| 35 | 38 | NO=1 | ... | ... |
Please
register
or
login
to post a comment