You are currently browsing the category archive for the 'Programming' category.
Mostly solaris, probably similar on other *nix sytems….
Disk Stats
$ iostat -xnct 5
tty cpu
tin tout us sy wt id
3 42 45 1 0 54
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
0.4 3.8 11.6 23.5 0.0 0.0 2.1 1.1 0 0 c1d0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 c0t0d0
tty cpu
tin tout us sy wt id
187 180 54 4 0 43
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
0.8 6.4 5.0 80.2 0.0 0.0 0.1 1.1 0 1 c1d0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 c0t0d0
tty cpu
tin tout us sy wt id
14 277 50 1 0 49
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
0.0 1.4 0.0 12.8 0.0 0.0 0.1 0.3 0 0 c1d0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 c0t0d0
Sorry about the g33ky post, but i was looking for an example of how to use awk for this circumstance. There’s probably another text-manipulation cli app to do the job, but i just wanted to use awk for this one.
Note: Solaris awk is known to be buggy. us the xpg4 version on all solaris boxes, or the “match” function wont work.
1 line of data set example:
20081210 133924638-0500 mmsrb owmmsrelay 193 46 46 Info;MMSRelayTxnLog(220/101)193:46:lc=Op ct=owmmsrelay op=MMBox_view.REQ ms=4.63 uid=114944517818131292 size=0 SrvcID=MMS AppID=”Openwave MMS Relay” AppHost=10.33.233.131 AppPort=8088 MsgID=AElADNwAEADBAC4KIe6D OrigIF=WEB RcptIF=WEB OrigAddr=”+19046219845/TYPE=PLMN” RcptAddr=”+19056219845/TYPE=PLMN” NumRcpts=1 EvTime=20081210133924 EvStatus=Success Folder=INBOX TrackID=AElADNwAEADBAC4KIe6D PeerHost=10.33.238.131 PeerPort=55476
Hi Everyone;
I made a great perl script to calculate sunrise and sunset times in Toronto for the whole year with a graphical output. I wrote this in my dead-time during a work order tonight… so I hope you enjoy it as much as I enjoyed making it.

Notes:
- my brother’s birthday, which is right around the corner is day 286. That’s a g33ky number.
- Here’s a day-of-the-year number calendar .
- does not account for Daylight Savings Time changes
- the output is in decimal form (.1 hours is about 6 minutes)
How to understand the output
————-***********************————– Day: 286 , sunrise: 7.46371983255512 , sunset: 18.6748421708946
-
- The —– is darkness (night)
- The ******* is sunlight (day)
- sunrise 7.46371…. is the time local to toronto at GMT -4 (7.46 = 7 oclock + (.46 * 60 minutes) = 7:27am
Sample output. If you scroll through enough lines, an “hourglass” shape starts to appear:
# ./sun.pl ----------------******************---------------- Day: 1 , sunrise: 8.8499964506844 , sunset: 17.8363243941365 ----------------******************---------------- Day: 2 , sunrise: 8.85157917721863 , sunset: 17.8505635052382 ---------------*******************---------------- Day: 3 , sunrise: 8.85247026342554 , sunset: 17.8653183755327 ---------------*******************---------------- Day: 4 , sunrise: 8.85266811641787 , sunset: 17.8805734993673 ---------------*******************---------------- Day: 5 , sunrise: 8.85217187255689 , sunset: 17.8963130190473 ---------------*******************---------------- Day: 6 , sunrise: 8.8509813847397 , sunset: 17.9125207658933 ---------------*******************---------------- Day: 7 , sunrise: 8.84909720761213 , sunset: 17.9291803019326
Here’s the perl code to support it. A lot of it was based on http://www.adventist.org/sun/sun.pm . Obviously, i did a lot of reworking of the ideas into my own script. Click MORE for a special suprise (and the code)
Here’s a list of useful Perl concepts and examples that I have compiled for my brother, and anyone else who might have an interest in Perl.
If there’s any examples you’d like to see or you have something useful for others, please comment! Thanks!
I use perl all the time at the telecommunications company where I work. I use it to process Gigabyte-large files with complex algorithms, gathering hourly statistics off of remote devices, and to identify patterns.
Ordinarily, I don’t publish such geeky content, but considering it’s been a while since my last post, and that my brother has taken an active interest in scripting, I decided to put this out there, for posterity sake.

SocialVibe