Browse Source

some more stuff to make this slightly more useful on a freebsd

master
Georg Hopp 12 years ago
parent
commit
a549d6e532
  1. 8
      gatherer/cpu_information.sh
  2. 15
      gatherer/misc_information.sh

8
gatherer/cpu_information.sh

@ -3,6 +3,7 @@ gather_cpu_info() {
has_class "GNU" && { has_class "GNU" && {
export NCPUS=$(${NPROC}) export NCPUS=$(${NPROC})
set_class ${NCPUS}cpus
} }
has_class "Linux" && { has_class "Linux" && {
@ -18,9 +19,14 @@ gather_cpu_info() {
} }
/CPU(s):/ { print "export NCPUS=" $2 ";" } /CPU(s):/ { print "export NCPUS=" $2 ";" }
/Virtualization/ { print "export CPU_VIRT=\"" $2 "\";" }') /Virtualization/ { print "export CPU_VIRT=\"" $2 "\";" }')
}
set_class ${NCPUS}cpus ${CPU_VIRT} ${BYTE_ORDER} ${OP_MODES} set_class ${NCPUS}cpus ${CPU_VIRT} ${BYTE_ORDER} ${OP_MODES}
} }
has_class "FreeBSD" && {
export NCPUS=$(${SYSCTL} kern.smp.cpus | cut -d\ -f2)
set_class ${NCPUS}cpus
}
}
# vim: set ts=4 sw=4: # vim: set ts=4 sw=4:

15
gatherer/misc_information.sh

@ -6,8 +6,7 @@ gather_uptime_info() {
export LOAD_5="" export LOAD_5=""
export LOAD_15="" export LOAD_15=""
has_class "Linux" && {
eval $(${AWK} -v ncpus=${NCPUS} '{
local CALC_LOAD_AWK='{
print "LOAD_1=\"" $1 "\";LOAD_5=\"" $2 "\";LOAD_15=\"" $3 "\";"; print "LOAD_1=\"" $1 "\";LOAD_5=\"" $2 "\";LOAD_15=\"" $3 "\";";
for(i=1; i<4; i++) { for(i=1; i<4; i++) {
if($i<=0.0) { if($i<=0.0) {
@ -27,7 +26,17 @@ gather_uptime_info() {
if(i==3) { classes=classes "LOAD_15_" load " "; } if(i==3) { classes=classes "LOAD_15_" load " "; }
} }
print "set_class " classes ";"; print "set_class " classes ";";
}' </proc/loadavg)
}'
has_class "Linux" && {
eval $(${AWK} -v ncpus=${NCPUS} "${CALC_LOAD_AWK}" </proc/loadavg)
}
has_class "FreeBSD" && {
local N='\([0-9]*\.[0-9]*\)'
eval $(${SYSCTL} vm.loadavg |\
${SED} 's/^.*{ '"${N}"' '"${N}"' '"${N}"'.*/\1 \2 \3/' |\
${AWK} -v ncpus=${NCPUS} "${CALC_LOAD_AWK}")
} }
export UPTIME LOAD_1 LOAD_5 LOAD_15 export UPTIME LOAD_1 LOAD_5 LOAD_15

Loading…
Cancel
Save