Skip to content

Instantly share code, notes, and snippets.

@50kudos
Created October 14, 2013 04:03
Show Gist options
  • Save 50kudos/6970570 to your computer and use it in GitHub Desktop.
Save 50kudos/6970570 to your computer and use it in GitHub Desktop.
Text processing (Only Ubuntu)
#161.246.34.191:-:161.246.34.195:-:sID.123456789012196:-:9999
!interval::1
!treshold::userCPU=51=89=180=180=300=999:-:usedMem=71=79=180=180=999=999:-:pUsedHdd=51=79=180=180=999=999:-:load5=1.50=1.79=180=180=200=999:-:load15=1.50=1.79=180=200=300=600
#treshold::key,threshold1,threshold2,t1(time to warning),t2(time to critical),t3(special time for migrate),t4(extra time for migrate) ,remark load5 t3 and t2 must be different 20+
$userCPU::sar -u 1 1 | sed -n 4,4p | awk '{print $4}'
$sysCPU::sar -u 1 1 | sed -n 4,4p | awk '{print $6}'
$load1::w | sed -n 1,1p |sed 's/.*: \(\)/\1/g' | cut -d, -f1
$load5::w | sed -n 1,1p |sed 's/.*: \(\)/\1/g' | cut -d, -f2 | sed s/' '//
$load15::w | sed -n 1,1p |sed 's/.*: \(\)/\1/g' | cut -d, -f3 | sed s/' '//
$pUsedHdd::df | grep '\/$' | awk '{if($1~/sda/)$4=$5};END{print $4}' | sed s/%//
$usedHdd::df | grep '\/$' | awk '{if($1~/sda/)$2=$3};END{print $2}' | sed s/%//
$freeHdd::df | grep '\/$' | awk '{if($1~/sda/)$3=$4};END{print $3}' | sed s/%//
$usedMem::cat /proc/meminfo | grep 'MemTotal' | awk -v free=$(cat /proc/meminfo | grep 'MemFree' | awk '{print $2}') '{print $2-free}'
$freeMem::cat /proc/meminfo | grep 'MemFree' | awk '{print $2}'
$apacheload::apache2ctl status | grep 'CPU load' | awk {'print $8'} | cut -d % -f1
$apacheReq::apache2ctl status | grep 'requests/sec' | awk '{print $1}'
$totalAccess::apache2ctl status | grep 'Traffic' | awk '{print $3}'
$totalTraffic::apache2ctl status | grep 'Traffic' | awk '{print $7}'
#apacheUPTIME::apache2ctl status | grep 'uptime' | awk {'print $3"."$5"."$7"."$9'}
#totalapachePS::top -b -n 1 | grep -vE 'top|PID|Cpu|Mem|Swap' | awk '{print $1,$2,$9,$10,$12}'
@psls::top -b -n1 | awk '{print $1,$2,$9,$10,$12}'| tail -n $(top -b -n1 | wc -l | awk '{print $1-11}') | grep -vE 'awk|wc|top|grep|bash|tail'
@cpu_info::grep -E 'model name|vendor_id|cpu MHz' /proc/cpuinfo | sed 's/^.*: \(\)/\1/g'
@uptime::w | sed -n 1,1p | sed 's/.*\(up.*, [0-9] u\).*/\1/g' | sed 's/.\{6\}$//'
@apacheInfo::apache2 -v | grep 'version' | sed 's/^.*: \(\)/\1/g'
@apacheUptime::apache2ctl status | grep 'uptime' | sed 's/.*: \(\)/\1/g'
@apacheStatus::service apache2 status | awk -v status=0 '{if($0~/is running/) status=1};END{print status}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment