A Blog about technology, linux, peer2peer, cool new downloads and software development.

Saturday, February 9, 2008

.screenrc

here is a .screenrc that displays various statistics like cpu, load avarages, memory, bandwidth utilization and display and easily switch between virtual windows (work like tabs)
escape char : ^x
create window ^x-c
switch between windows : F11/F12
Screenshot :

$ cat > ~/.screenrc
---------- 8< ---------- 8< ---------- 8< ----------




vbell on
startup_message off
shell -bash
term linux
#term screen-bce
#term xterm
defbce on
defscrollback 2000
defescape ^Xx
escape ^Xx
term screen-256color
defutf8 on
bindkey -k F1 prev # F11
bindkey -k F2 next # F12

backtick 0 10 10 awk '{ printf "%sC", $2 }' /proc/acpi/thermal_zone/THRM/temperature

backtick 1 60 60 awk '{if ($1=="MemTotal:") mt = $2; if ($1=="MemFree:") mm = $2; if ($1=="Buffers:") mb = $2; if ($1=="Cached:") mc = $2} END {printf ("%2.1f"), ((mt-(mm+mb+mc)) * 100 / mt);print "%M"}' /proc/meminfo

backtick 2 60 50 awk '{if ($1=="SwapFree:") fs = $2; if ($1=="SwapTotal:") ts = $2} END {printf ("%2.1f"),((ts-fs) * 100 / ts );print "%S"}' /proc/meminfo

backtick 3 0 0 awk 'BEGIN {file = "/proc/stat";while (a==a) {getline < u="$2-up;s=" n="$4-np;i=" up="$2;sp=" np="$4;i" p="$5;close(file);system(" file="/proc/net/dev" a="=" d="substr($1,6,10);u=" printf="" 1f="" k="" s="" pri="">
ntf "%4.1f k/s\n",((u-up)/1024)}};close(file);dp=d;up=u;system("sleep 2")}}'

caption always "%{wk}%H|%{wk}%0` %1` %2` %3` |%4` %{wk}| %{wk}%l%{wk} | %Y-%m-%d %c | %{+b w}%-w%{-b kw}%n %t%{-}%+w %-= %=%{wk}|"

2 comments:

Anonymous said...

nice. but the bandwidth line is fubar for my (very, very limited) awk scripting knowledge.

Admin00 said...

Thanks, I re-formatted the script to be more readable.
regardign the network check that your distro shows something sililar to the sample below when lookign at /proc/net/dev
and let me know if you still have problems, i will try to help

cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 24306 271 0 0 0 0 0 0 24306 271 0 0 0 0 0 0
eth0:25635025 32141 0 0 0 0 0 0 27159476 43564 0 0 0 0 0 0
ham0: 33690 128 0 0 0 0 0 0 6451 43 0 0 0 0 0 0