|
||||
HOWTO: system load status in screen(1)
To be precise, not the load itself (0.00 0.00 0.00) but ...
CPU: 5.2% user, 0.0% nice, 19.0% system, 0.0% interrupt, 75.8% idle ... but like that (generally you may customize output as you need): user: 5.2% | nice: 0.0% | system: 19.0% | interrupt: 0.0% | idle: 75.8% Like on this window: Now as you know what the end result will look like, lets describe needed steps to achieve this. First, you need to have the uniload.sh script running in the background: % uniload.sh & The uniload.sh script itself: Code:
#! /bin/sh STATS_FILE=/var/tmp/${USER}_stats_top DELAY=1 # FreeBSD uses jot(1) while Linux uses seq(1) which jot 1> /dev/null 2> /dev/null || alias jot=seq __freebsd() { top -s ${DELAY} -d 2 0 \ | grep -m 1 CPU \ | sed 's/,//g' \ | awk '{ print $2": "$3" | "$4": "$5" | "$6": "$7" | "$8": "$9" | "$10": "$11 }' } __linux() { top -d ${DELAY} -n 2 -b \ | grep -m 2 Cpu \ | tail -1 \ | sed 's/%/ /g' \ | awk '{ print "user: " $2 " | system: " $4 " | nice: " $6 " | idle: " $8 }' } __exit() { rm -rf ${STATS_FILE} exit 0 } trap '__exit' 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 OS=$( uname ) while true do for I in $( jot 128 ); do case ${OS} in (FreeBSD) __freebsd >> ${STATS_FILE} 2>&1 ;; (Linux) __linux >> ${STATS_FILE} 2>&1 ;; (*) echo "supported systems: FreeBSD Linux"; exit 1 ;; esac done sleep 1 :> ${STATS_FILE} done It will be like that for vermaden user: Code:
backtick 100 5 5 tail -1 /var/tmp/vermaden_stats_top caption always '%{= wk} %= %100` %='
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
|||
screen? tmux is the new screen.
|
|
||||
GNU screen works very good for me, I do not have any reason to switch, of course BSD screen looks better then GNU screen, but I can live with that
Also, can I customize status bar in tmux as I have it now in screen? I have seen that tmux displays some bar on bottom by default, but I havent checked if it can be modified.
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
||||
Thanks IdOp.
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
||||
Works great. Thanks vermanden
__________________
BSD and Linux tips and tutorials: Blog Linux/BSD: sharing experiences |
|
||||
Noticed that the output isn't correct, e.g.
0.0%: user | 0.0%: nice | 0.0%: system | 99.3%: interrupt | : idle .The culprit is this part: Code:
__freebsd() { top -s ${DELAY} -d 2 0 \ | grep -m 1 CPU \ | sed 's/,//g' \ | awk '{ print $4": "$3" | "$6": "$5" | "$8": "$7" | "$10": "$9" | "$12": "$11 }' } Code:
__freebsd() { top -s ${DELAY} -d 2 0 \ | grep -m 1 CPU \ | sed 's/,//g' \ | awk '{ print $2": "$3" | "$4": "$5" | "$6": "$7" | "$8": "$9" | "$10": "$11 }' }
__________________
BSD and Linux tips and tutorials: Blog Linux/BSD: sharing experiences |
|
||||
Thanks, added.
When I was creating this HOWTO I generally did not used it, I have used it rather in the past
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
||||
Notice that top changed on FreeBSD 7.3-RELEASE/STABLE so the script needs to be updated to reflect it.
Namely, change from Code:
__freebsd() { top -s ${DELAY} -d 2 0 \ | grep -m 1 CPU \ | sed 's/,//g' \ | awk '{ print $2": "$3" | "$4": "$5" | "$6": "$7" | "$8": "$9" | "$10": "$11 }' } Code:
__freebsd() { top -s ${DELAY} -d 2 0 \ | grep -m 1 CPU \ | sed 's/,//g' \ | awk '{ print $4": "$3" | "$6": "$5" | "$8": "$7" | "$10": "$9" | "$12": "$11 }' }
__________________
BSD and Linux tips and tutorials: Blog Linux/BSD: sharing experiences |
|
||||
@tangram
Good to know, I havent used that 'monitoring' for ages ... propably about FreeBSD 6.1 last time.
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What is the status of KDE4? | wubrgamer | General software and network | 10 | 24th September 2008 03:58 AM |
howto change 'uname -a' after base system U/G | fallen | FreeBSD Installation and Upgrading | 8 | 16th July 2008 01:24 AM |
Status of Xen on OpenBSD | Oko | OpenBSD General | 2 | 19th June 2008 09:02 PM |
Which file system use to share data on Bsd system? | aleunix | Other BSD and UNIX/UNIX-like | 2 | 1st June 2008 04:14 PM |
HOWTO: Clear console screen after logout | vermaden | Guides | 0 | 5th May 2008 11:30 AM |