This coming Monday I’m flying off to Atlanta, Georgia for the week. Not keen on going as Atlanta is like descending into the armpit of summer. I’m hoping that the weather co-operates and I don’t melt.
I’m flying down there for work, we’re beta launching a product for a customer (that’s based in Atlanta - go figure) and they (the customer) have requested a contingent of us from work be on site for the release. So it’s me and two others from the UK.
We’re down on Monday then flying back home on Friday evening - I’m hoping to be in bed by midnight (landing 22:05 - 30 minute taxi home, getting bags and immigration and such). A SysAdmin that works for our customer suggested Zuma sushi bar to me for sushi. I like sushi a lot and hope to stop in for some glorious sushi.
Last month I made a post about using rrdtool and ruby to graph hard disk temperatures. I recently had some hardware trouble and something with permissions went crazy. Today I took the time to look into the problem and fix it.
The /dev/hd[egik] device nodes were owned by root:disk and 660. However, the hddtemp binary was trying to do some restricted ioctl operations. Even though the binary was setuid and my non-root user was in the disk group I couldn’t access the disk to get the temperatures.
I found out that there is a hddtemp daemon which can query the disks for my unpriveleged user.
The daemon listens on a TCP port and provides output like this:
|/dev/hde|ST3160811AS|39|C||/dev/hdg|ST3160811AS|40|C||/dev/hdi|ST3160811AS|38|C||/dev/hdk|ST3160815AS|39|C|
Should be easy to modify my disk_temperature.rb to connect to that port and parse the data.
Now my temperature graphs will have new data (as soon as the change is made).
I received an email to my work account today that started with “Dear Sirs…”. The email was sent, presumably, to a large number of customers at once about a networking issue by a UK hosting company.
I am female and at the time the salutation bugged me. In normal society one doesn’t generally greet a member of one gender with the salutations of the other. When I received the email my brain put together discussions from LinuxChix mail lists and other recent discussions on women in IT.
I took offence at the salutation “Sirs” because it implies that there are no women working in IT which is clearly not the case.
Anyways, I sent an email in reply to the email (which went to a support@ email) saying that I didn’t appreciate being addressed as a “Sir”. Less than 25 minutes later I received an email from the managing director of saying he wrote the message and thought the salutation “Sirs” was …was an acceptable greeting if the gender of the other party is unknown. I’m not sure I agree but I appreciated the feedback anyways and replied to him thanking him for taking the time to reply. Hopefully he will do as his email says and take my feedback on board and change the way his company addresses emails to women.
My good deed for the day is done.
Since I got to North America I have wanted to put my system under better monitoring. It’s got four active hard disks (and a fifth powered, not active) hard disk in an IcyDock MB-455SPF 5-Bay Internal SATA Drive Enclosure (Manufacturer site, icydock.com, seems offline so link to where I bought it!) with the four active disks plugged into a HighPoint RocketRaid 1640 SATA controller.
I can easily use S.M.A.R.T. to monitor the temperature and the hddtemp Linux utility to get the temperatures of the disks.
It’s easy to use a crontask to poll the disks and to stuff the temperatures into an rrdtool database. I drew much inspiration from Martin Pot’s Perl script to do the same thing but implemented my own in a Ruby Rake task using the woefully undocumented RubyRRDtool gem and a custom hddtemp wrapper class to get the temperatures.
The similarities between my Rake task and Martin’s RRDtool-fu is obvious, however I wanted an hour graph too and so I added it in on line 17.
My next task is to combine the temperatures (lines) of all four disks into a single graph to get a feel for the overall temperature of the disks on one image.
The graphs can be seen at my personal website.
I’ve been back in North America for about a week and a half so far. Spent a week with my parents and am visiting a friend for a while.
I’m settling into life on this side of the pond again and it’s nice to be round people who sound like me (makes it easier for speechreading). I haven’t been working on Reve or my other Rails project (evedb) for a while. Been working on a smaller private app here and there when not doing my real work.
This is just a quick post to say that my life has become quite hectic as my spouse recently died. I’m also planning to move back to North America…
I haven’t had much time to wrap my head around my newest Reve ticket/bug report. Once things settle down again I’ll be able to get back into posting and making Reve better.
Another Reve release, 86. This time I’m fixing a bug with the strict XML parsing not picking up cachedUntil. Tests and test XML have been fixed. Check trac for specific changes.
Just a quick note! I’ve been busy and have not had time to push this Reve release. Wish I had done it earlier but it’s here now.
Reve Release 83 with release notes at rubyforge. Short story is that I’ve fixed a bug with personal_wallet_tansactions method and fixed a bug with short XML tags causing problem with writing XML to disk for re-use.
Good luck!
Had my first bug report today about the to_i method I made on the String class breaking Rails migrations because leading zeroes weren’t being treated nicely in my method: "001".to_i # => 1 and fails the test 1.to_s == "001" and so a String was being returned fromto_i. Crap.
I don’t think that I need the method anyways (I’m going to spend part of today to make sure with more tests!) so I’ve removed it and tagged Release 80 and uploaded the gem to RubyForge. It should be available to gem update or gem install shortly.
This release also has a larger test coverage and some other unnecessary methods were pruned. Check it out!
First the problem:
I'm writing a load test framework at work and I need to consume JSON webservice and pass on the output to another request. But I don't always know what the data is that I need to pass on but I do know the basic "path" ("hpath" -- "hash path") to get to the data as the JSON data is uniform.
Now the method:
RUBY:
-
# Picks out data from a (JSON) decoded hash based on the @passon hash,
-
# which looks like this:
-
# { "id" => "packet.products[0].attributes.id",
-
# "quantity" => "packet.products[0].attributes.quantity"
-
# }
-
# The "id" and "quantity" are the new keys for the return data;
-
# packet.products[0].attributes.id will look at the value of the id key
-
# in the attributes hash in the 0th element of the products array in the
-
# packet hash.
-
def pick_out_passon(hash_data)
-
return {} unless @passon
-
returnhash = {}
-
nh = hash_data.dup
-
@passon.each do |newkey,part_str|
-
parts = part_str.split(".").reverse
-
while (part = parts.pop) do
-
m = part.match(/\[(\d+)\]/)
-
index = nil
-
if m
-
index = m[1].to_i
-
part.gsub!(/\[#{m[0]}\]/,'')
-
end
-
nh = nh.values_at(part).first
-
nh = nh.at(index) if index
-
end
-
returnhash.merge!({ newkey=> nh})
-
nh = hash_data.dup
-
end
-
returnhash
-
end
What's it do? It does magic!
I'll step through it...
Looks for @passon instance variable and doesn't do anything useful unless it exists.
Duplicate the input hash because the process done is destructive to it and we may need to reuse it.
For each new hash key and "hpath" pair from @passon split up the hpath into its parts and reverse it so Array#pop will work in the while loop to get the next first part to try.
Since each part of the hpath can examine an Array by index it has to be checked for and the index removed from the part (and saved).
Next, investigate the copy of the hash_data, nh by the computed key; if the value in the hash was an Array use the index to get the desired value. Then compute the next part!
Once we're out of parts stuff the new key and data into the returnhash and keep going til there's no more @passon pairs.
And thus some fun code was written.