Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] Which openoffice
Date: Tue, 06 May 2008 08:12:30
Message-Id: 200805061011.07872.shrdlu@unlimitedmail.org
In Reply to: Re: [gentoo-user] [OT] Which openoffice by Alan McKinnon
1 On Monday 5 May 2008, 22:12, Alan McKinnon wrote:
2
3 > nazgul screenlets-0.0.2 # echo `uptime|grep days|sed 's/.*up
4 > \([0-9]*\) day.*/\1\/10+/'; cat /proc/cpuinfo|grep '^cpu MHz'|awk
5 > '{print $4"/30 +";}';free|grep '^Mem'|awk '{print $3"/1024/3+"}'; df
6 > -P -k -x nfs -x smbfs | grep -v '1024-blocks' | awk '{if ($1 ~
7 > "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15
8 > +70";}'`|bc|sed 's/\(.$\)/.\1cm/' 67.1cm
9 >
10 > Fascinating, most fascinating. I get 67.1cm! Longer than yours!
11 >
12 > Now, this command of your. Wazzitdo?
13
14 It builds a bc expression, which is then fed to bc and the result is
15 divided by 10 and has "cm" added to it.
16
17 uptime|grep days|sed 's/.*up \([0-9]*\) day.*/\1\/10+/'
18
19 This checks the uptime, and outputs "n/10+", where "n" is the uptime in
20 days. In my case, the expression is "2/10+".
21
22
23 cat /proc/cpuinfo|grep '^cpu MHz'|awk '{print $4"/30 +";}'
24
25 This outputs "n/30 +", where "n" is the CPU speed in mhz. In my case
26 (hyperthreding cpu) it outputs
27
28 3000.000/30 +
29 3000.000/30 +
30
31
32 free|grep '^Mem'|awk '{print $3"/1024/3+"}'
33
34 This outputs "n/1024/3+", where "n" is the "used memory" from free's
35 output. On my desktop, that is "1721716/1024/3+", but obvioulsy it
36 changes almost every time you run the command. Not sure why the used
37 memory is used instead of the total.
38
39 df -P -k -x nfs -x smbfs | grep -v '1024-blocks' | awk '{if ($1
40 ~ "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15
41 +70";}'
42
43 This outputs "n/15 +70", where "n" is the sum of the 1024-blocks as per
44 df's output (excluding nfs and smbfs file systems), divided by 1024 and
45 further divided by 50. The block count of /dev/scsi* or /dev/sd* devices
46 is counted twice (not sure why though). On my system, the output
47 is "5313.33/15 +70".
48
49 So, the final expression fed to bc is
50
51 2/10+ 3000.000/30 + 3000.000/30 + 1721716/1024/3+ 5313.33/15 +70
52
53 bc does the math, and sed divides the result by 10 and adds "cm" to the
54 result. For me, that gives 118.4cm.
55
56 It would be interesting to know why Willie chose those values, those
57 scaling factors, and what's the purpose of the constants.
58
59 Nice script though! Thanks!
60 --
61 gentoo-user@l.g.o mailing list

Replies

Subject Author
Re: [gentoo-user] [OT] Which openoffice Neil Bothwick <neil@××××××××××.uk>