I've recently been looking at reporting in OpenNMS and it seems that some of the reports require date ranges to be specified in unix time. Now, I don't know about you, but my mental ability to translate "April 26, 2011 15:00 UTC" to 1303830000 is sadly lacking. So, here are some useful commands to convert from unix time to date and vice versa:
Date to Unix time:
# current timestamp
date +%s
# specific timestamp
date -d '2011-04-26 15:00:00' +%s
# same thing but UTC
date -u +%s
date -u -d '2011-04-26 15:00:00' +%s
Unix time to date:
date -d @1303826400
# same thing but UTC
date -u -d @1303826400
Posted by Robin Bowes on April 27, 2011 at 11:27 am under Uncategorized.
Tags: date conversion, shell
1 Comment.
I ran into an odd issue today – my firewall build script was failing on our account master node.
It turns out that I was trying to use a chain name in iptables that exceeded the maximum length allowed. I wanted to use "REMOTE_ACCOUNT_SLAV ES_ASHEVILLE" (31 chars) and the limit is 30 chars.
You can see this in /usr/include/linux/netfilter_ipv4/ip_tables.h and /usr/include/linux/netfilter/x_tables.h:
/usr/include/linux/netfilter_ipv4/ip_tables.h
22:#define IPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
/usr/include/linux/netfilter/x_tables.h
4:#define XT_FUNCTION_MAXNAMELEN 30
This was on CentOS 5.6.
Posted by Robin Bowes on April 15, 2011 at 2:44 pm under Uncategorized.
Tags: iptables, linux
Comment on this post.
Having grown up with CVS then moved on to svn, I find git amazingly powerful. However, I don't use it enough to learn some of the more powerful features. This is just a post to document a couple of useful things I learned recently.
I was working on a project on github, adding a missing command-line option. But, while editing, I got carried away and made a load of additional trivial changes, cleaning up the man page text, making capitalisation consistent, etc. All good stuff, but I didn't want to commit both sets of changes in the same commit.
What I needed to do was to select which changes to commit. The command to do that is:
git add --patch
To show the changes that have been added to the staging area, ie. those that will be commited:
git diff --cached
If you mistakenly add a change and want to remove it from the staging area:
git reset --patch
Finally, commit the change:
git commit
Optionally, push the change back to github:
git push origin master
Nifty stuff.
Posted by Robin Bowes on April 8, 2011 at 11:07 am under Uncategorized.
Tags: git
Comment on this post.
I'm sure we've all seen this message from time to time when using puppet with exported resources:
Error 400 on SERVER: Exported resource Sshkey[foo] cannot override local resource on node bar.example.com
It's actually pretty easy to fix. Simply delete the exported resource for node foo.
Assuming you are using MySQL for your DB, something like this will do the trick:
mysql -e "delete from resources where restype like 'sshkey' and exported=1 and host_id = (select id from hosts where name 'foo')" puppet
Posted by Robin Bowes on February 11, 2011 at 8:10 pm under Uncategorized.
Tags: exported resource, mysql, puppet
3 Comments.
We sometimes see problems updating our Dell machines to the latest firmware, ie. update_firmware -y fails:
Running updates...
- Installing dell_dup_componentid_00159 - 1.4.7Installation failed for
package: dell_dup_componentid_00159 - 1.4.7
aborting update...
The error message from the low-level command was:
Could not parse output, bad xml for package: dell_dup_componentid_00159
Dell have been unable to tell me why this is, or provide a fix or workaround.
Here's what I did to get the firmware installed:
Continue reading ‘Updating Dell firmware when update_firmware fails’ »
Posted by Robin Bowes on November 10, 2010 at 10:31 am under Uncategorized.
Tags: dell, firmware, update
9 Comments.
I have a NexentaStor-based NAS device on my home network. It has 10 x 500GB SATA Drives in a raidz2 configuration giving me approx 4TB of usable storage.
I don't have many users at home (basically, just me!) so I don't bother with any central authentication mechanism – I simply make sure that use I the same login (robin) across all servers, and on unix/linux servers I make sure the UID is the same (10000).
When a user is added to NexentaStor, it is allocated the next available UID beginning at 1001 (1000 is allocated to the admin user). For the robin login, I need this to be 10000.
Not a problem – simply drop to a bash shell on the NAS and use vipw to change the UID of the login.
The bit I *always* forget is that the CIFS server uses a different passwd file (/var/smb/smbpasswd) and it is necessary to change the UID in that file too.
Posted by Robin Bowes on October 25, 2010 at 10:47 pm under Uncategorized.
Tags: CIFS, NexentaStor, OpenSolaris
Comment on this post.
We currently deploy our app code to around 50 nodes using capistrano. We use the "copy" deployment method, ie. the code is checked out of svn onto the local deployment node, rolled into a tarball, then copied out to each target node where it is unrolled into a release dir before the final symlink is put in place.
As you might imagine, copying to 50 nodes generates quite a bit of traffic, and it takes ~5 mins to do a full deploy.
I was reading this interesting link today; one bullet in particular jumped out at me:
- "… the few hundred MB binary gets rapidly pushed bia [sic] bit torrent."
Now that's an interesting idea – I wonder if I can knock up something in capistrano that deploys using bittorrent?
Posted by Robin Bowes on October 1, 2010 at 10:45 am under Uncategorized.
Tags: bittorrent, capistrano, deployment
2 Comments.
I wanted to install a Fedora 13 machine as a paravirtual domu guest on our CentOS 5.5, xen 3.4.2 host. I also wanted to provision it using koan/cobbler. I ran into a few problems along the way, but I got there in the end!
Continue reading ‘Fedora 13 as a domu guest with xen 3.4.2 on CentOS 5.5’ »
Posted by Robin Bowes on September 1, 2010 at 5:57 pm under Uncategorized.
Tags: centos, fedora, linux, xen
Comment on this post.
Dell distributes its OMSA software in RPM packages and even has a yum repo available so you'd think that updating to the next version would be as simple as yum update, right? Wrong!
You have to remove the old version first, and then install the new version. Oh, and you also need to stop the Dell services, restart ipmi, then restart the Dell services.
Something like this:
yum -y remove srvadmin-* \
&& rm -Rf /opt/dell \
&& yum -y install srvadmin-all dell_ft_install \
&& srvadmin-services.sh stop \
&& service ipmi restart \
&& srvadmin-services.sh start
Posted by Robin Bowes on August 31, 2010 at 1:08 pm under Uncategorized.
Tags: centos, dell, omsa
1 Comment.
Some kind soul on #bash on Freenode recently pointed me at this excellent document:
http://mywiki.wooledge.org/BashPitfalls
(I ran into #20, in case you're wondering)
Posted by Robin Bowes on June 24, 2010 at 2:00 pm under Uncategorized.
Tags: bash, shell scripts
Comment on this post.