Thursday, December 1, 2016

HowTo: Restore a GridScaler GPFS Client Node after Reinstalling the Node

I ran into this issue after reinstalling several compute nodes on our cluster shortly after bringing our new DDN GridScaler GPFS storage cluster online.
$ sudo mmstartup -N c0040
Fri Dec  2 03:36:03 UTC 2016: mmstartup: Starting GPFS ...
c0040:  mmremote: determineMode: Missing file /var/mmfs/gen/mmsdrfs.
c0040:  mmremote: This node does not belong to a GPFS cluster.
mmstartup: Command failed. Examine previous error messages to determine cause.

One method I discovered online was to take the affected node off of the network (or reboot it), remove it from the GPFS cluster, once it's back on the network (or fully rebooted), add it back, license it and start it.

Later I was introduced to the mmsdrrestore command (portion of the man file below:
mmsdrrestore command

Restores the latest GPFS system files on the specified nodes.

Synopsis

mmsdrrestore [-p NodeName] [-F mmsdrfsFile] [-R remoteFileCopyCommand]
             [-a | -N {Node[,Node...] | NodeFile | NodeClass}]

Availability

Available on all IBM Spectrum Scale editions.

Description

The mmsdrrestore command is intended for use by experienced
system administrators.

Use the mmsdrrestore command to restore the latest GPFS
system files on the specified nodes. If no nodes are specified,
the command restores the configuration information only on the
node on which is it run. If the local GPFS configuration file is
missing, the file that is specified with the -F option from
the node that is specified with the -p option is used
instead. This command works best when used with the
mmsdrbackup user exit. See the following IBM Spectrum
Scale: Administration and Programming Reference topic:
mmsdrbackup user exit.

...

Here's an example of using the command to restore the configuration to node c0040 using primary server gs0 (i.e. one of the NSD servers)
$ sudo mmsdrrestore -p gs0 -N c0040
Fri Dec  2 03:47:06 UTC 2016: mmsdrrestore: Processing node gs0
Fri Dec  2 03:47:08 UTC 2016: mmsdrrestore: Processing node c0040
mmsdrrestore: Command successfully completed

Finally, start GPFS on the client (which also mounts the file system(s) if configured to do so
$ sudo mmstartup -N c0040

Monday, August 22, 2016

Dell OMSA 8.3 on CentOS 7.2 "Error! Chassis info setting unavailable on this system."

After installing Dell OMSA 8.3 on a new PowerEdge 730xd running CentOS 7.2 x86_64, the omreport chassis info command reports the following (after starting the services):

# omreport chassis info

Error! Chassis info setting unavailable on this system.
First, the solution (Zurd on the mailing list pointed me here: http://lists.us.dell.com/pipermail/linux-poweredge/2016-August/050692.html) followed by the full ticket I sent to the Dell linux-poweredge mailing list.

The solution for CentOS users (and possibly other non-supported distros) is to stop the services, make the following change, then restart the services
--- /opt/dell/srvadmin/etc/srvadmin-storage/stsvc.ini.orig 2016-08-22 21:28:32.079580254 -0500
+++ /opt/dell/srvadmin/etc/srvadmin-storage/stsvc.ini 2016-08-22 21:20:32.374317823 -0500
@@ -116,7 +116,7 @@
 vil4=dsm_sm_sasvil
 vil5=dsm_sm_sasenclvil
 vil6=dsm_sm_swrvil
-vil7=dsm_sm_psrvil
+; vil7=dsm_sm_psrvil
 vil8=dsm_sm_rnavil

 [SSDSmartInterval]
Now on to the full details of the issue:
  1. Install Dell OMSA 8.3
  2. # wget -q -O - http://linux.dell.com/repo/hardware/dsu/bootstrap.cgi | bash
    # yum clean all
    # yum -y install kernel-devel kernel-headers gcc dell-system-update
    # yum -y install srvadmin-all
  3. Next check the status of the services (not started)
    # srvadmin-services.sh status
    dell_rbu (module) is stopped
    ipmi driver is running
    dsm_sa_datamgrd is stopped
    dsm_sa_eventmgrd is stopped
    dsm_sa_snmpd is stopped
    ● dsm_om_shrsvc.service - LSB: DSM OM Shared Services
       Loaded: loaded (/etc/rc.d/init.d/dsm_om_shrsvc)
       Active: inactive (dead)
         Docs: man:systemd-sysv-generator(8)
     
    Aug 22 20:43:08 r730xd-srv01.local systemd[1]: Starting LSB: DSM OM Shared Services...
    Aug 22 20:43:08 r730xd-srv01.local dsm_om_shrsvc[5144]: [47B blob data]
    Aug 22 20:43:08 r730xd-srv01.local systemd[1]: Started LSB: DSM OM Shared Services.
    Aug 22 20:43:08 r730xd-srv01.local dsm_om_shrsvc[5144]: tput: No value for $TERM and no -T specified
    Aug 22 20:45:55 r730xd-srv01.local systemd[1]: Stopping LSB: DSM OM Shared Services...
    Aug 22 20:45:55 r730xd-srv01.local dsm_om_shrsvc[8804]: [52B blob data]
    Aug 22 20:45:55 r730xd-srv01.local systemd[1]: Stopped LSB: DSM OM Shared Services.
    Aug 22 20:46:28 r730xd-srv01.local systemd[1]: Stopped LSB: DSM OM Shared Services.
    ● dsm_om_connsvc.service - LSB: DSM OM Connection Service
       Loaded: loaded (/etc/rc.d/init.d/dsm_om_connsvc)
       Active: inactive (dead)
         Docs: man:systemd-sysv-generator(8)
     
    Aug 22 20:43:08 r730xd-srv01.local systemd[1]: Starting LSB: DSM OM Connection Service...
    Aug 22 20:43:08 r730xd-srv01.local dsm_om_connsvc[5145]: [50B blob data]
    Aug 22 20:43:08 r730xd-srv01.local systemd[1]: Started LSB: DSM OM Connection Service.
    Aug 22 20:45:55 r730xd-srv01.local systemd[1]: Stopping LSB: DSM OM Connection Service...
    Aug 22 20:46:02 r730xd-srv01.local dsm_om_connsvc[8844]: [55B blob data]
    Aug 22 20:46:02 r730xd-srv01.local systemd[1]: Stopped LSB: DSM OM Connection Service.
    Aug 22 20:46:29 r730xd-srv01.local systemd[1]: Stopped LSB: DSM OM Connection Service.
  4. Start the services
    # srvadmin-services.sh start
    Starting instsvcdrv (via systemctl):                       [  OK  ]
    Starting dataeng (via systemctl):                          [  OK  ]
    Starting dsm_om_shrsvc (via systemctl):                    [  OK  ]
    Starting dsm_om_connsvc (via systemctl):                   [  OK  ]
  5. Try running the chassis info command
    # omreport chassis info
    Error! Chassis info setting unavailable on this system.
     
    # omreport about
    Product name : Dell OpenManage Server Administrator
    Version      : 8.3.0
    Copyright    : Copyright (C) Dell Inc. 1995-2015 All rights reserved.
    Company      : Dell Inc.
  6. The following are the rpms installed via yum
    # rpm -qa | grep srvadmin
    srvadmin-xmlsup-8.3.0-1908.9058.el7.x86_64
    srvadmin-omacore-8.3.0-1908.9058.el7.x86_64
    srvadmin-server-snmp-8.3.0-1908.9058.el7.x86_64
    srvadmin-oslog-8.3.0-1908.9058.el7.x86_64
    srvadmin-idrac-vmcli-8.3.0-1908.9058.el7.x86_64
    srvadmin-storageservices-snmp-8.3.0-1908.9058.el7.x86_64
    srvadmin-smcommon-8.3.0-1908.9058.el7.x86_64
    srvadmin-omcommon-8.3.0-1908.9058.el7.x86_64
    srvadmin-smweb-8.3.0-1908.9058.el7.x86_64
    srvadmin-racsvc-8.3.0-1908.9058.el7.x86_64
    srvadmin-nvme-8.3.0-1908.9058.el7.x86_64
    srvadmin-storage-cli-8.3.0-1908.9058.el7.x86_64
    srvadmin-storageservices-8.3.0-1908.9058.el7.x86_64
    srvadmin-omilcore-8.3.0-1908.9058.el7.x86_64
    srvadmin-racadm4-8.3.0-1908.9058.el7.x86_64
    srvadmin-isvc-8.3.0-1908.9058.el7.x86_64
    srvadmin-argtable2-8.3.0-1908.9058.el7.x86_64
    srvadmin-racadm5-8.3.0-1908.9058.el7.x86_64
    srvadmin-cm-8.3.0-1908.9058.el7.x86_64
    srvadmin-isvc-snmp-8.3.0-1908.9058.el7.x86_64
    srvadmin-rac4-populator-8.3.0-1908.9058.el7.x86_64
    srvadmin-tomcat-8.3.0-1908.9058.el7.x86_64
    srvadmin-itunnelprovider-8.3.0-1908.9058.el7.x86_64
    srvadmin-storelib-sysfs-8.3.0-1908.9058.el7.x86_64
    srvadmin-storageservices-cli-8.3.0-1908.9058.el7.x86_64
    srvadmin-deng-8.3.0-1908.9058.el7.x86_64
    srvadmin-rac-components-8.3.0-1908.9058.el7.x86_64
    srvadmin-ominst-8.3.0-1908.9058.el7.x86_64
    srvadmin-sysfsutils-8.3.0-1908.9058.el7.x86_64
    srvadmin-rac5-8.3.0-1908.9058.el7.x86_64
    srvadmin-base-8.3.0-1908.9058.el7.x86_64
    srvadmin-idrac-ivmcli-8.3.0-1908.9058.el7.x86_64
    srvadmin-rac4-8.3.0-1908.9058.el7.x86_64
    srvadmin-webserver-8.3.0-1908.9058.el7.x86_64
    srvadmin-standardAgent-8.3.0-1908.9058.el7.x86_64
    srvadmin-storelib-8.3.0-1908.9058.el7.x86_64
    srvadmin-storage-snmp-8.3.0-1908.9058.el7.x86_64
    srvadmin-omacs-8.3.0-1908.9058.el7.x86_64
    srvadmin-racdrsc-8.3.0-1908.9058.el7.x86_64
    srvadmin-idracadm-8.3.0-1908.9058.el7.x86_64
    srvadmin-idrac-snmp-8.3.0-1908.9058.el7.x86_64
    srvadmin-realssd-8.3.0-1908.9058.el7.x86_64
    srvadmin-storage-8.3.0-1908.9058.el7.x86_64
    srvadmin-all-8.3.0-1908.9058.el7.x86_64
    srvadmin-hapi-8.3.0-1908.9058.el7.x86_64
    srvadmin-deng-snmp-8.3.0-1908.9058.el7.x86_64
    srvadmin-server-cli-8.3.0-1908.9058.el7.x86_64
    srvadmin-jre-8.3.0-1908.9058.el7.x86_64
    srvadmin-idrac-8.3.0-1908.9058.el7.x86_64

Wednesday, June 22, 2016

How To: Enable PXE and Configure Boot Order Via Dell RACADM Command

Our HPC cluster was lucky enough double in compute capacity recently. Whoop! The new hardware brought with it some significant changes in rack layout and networking fabric. The compute nodes are a combination of Dell R630, DSS1500 and R730 (for GPU K80 and Intel Phi nodes).

The existing core 10GbE CAT6 based fabric (made up of Dell Force10 S4820T) was replaced by a Dell Force10 Z9500 and fiber (Z9500 has 132 QSFP+ 40GbE ports that can in turn be broken out into 528 10GbE SFP+ ports).

Physical changes aside (like wiring, top of rack 40GbE to 10GbE breakout panels, etc...), the above meant we had to change the primary boot device from the addon 10GbE CAT6 based NIC to the onboard fiber 10GbE NIC (CentOS 7 sees this interface as eno1).

This required two changes at the system BIOS / nic hardware config level
  • Enable PXE boot on the NIC
  • Modify the BIOS boot order
One method to make these two changes in bulk is to use the Dell OpenManage command line tool racadm, which was what we decided to use.

The following are notes I took while working on a subset of the compute nodes.

Enable PXE on the fiber interface

The first step is to identify the names of the network interfaces. I queried a single node to get the full list of interfaces followed by querying the specific interface (.1) just for grins to see what settings were available. In this case the first integrated port is referenced as NIC.nicconfig.1 and NIC.Integrated.1-1-1
# Get list of Nics
racadm -r 172.16.3.48 -u root -p xxxxxxx get nic.nicconfig

NIC.nicconfig.1 [Key=NIC.Integrated.1-1-1#nicconfig]
NIC.nicconfig.2 [Key=NIC.Integrated.1-2-1#nicconfig]
NIC.nicconfig.3 [Key=NIC.Integrated.1-3-1#nicconfig]
NIC.nicconfig.4 [Key=NIC.Integrated.1-4-1#nicconfig]
NIC.nicconfig.5 [Key=NIC.Slot.3-1-1#nicconfig]
NIC.nicconfig.6 [Key=NIC.Slot.3-2-1#nicconfig]

racadm -r 172.16.3.48 -u root -p xxxxxxx get nic.nicconfig.1

[Key=NIC.Integrated.1-1-1#nicconfig]
LegacyBootProto=NONE
#LnkSpeed=AutoNeg
NumberVFAdvertised=64
VLanId=0
WakeOnLan=Disabled

 
Next we can enable PXE boot on NIC.Integrated.1-1-1 for the set of nodes. In order for the change to take affect you have to create a job followed by a reboot.
for n in {48..10} ; do
  ip=172.16.3.${n}
  echo "IP: $ip - configuring nic.nicconfig.1.legacybootproto PXE"
  # Get Nic config for integrated port 1
  racadm -r $ip -u root -p xxxxxxx get nic.nicconfig.1 | grep Legacy
  # Set to PXE
  racadm -r $ip -u root -p xxxxxxx set nic.nicconfig.1.legacybootproto PXE
  # Verify it's set to PXE (pending)
  racadm -r $ip -u root -p xxxxxxx get nic.nicconfig.1 | grep Legacy
  # Create a job to enable the changes following the reboot
  racadm -r $ip -u root -p xxxxxxx jobqueue create NIC.Integrated.1-1-1
  # reboot so that the configur job will execute
  ipmitool -I lanplus -H $ip -U root -P xxxxxxx chassis power reset
done 

Configure the BIOS boot order

Now that the NIC has PXE enabled and the changes have been applied, the boot order can be modified. If this fails for a node it either means that the job failed to run in the previous step, start debugging.
for n in {48..10} ; do
  ip=172.16.3.${n}
  echo "IP: $ip - configuring BIOS.biosbootsettings.BootSeq NIC.Integrated.1-1-1,...."
  # Get Bios Boot sequence
  racadm -r $ip -u root -p xxxxxxx get BIOS.biosbootsettings.BootSeq | grep BootSeq
  # Set Bios boot sequence
  racadm -r $ip -u root -p xxxxxxx set BIOS.biosbootsettings.BootSeq NIC.Integrated.1-1-1,NIC.Integrated.1-3-1,NIC.Slot.3-1-1,Optical.SATAEmbedded.J-1,HardDisk.List.1-1
  # Create a BIOS reboot job so that the boot order changes are applied
  racadm -r $ip -u root -p xxxxxxx jobqueue create BIOS.Setup.1-1 -r pwrcycle -s TIME_NOW -e TIME_NA
done
 

Modify the switch and port locations in BrightCM

We use Bright Computing Cluster Manager for HPC to manage our HPC nodes (this recently replaced Rocks in our environment). Within BrightCM we had to modify the boot interface for the set of compute nodes. BrightCM provides excellent CLI support, hooray!
cmsh -c "device foreach -n node0001..node0039 (interfaces; use bootif; set networkdevicename eno1); commit"
 

Update the switch port locations in BrightCM

BrightCM keeps track of the switch port to node NIC mapping. One reason for this is to prevent accidentally imprinting the wrong image on nodes that got swapped (i.e. you remove two nodes for service and insert them back into the rack in the wrong location).
First I had to identify the new port number for a node, I chose the node that would be last in sequence on the switch. This happened to show up in BrightCM as port 171. I found this by PXE booting the compute node, once it comes up BrightCM notices a discrepancy and displays an interface that allows you to manually address the issue, something akin to "node0039 should be on switch XXX port ## but it's showing up on switch z9500-r05-03-38 port 171" blah blah blah.
Instead of manually addressing the issue, it can be done via the CLI in bulk (assuming there's a sequence). Each of our nodes have two NICs wired to the Z9500 (node0039 would be on ports 171 and 172), thus in the code below I decrement by 2 ports for each node's boot device.
port=171
for n in {39..26} ; do
  let port=${port}-2
  cmsh -c "device; set node00${n} ethernetswitch z9500-r05-03-38:${port}; commit ;"
done
unset port
 

Friday, August 7, 2015

How To: Clear Dell iDRAC Job Queue

I'm in the process of deploying 41 new Dell R630 PowerEdge servers in our HPC environment. To help manage the hardware I'm using a new tool (to us anyways), Dell OpenManage Essentials.

OME requires a Microsoft Windows OS, luckily (since we are a Linux shop) it's a snap to install Windows Server 2012 in KVM.

Some of the functionality provided by OME:

  • Reporting and alerting
  • Firmware upgrades
  • Configuration deployment (BIOS settings, iDRAC, RAID, etc...)
  • Bare metal provisioning
While OME is free, some of the features require a license. I've only been using OME for a couple of days so I haven't had a chance to test all of its features, but I have found that configuration requires a license (ex: ability to push a configuration template out to a node(s)). Firmware upgrades and reporting do not require a license.

The first task to be handled by OME, firmware upgrades on all 41 nodes. My initial attempts failed. Reading through the logs revealed that the remote clients couldn't reach TCP port 1278 on the OME server. Firmware upgrades started deploying after opening that TCP 1278 in the Windows firewall.

Each server had a long list of upgrades including BIOS, iDRAC, and the 6 network cards (mix of 10Gbit and 1Gbit). All of the firmware deployed successfully, with the exception of the Ethernet cards. Grrr, back to the scanning the logs.


Results:  
 Downloading Packages.
 Calling InstallFromUri method to Download packages to the iDRAC 
 There are some pending reboot jobs on the iDRAC that maybe block updating the system. It is recommended that you clear all the jobs before updating
 Downloading Package: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE onto the iDRAC 
 Package download has successfully started and the Job ID is JID_388846411941
 The URI given to the iDRAC to download from: http://192.168.2.69:1278/install_packages/Packages/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE

Ok, but how do you do this? I didn't see any native way to do this from within OME, so on to Google.

Thanks to this post on Jon Munday's blog, I was able to clear the pending jobs with a little PowerShell for loop action to hit all nodes.

The following command displays the job queue for the range of compute nodes (192.16.2.10 thru 50)

For ($i=10; $i -lt 51; $i++) { winrm e cimv2/root/dcim/DCIM_LifecycleJob -u:$USER -p:$PASSWORD -SkipCNcheck -SkipCAcheck -r:https://192.168.2.$i/wsman -auth:basic -encoding:utf-8 }
 
The next command clears the queue. Sorry for the long single line, I don't know if PowerShell supports spanning a command across multiple lines like I can do in Bash:

For ($i=10; $i -lt 51; $i++) { winrm invoke DeleteJobQueue "cimv2/root/dcim/DCIM_JobService?CreationClassName=DCIM_JobService+Name=JobService+SystemName=Idrac+SystemCreationClassName=DCIM_ComputerSystem" '@{JobID="JID_CLEARALL"}' -r:https://192.168.2.$i/wsman -u:$USER -p:$PASSWORD -SkipCNCheck -SkipCACheck -auth:basic -encoding:utf-8 -format:pretty }
 


Friday, May 29, 2015

A Linux User's First Time on a Mac

I'm in the process of switching from a Dell XPS 13 (Project Sputnik) ultrabook to a Macbook Pro 13 (Broadwell i7). The battery life on my current laptop was horrible, an hour of real world use with the screen dimmed and killing running applications like Scrooge. Unfortunately, the XPS solders the battery onboard, so it's not easily replaced (if at all?). It still functions great when near power.

You may be thinking, why would you do such a thing if you are a Linux user?

For starters, the specs for the Macbook Pro 13 (Spring 2015) are better than the XPS for a similar cost (how much is of course open to interpretation):
  • Intel 3.1 GHz Core i7-5557U vs  3.0 GHz Core i7-5500U Processor
  • 16 GB (optional) vs 8 GB RAM
  • Intel Iris 6100 vs Intel HD Graphics 5500
  • PCIe based SSD vs SATA
  • Non-touch Retina Display vs touch UltraSharp QHD+ (personally I don't see the value yet in having a touch screen on a Linux laptop, especially considering the screen doesn't completely fold over)
  • Magsafe Power Adapter
  • Proven battery life
I do most of my work via SSH to the Linux systems, so the workstation doesn't have to be Linux, although it makes life much less painful. I figured, what the heck, let's try a BSD like system that has a history of awesome battery life.

Without further ado, here are some of my experiences using a Mac and OSX for the first time as a Linux user.

Useful Applications

  • Oh My Zsh - Trying out Zsh shell as an alternative for Bash for the first time, pretty darn cool.
  • Caffeine - Useful for temporarily preventing the laptop from sleeping (don't kill my SSH or VPN connections, dangit!
  • iTerm2 - Really nice terminal replacement for the builtin OSX terminal. Ton's of features like built in Tmux, search, transparent background, it's own built in auto completion (Cmd ;), etc... This part was what got me searching for a new terminal in the first place "Coming from a Unix world? You'll feel at home with focus follows mouse, copy on select, middle button paste, and keyboard shortcuts to avoid mousing."
  • MagicPrefs - This app lets you configure middle mouse paste functionality on the trackpad (set mine to three finger press)
  • XChat Azure - Excellent IRC client
  • TextWrangler - Extremely nice graphical script editor
  • Microsoft Office 2016 Preview - Because I need it Office work

Graphical Text Editor

I use vi/vim extensively on Linux and now on my Macbook Pro. That said, I do like to edit in a GUI text editor as well. After a good bit of searching around, TextWrangler is the (free) one I've been most happy using.

The way I understand it, TextWrangler is sort of the little brother to the professional product BBEdit, which adds "its extensive professional feature set including Web authoring capabilities and software development tools". I primarily work with Ruby (shell scripts, not Rails), Perl, Bash, Puppet and other system management type scripting, TextWrangler works very well for these.

One thing I found missing that I use regularly in other editors is the ability to duplicate a line without the cumbersome highlight, copy, paste. Many GUI editors provide this ability using a shortcut like Ctrl + d, or in vi, yy p (yank yank paste).

After searching around in the keyboard shortcuts a Google search led me to this post which mentioned creating an "AppleScript" to accomplish the task. What tha?

While the code did work, it left both the original and new lines highlighted, which was a bit annoying. I decided I wanted the cursor to remain where it originally was located. By the way, in TextWrangler, the "cursor" is called the "insertion point" both in the documentation and in AppleScript.

So, here's my updated script (my changes are the single lines following each comment):

tell application "TextWrangler"
  tell window 1
    # Get the current position for the cursor so we can pace it back
    set cursorLoc to characterOffset of selection
    select line the (startLine of the selection)
    copy (contents of the selection) as text to myText
    set the contents of the selection to myText & myText
    # Move the cursor back to the first column with a character
    select insertion point before character cursorLoc
  end tell
end tell  

I searched all over the place to get a hint how to place the cursor back in it's original location. As you can see, AppleScript isn't syntactically like Ruby, Perl, Java, etc... It's pretty funky and totally dynamic based on the application being scripted. TextWrangler provides a dictionary, but I didn't find they contents very helpful.

I finally stumbled on this post that mentions using "characterOffset of selection". Voila! All in all, it's pretty darn cool that the OS provides a simple way to extend the functionality of a GUI app.

Create the script in the AppleScript Editor (either launch it from Spotlight Search (Command Space) or click the script menu next to Help in TextWrangler and "Open Script Editor".

Copy and paste the code above, then save it in the directory
"~/Library/Application\ Support/TextWrangler/Scripts"
as something like DuplicateLine.scpt (the extension will get added automatically).

Next, restart TextWrangler and go to Window -> Palettes -> Scripts, click on DuplicateLine in the list and click Set Shortcut. Set it to whatever, I set mine to Ctrl D. This shortcut is already set to delete line, so I altered that shortcut in preferences to Shift Ctrl D.


Wednesday, July 9, 2014

Using Check_Openmanage with Check_MK via WATO

In an older post I described the steps to integrate check_openmanage Nagios plugin with check_mk. This approach required manually editing the etc/check_mk/main.mk file to configure the extra_nagios_conf and legacy_checks.

This updated guide uses the check_mk WATO (Web Administration Tool) to integrate the check_openmanage check using a feature called "Active Checks".

Here's the guide, hope it helps:

Environment:

Install Check_openmanage

Unless otherwise specified all paths are relative to the site owners home (ex: /opt/omd/sites/mysite)
  1. Make sure your dell servers had the following SNMP packages installed prior to installing OMSA (if not, it's easy to 'yum remove srvadmin-\*' 'yum install srvadmin-all': net-snmp, net-snmp-libs, net-snmp-utils
    • Start the OMSA services 'srvadmin-services.sh start' and then check 'srvadmin-services.sh status' to verify that the snmpd component is running
    • Ensure that snmpd is running and configured
    • Configure the firewall to allow access from your OMD server to udp port 161
  2. change users on your OMD server to the site user: $ su - mysite
  3. Download the latest check_openmanage from http://folk.uio.no/trondham/software/check_openmanage.html to ~/tmp and extract
  4. copy the check_openmanage script to local/lib/nagios/plugins (this defaults to $USER2$ in your commands)
    
    $ cp tmp/check_openmanage-3.7.11/check_openmanage local/lib/nagios/plugins/
    $ chmod +x local/lib/nagios/plugins/check_openmanage
    
  5. copy the PNP4Nagios template
    
    $ cp tmp/check_openmanage-3.7.11/check_openmanage.php etc/pnp4nagios/templates/
    
  6. Test check_openmanage to see that it can successfully query a node
    
    local/lib/nagios/plugins/check_openmanage -H dell-r720xd-01 -p -C MySecretCommunity
    
    OK - System: 'PowerEdge R720xd', SN: 'XXXXXX1', 24 GB ram (6 dimms), 2 logical drives, 14 physical drives|T0_System_Board_Inlet=21C;42;47 T1_System_Board_Exhaust=30C;70;75 T2_CPU1=48C;86;91 T3_CPU2=39C;86;91 W2_System_Board_Pwr_Consumption=126W;0;0 A0_PS1_Current_1=0.6A;0;0 A1_PS2_Current_2=0.2A;0;0 V25_PS1_Voltage_1=240V;0;0 V26_PS2_Voltage_2=240V;0;0 F0_System_Board_Fan1=2280rpm;0;0 F1_System_Board_Fan2=2280rpm;0;0 F2_System_Board_Fan3=2280rpm;0;0 F3_System_Board_Fan4=3000rpm;0;0 F4_System_Board_Fan5=3600rpm;0;0 F5_System_Board_Fan6=3480rpm;0;0
    
    

WATO Configuration

  1. Create a Host Group by clicking Host Groups under WATO - Configuration, click New Group (click save when done):
    • Name: omsa
    • Alias: Dell OpenManage
  2. Create a Host Tag by clicking Host Tags under WATO - Configuration, click New Tag Group (click save when done):
    • Internal ID: dellomsa
    • Topic: (leave empty)
    • Choices:
      • Tag ID: omsa
      • Description: Dell OpenManage
  3. Create a Active Check by clicking Host & Service Parameter under WATO - Configuration, click Active Checks, click Classical active and passive Nagios checks (create a new one, click save when done):
    • Folder: Main Directory
    • Host Tags: Select Dell OpenManage is set
    • Service Description: check_openmanage
    • Commmand Line: $USER2$/check_openmanage -H $HOSTADDRESS$ -p -C MySecretCommunity
    • Service Description: check_openmanage
    • Check Perfomance Data
  4. Add the omsa Host Tag to a host running OpenManage with SNMP configured by clicking Hosts under WATO - Configuration, and click the properties editor (pencil icon) for the host (click Save & go to Services when done):
    • Host tags: Dell OpenManage: check Dell OpenManage twice

On the Host services page you should see the new service at the bottom, example:
Custom checks (defined via rule)
Status  Checkplugin   Item              Service Description  Plugin output    
OK      custom        check_openmanage  check_openmanage     OK - System: 'PowerEdge R710', SN: 'XXXXXX1', 24 GB ram (6 dimms), 2 logical drives, 14 physical drives
Click Activate Missing services or Save manual check configuration. Activate the changes and you should start seeing the check within a few minutes and graphs after 10 minutes or so. Hope this helps, and comments are welcome.

Tuesday, June 24, 2014

Replace The Foreman Self Signed Certificate with a Trusted Certificate

I've installed a few Foreman servers to provide provisioning and configuration management (via Puppet). This document will cover the steps to replace the self signed certificate used for the web interface with a trusted certificate.

For those unfamiliar with Foreman and Puppet, here are snippet from both project pages (http://theforeman.org/learn_more.html and http://puppetlabs.com/puppet/what-is-puppet:

Foreman is an open source project that helps system administrators manage servers throughout their lifecycle, from provisioning and configuration to orchestration and monitoring. Using Puppet or Chef and Foreman's smart proxy architecture, you can easily automate repetitive tasks, quickly deploy applications, and proactively manage change, both on-premise with VMs and bare-metal or in the cloud.

Foreman provides comprehensive, interaction facilities including a web frontend, CLI and RESTful API which enables you to build higher level business logic on top of a solid foundation.
Puppet is IT automation software that defines and enforces the state of your infrastructure throughout your software development cycle. From provisioning and configuration to orchestration and reporting, from initial code development through production release and updates, Puppet frees sysadmins from writing one-off, fragile scripts and other manual tasks. At the same time, Puppet ensures consistency and dependability across your infrastructure.

With Puppet, repetitive tasks are automated away, so sysadmins can quickly deploy business applications, scaling easily from tens of servers to thousands, both on-premise and in the cloud.

By default, the Puppet / Foreman server install uses Puppet's own internal CA for issuing SSL certificates. The Foreman install defaults to using the Puppet CA self signed cert for the web interface. The following steps will replace The Foreman's SSL certificate for the user web interface, but will leave the Puppet CA and SSL certs in place for Puppet related work.

I spent a bit of time trying to get this working, but each attempt resulted in a working web interface and broken Puppet master to client communications and Foreman proxy. Essentially, I was changing the SSL certificate entries in too many locations. Dominic on the #theforeman channel on FreeNode IRC directed me to this Google Groups thread that listed the short list of places to make the change. The following steps are based on that post.

  1. Create the SSL key and csr
    sudo su - 
    mkdir /root/Incommon-cert
    cd /root/Incommon-cert
    
    openssl req -out $(hostname)-2048.csr -new -newkey rsa:2048 -nodes -keyout $(hostname -f)-2048.key
  2. Copy the contents of the csr to the clipboard and use it to request an InCommon SSL certificate
  3. Once the cert is approved, download the following files to /root/Incommon-cert on the Puppet / Foreman server:
    • as X509 Certificate only, Base64 encoded
    • as X509 Intermediates/root only, Base64 encoded
  4. Rename the files so that we know these are InCommon files
    mv puppet.tld.blah.crt puppet.tld.blah-2048-incommon-cert.crt
    mv puppet.tld.blah_interm.crt puppet.tld.blah-2048-incommon-interm.crt
    chown root:root *.crt
  5. Copy the files to the appropriate directories
    cp puppet.tld.blah-2048.key /var/lib/puppet/ssl/private_keys/
    cp puppet.tld.blah-2048-incommon-cert.crt /var/lib/puppet/ssl/certs/
    cp puppet.tld.blah-2048-incommon-interm.crt /var/lib/puppet/ssl/certs/
    wget https://www.incommon.org/certificates/repository/incommon-ssl.ca-bundle -O /var/lib/puppet/ssl/certs/incommon-ssl.ca-bundle
  6. Set the appropriate permissions and SELinux configs for the key
    cd /var/lib/puppet/ssl/private_keys/
    chown puppet:puppet *.key
    chmod 640 *.key
    chcon -u system_u -r object_r -t puppet_var_lib_t *.key
    
    ls -lZ
    -rw-r-----. puppet puppet system_u:object_r:puppet_var_lib_t:s0 puppet.tld.blah-2048.key
    -rw-r-----. puppet puppet system_u:object_r:puppet_var_lib_t:s0 puppet.tld.blah.pem
  7. Set perms and SELinux for the certs
    cd /var/lib/puppet/ssl/certs/
    chown puppet:puppet *
    chcon -u system_u -r object_r -t puppet_var_lib_t *.crt
    
    ls -lZ
    -rw-r--r--. puppet puppet system_u:object_r:puppet_var_lib_t:s0 ca.pem
    -rw-r--r--. puppet puppet system_u:object_r:puppet_var_lib_t:s0 incommon-ssl.ca-bundle
    -rw-r--r--. puppet puppet system_u:object_r:puppet_var_lib_t:s0 puppet.tld.blah-2048-incommon-cert.crt
    -rw-r--r--. puppet puppet system_u:object_r:puppet_var_lib_t:s0 puppet.tld.blah-2048-incommon-interm.crt
    -rw-r--r--. puppet puppet system_u:object_r:puppet_var_lib_t:s0 puppet.tld.blah.pem
  8. Next edit the various config files
    • /etc/puppet/node.rb: Change the line :ssl_ca to use the new interm cert
      --- /etc/puppet/node.rb.orig 2014-03-24 17:48:09.215000045 -0500
      +++ /etc/puppet/node.rb 2014-06-24 10:24:51.049282905 -0500
      @@ -8,7 +8,8 @@
         :facts        => true,          # true/false to upload facts
         :timeout      => 10,
         # if CA is specified, remote Foreman host will be verified
      -  :ssl_ca       => "/var/lib/puppet/ssl/certs/ca.pem",      # e.g. /var/lib/puppet/ssl/certs/ca.pem
      +  #:ssl_ca       => "/var/lib/puppet/ssl/certs/ca.pem",      # e.g. /var/lib/puppet/ssl/certs/ca.pem
      +  :ssl_ca       => "/var/lib/puppet/ssl/certs/puppet.tld.blah-2048-incommon-interm.crt",      # e.g. /var/lib/puppet/ssl/certs/ca.pem
         # ssl_cert and key are required if require_ssl_puppetmasters is enabled in Foreman
         :ssl_cert     => "/var/lib/puppet/ssl/certs/puppet.tld.blah.pem",    # e.g. /var/lib/puppet/ssl/certs/FQDN.pem
         :ssl_key      => "/var/lib/puppet/ssl/private_keys/puppet.tld.blah.pem"      # e.g. /var/lib/puppet/ssl/private_keys/FQDN.pem
    • /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb: Change the foreman_ssl_ca = line to use the interm cert
      --- /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb.orig 2014-03-24 17:44:37.494000046 -0500
      +++ /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb 2014-06-24 10:28:54.497406986 -0500
      @@ -5,7 +5,8 @@
       # URL of your Foreman installation
       $foreman_url='https://puppet.tld.blah'
       # if CA is specified, remote Foreman host will be verified
      -$foreman_ssl_ca = "/var/lib/puppet/ssl/certs/ca.pem"
      +#$foreman_ssl_ca = "/var/lib/puppet/ssl/certs/ca.pem"
      +$foreman_ssl_ca = "/var/lib/puppet/ssl/certs/puppet.tld.blah-2048-incommon-interm.crt"
       # ssl_cert and key are required if require_ssl_puppetmasters is enabled in Foreman
       $foreman_ssl_cert = "/var/lib/puppet/ssl/certs/puppet.tld.blah.pem"
       $foreman_ssl_key = "/var/lib/puppet/ssl/private_keys/puppet.tld.blah.pem"
    • /etc/httpd/conf.d/05-foreman-ssl.conf: Change three lines SSLCertificateFile, SSLCertificateKeyFile and SSLCertificateChainFile to use the new cert, key and CA bundle respectively
      --- /etc/httpd/conf.d/05-foreman-ssl.conf.orig 2014-06-24 10:30:59.917531640 -0500
      +++ /etc/httpd/conf.d/05-foreman-ssl.conf 2014-06-24 10:32:36.318164714 -0500
      @@ -35,11 +35,18 @@
       
         ## SSL directives
         SSLEngine on
      -  SSLCertificateFile      /var/lib/puppet/ssl/certs/puppet.tld.blah.pem
      -  SSLCertificateKeyFile   /var/lib/puppet/ssl/private_keys/puppet.tld.blah.pem
      -  SSLCertificateChainFile /var/lib/puppet/ssl/certs/ca.pem
      +  SSLCertificateFile      "/var/lib/puppet/ssl/certs/puppet.tld.blah-2048-incommon-cert.crt"
      +  SSLCertificateKeyFile   "/var/lib/puppet/ssl/private_keys/puppet.tld.blah-2048.key"
      +  SSLCertificateChainFile "/var/lib/puppet/ssl/certs/incommon-ssl.ca-bundle"
         SSLCACertificatePath    /etc/pki/tls/certs
         SSLCACertificateFile    /var/lib/puppet/ssl/certs/ca.pem
      +
      +#  SSLCertificateFile      /var/lib/puppet/ssl/certs/puppet.tld.blah.pem
      +#  SSLCertificateKeyFile   /var/lib/puppet/ssl/private_keys/puppet.tld.blah.pem
      +#  SSLCertificateChainFile /var/lib/puppet/ssl/certs/ca.pem
      +#  SSLCACertificatePath    /etc/pki/tls/certs
      +#  SSLCACertificateFile    /var/lib/puppet/ssl/certs/ca.pem
      +
         SSLVerifyClient         optional
         SSLVerifyDepth          3
         SSLOptions +StdEnvVars
  9. Restart the services (foreman-proxy restart probably isn't necessary but may as well)
    service httpd restart
    service foreman-proxy restart

Wednesday, August 28, 2013

Fun with Bash :: Sums

I frequently find the need to sum up long lists of numbers from the Bash command shell. The following is a nice bit of code that sums up the bytes contained in a series of files and prints out the each sum in GB.

The current directory has files *-bytes.log that each contain a single column with a number of bytes on each row, example:

53824
247104
61776
53824
53824
53824
247104
53824
247104
542

The code contains an outer loop to iterate the files and an inner loop to process the contents of the files
for file in $(ls *-bytes.log); do
  sum=0;
  for num in $(cat $file); do
    let sum=$sum+$num;
  done
  echo "$sum/1024/1024/1024" | bc -l | xargs printf "$file %1.2f GB\n";
done

This is an alternative approach using an inner while loop to read the sums rather than cat'ing the file
for file in $(ls *-bytes.log); do
  sum=0;
  while read num; do
    let sum=$sum+$num;
  done < $file
  echo "$sum/1024/1024/1024" | bc -l | xargs printf "$file %1.2f GB\n";
done

Sample results
user1-bytes.log 3.81 GB
user2-bytes.log 4.75 GB
user3-bytes.log 1.40 GB
user4-bytes.log 2.03 GB
user5-bytes.log 5.01 GB
...

I've also found the following bit of code helpful in my $HOME/.bashrc to make quick calculations easy (this comes from a nixCraft Facebook post:

# nixCraft (on Facebook) calc recipe
# Usage: calc "10+2"
#   Pi:  calc "scale=10; 4*a(1)"
# Temperature: calc "30 * 1.8 + 32"
#              calc "(86 - 32)/1.8"
calc() { echo "$*" | bc -l; }

Thursday, June 13, 2013

Building GCC 4.8.1 on CentOS 5.9

References:

Build:

  1. Install packages for dependencies (readline-devel is needed for guile build, dejagnu is needed for gcc make check)
    sudo yum install readline readline-devel guile guile-devel dejagnu expect
    sudo yum -y install readline readline-devel guile guile-devel dejagnu expect
    
  2. Download and untar all the sources
    mkdir -p ~/sources/gcc
    cd ~/sources/gcc
    
    gccver=4.8.1
    gmpver=5.1.2
    mpfrver=3.1.2
    mpcver=1.0.1
    binutilsver=2.23.2
    libtoolver=2.4.2
    libunistringver=0.9.3
    libffiver=3.0.13
    gcver=7.2d
    autogenver=5.17.4
    guilever=2.0.9
    prefixroot=/share/apps/tools
    
    wget http://www.netgull.com/gcc/releases/gcc-4.8.1/gcc-${gccver}.tar.bz2
    wget ftp://ftp.gnu.org/gnu/gmp/gmp-${gmpver}.tar.bz2
    wget http://mpfr.loria.fr/mpfr-current/mpfr-${mpfrver}.tar.bz2
    wget http://www.multiprecision.org/mpc/download/mpc-${mpcver}.tar.gz
    wget http://ftp.gnu.org/gnu/binutils/binutils-${binutilsver}.tar.bz2
    wget http://mirror.sbb.rs/gnu/libtool/libtool-${libtoolver}.tar.gz
    wget http://ftp.gnu.org/gnu/libunistring/libunistring-${libunistringver}.tar.gz
    wget ftp://sourceware.org/pub/libffi/libffi-${libffiver}.tar.gz
    wget http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-${gcver}.tar.gz
    wget http://ftp.gnu.org/gnu/autogen/rel5.17.4/autogen-${autogenver}.tar.gz
    wget ftp://ftp.gnu.org/gnu/guile/guile-${guilever}.tar.gz
    
    for file in *.{gz,bz2}; do echo tar xf $file; done
    
    for dir in `find . -maxdepth 1 -type d | grep -v ^.$ | cut -d \/ -f2` ; do
      app=$(echo $dir | cut -f1 -d-);
      ver=$(echo $dir | cut -f2 -d-);
      mkdir -p ${prefixroot}/${app}/${ver} ;
    done
    
    mv gc-7.2 gc-7.2d
    
  3. Build gmp
    cd gmp-${gmpver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/gmp/${gmpver}
    make
    make check
    make install
    
    EXAMPLE OUTPUT
    ================================================
      Version:           GNU MP 5.1.2
      Host type:         coreisbr-unknown-linux-gnu
      ABI:               64
      Install prefix:    /share/apps/tools/gmp/5.1.2
      Compiler:          gcc -std=gnu99
      Static libraries:  yes
      Shared libraries:  yes
    
    
    Libraries have been installed in:
       /share/apps/gcc/gmp/5.1.2/lib
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    
    4. Build mpfr
    cd ../../mpfr-${mpfrver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/mpfr/${mpfrver} \
      --with-gmp=${prefixroot}/gmp/${gmpver}
    make
    make check
    make install
    
    EXAMPLE OUTPUT
    ================================================
    Libraries have been installed in:
       /share/apps/gcc/mpfr/3.1.2/lib
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    
  4. Build mpc
    cd ../../mpc-${mpcver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/mpc/${mpcver} \
      --with-gmp=${prefixroot}/gmp/${gmpver} \
      --with-mpfr=${prefixroot}/mpfr/${mpfrver}
    make
    make check
    make install
    
    EXAMPLE OUTPUT
    ================================================
    Libraries have been installed in:
       /share/apps/gcc/mpc/1.0.1/lib
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    
  5. Build Binutils
    cd ../../binutils-${binutilsver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/binutils/${binutilsver}
    make
    make check
    make install
    
  6. Build libtool (make check runs for quite a while, upwards of an hour. Runs 126 tests.)
    cd ../../libtool-${libtoolver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/libtool/${libtoolver}
    make
    make check
    make install
    
    EXAMPLE OUTPUT
    ================================================
    ## ------------- ##
    ## Test results. ##
    ## ------------- ##
    
    105 tests behaved as expected.
    21 tests were skipped.
    
  7. Build libunistring
    cd ../../libunistring-${libunistringver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/libunistring/${libunistringver}
    make
    make check
    make install
    
  8. Build libffi
    cd ../../libffi-${libffiver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/libffi/${libffiver}
    make
    make check
    make install
    
    cd ${prefixroot}/libffi/${libffiver}
    ln -s lib/libffi-${libffiver}/include
    cd -
    
    EXAMPLE OUTPUT
    ================================================
    Libraries have been installed in:
       /share/apps/tools/libffi/3.0.13/lib/../lib64
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    
  9. Build gc
    cd ../../gc-${gcver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/gc/${gcver}
    make
    make check
    make install
    
    EXAMPLE OUTPUT
    ================================================
    Libraries have been installed in:
       /share/apps/tools/gc/7.2d/lib
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    
  10. Build guile. This keeps blowing up with the error following the code. CentOS base repo actually has the guile and guile-devel packages that are new enough to support autogen, so I used the package instead. Leaving this step for future reference.
    cd ../../guile-${guilever}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/guile/${guilever} \
       --with-libltdl-prefix=${prefixroot}/libtool/${libtoolver} \
       --with-libgmp-prefix=${prefixroot}/gmp/${gmpver} \
       --with-libunistring-prefix=${prefixroot}/libunistring/${libunistringver} \
       LDFLAGS="-L${prefixroot}/libtool/${libtoolver}/lib -L${prefixroot}/gmp/${gmpver}/lib -L${prefixroot}/libunistring/${libunistringver}/lib -L${prefixroot}/libffi/${libffiver}/lib -L${prefixroot}/gc/${gcver}/lib" \
       CPPFLAGS="-I${prefixroot}/libtool/${libtoolver}/include -I${prefixroot}/libtool/${libtoolver}/include/libltdl -I${prefixroot}/libffi/${libffiver}/include -I${prefixroot}/gc/${gcver}/include -I${prefixroot}/gmp/${gmpver}/include" \
       LIBFFI_CFLAGS=-I${prefixroot}/libffi/${libffiver}/include \
       LIBFFI_LIBS=-L${prefixroot}/libffi/${libffiver}/lib \
       BDW_GC_CFLAGS=-I${prefixroot}/gc/${gcver}/include \
       BDW_GC_LIBS=-L${prefixroot}/gc/${gcver}/lib
    make
    make check
    make install
    
    EXAMPLE OUTPUT
    ================================================
    make[1]: Entering directory `/home/mhanby/sources/gcc/guile-2.0.9/build'
    Making all in lib
    make[2]: Entering directory `/home/mhanby/sources/gcc/guile-2.0.9/build/lib'
    make  all-recursive
    make[3]: Entering directory `/home/mhanby/sources/gcc/guile-2.0.9/build/lib'
    make[4]: Entering directory `/home/mhanby/sources/gcc/guile-2.0.9/build/lib'
    make[4]: Nothing to be done for `all-am'.
    make[4]: Leaving directory `/home/mhanby/sources/gcc/guile-2.0.9/build/lib'
    make[3]: Leaving directory `/home/mhanby/sources/gcc/guile-2.0.9/build/lib'
    make[2]: Leaving directory `/home/mhanby/sources/gcc/guile-2.0.9/build/lib'
    Making all in meta
    make[2]: Entering directory `/home/mhanby/sources/gcc/guile-2.0.9/build/meta'
    make[2]: Nothing to be done for `all'.
    make[2]: Leaving directory `/home/mhanby/sources/gcc/guile-2.0.9/build/meta'
    Making all in libguile
    make[2]: Entering directory `/home/mhanby/sources/gcc/guile-2.0.9/build/libguile'
    make  all-am
    make[3]: Entering directory `/home/mhanby/sources/gcc/guile-2.0.9/build/libguile'
      CC       libguile_2.0_la-finalizers.lo
    ../.././libguile/finalizers.c:167: error: static declaration of 'GC_set_finalizer_notifier' follows non-static declaration
    /share/apps/tools/gc/7.2d/include/gc/gc.h:177: error: previous declaration of 'GC_set_finalizer_notifier' was here
    make[3]: *** [libguile_2.0_la-finalizers.lo] Error 1
    make[3]: Leaving directory `/home/mhanby/sources/gcc/guile-2.0.9/build/libguile'
    make[2]: *** [all] Error 2
    make[2]: Leaving directory `/home/mhanby/sources/gcc/guile-2.0.9/build/libguile'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/mhanby/sources/gcc/guile-2.0.9/build'
    make: *** [all] Error 2
    
  11. Build autogen
    cd ../../autogen-${autogenver}
    mkdir build
    cd build
    .././configure --prefix=${prefixroot}/autogen/${autogenver}
    make
    make check
    make install
    
    EXAMPLE OUTPUT
    ================================================
    ------------------------------------------------------------------------
    Configuration:
    
      Source code location:   ../.
      Compiler:               gcc -std=gnu99
      Compiler flags:         -g -O2
      Host System Type:       x86_64-unknown-linux-gnu
      Install path:           /share/apps/tools/autogen/5.17.4
    
      See config.h for further configuration information.
    ------------------------------------------------------------------------
    
    Libraries have been installed in:
       /share/apps/tools/autogen/5.17.4/lib
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    
  12. Build gcc (make took approximately 2.5 hours to run on a system with a 2.7GHz Intel Xeon E5-2680, make check took about 3 hours)
    cd ../../gcc-${gccver}
    mkdir build
    cd build
    
    OLD_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
    export LD_LIBRARY_PATH=${prefixroot}/gmp/${gmpver}/lib:${prefixroot}/mpc/${mpcver}/lib:${prefixroot}/mpfr/${mpfrver}/lib:${LD_LIBRARY_PATH}
    
    .././configure \
      --prefix=${prefixroot}/gcc/${gccver} \
      --with-gmp=${prefixroot}/gmp/${gmpver} \
      --with-mpfr=${prefixroot}/mpfr/${mpfrver} \
      --with-mpc=${prefixroot}/mpc/${mpcver} \
      LD_FOR_TARGET=ld \
      AS_FOR_TARGET=as \
      --with-ld=${prefixroot}/binutils/${binutilsver}/bin/ld \
      --with-as=${prefixroot}/binutils/${binutilsver}/bin/as \
      --with-ar=${prefixroot}/binutils/${binutilsver}/bin/ar \
      AR_FOR_TARGET=ar
    
    time make
    
    #real 150m4.427s
    #user 101m21.408s
    #sys 12m54.047s
    
    OLD_PATH=${PATH}
    export PATH=/share/apps/tools/autogen/5.17.4/bin:${PATH}
    time make -k check
    make install
    
    export PATH=${OLD_PATH}
    export LD_LIBRARY_PATH=${OLD_LD_LIBRARY_PATH}
    
    EXAMPLE OUTPUT
    ================================================
    ----------------------------------------------------------------------
    Libraries have been installed in:
       /share/apps/tools/gcc/4.8.1/lib/../lib
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    ----------------------------------------------------------------------
    
    ----------------------------------------------------------------------
    Libraries have been installed in:
       /share/apps/tools/gcc/4.8.1/lib/../lib64
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    ----------------------------------------------------------------------
    
  13. Create the module file (for Environment Modules support)
    #%Module1.0####################################################################
    ##
    ## mymodule modulefile
    ##
    ## Sets up the 4.8.1 GCC compilation environment
    ##
    set ver [lrange [split [ module-info name ] / ] 1 1 ]
    set name [lrange [split [ module-info name ] / ] 0 0 ]
    set loading [module-info mode load]
    set subname [lrange [split $name - ] 0 0 ]
    
    proc ModulesHelp { } {
      puts stderr "\tThis module sets the environment for $name v$ver"
    }
    
    module-whatis   "Set environment variables to use $name version $ver"
    
    conflict compiler
    
    set base /share/apps/tools
    set gccdir $base/$subname/$ver
    set binutilsdir $base/binutils/2.23.2
    set gmpdir $base/gmp/5.1.2
    set mpcdir $base/mpc/1.0.1
    set mpfrdir $base/mpfr/3.1.2
    
    ## Add bin directories to the path
    prepend-path PATH $gccdir/bin
    prepend-path PATH $binutilsdir/bin
    
    prepend-path LD_LIBRARY_PATH $mpfrdir/lib
    prepend-path LD_LIBRARY_PATH $mpcdir/lib
    prepend-path LD_LIBRARY_PATH $gmpdir/lib
    prepend-path LD_LIBRARY_PATH $binutilsdir/lib
    prepend-path LD_LIBRARY_PATH $binutilsdir/lib64
    prepend-path LD_LIBRARY_PATH $gccdir/lib
    prepend-path LD_LIBRARY_PATH $gccdir/lib64
    
    prepend-path MANPATH $gccdir/share/man
    prepend-path C_INCLUDE_PATH $gccdir/include
    prepend-path CPLUS_INCLUDE_PATH $gccdir/include
    
    setenv CC $gccdir/bin/gcc
    setenv CXX $gccdir/bin/g++
    setenv FC $gccdir/bin/gfortran
    
    if { [ module-info mode load ] } {
      puts stderr "Note: $name $ver environment loaded."
    }
    

Friday, April 19, 2013

How To Compile Gromacs 4.6.1 with OpenMPI 1.6.4 on CentOS

I took the following notes while installing Gromacs 4.6.1 recently. Hopefully others will find them useful. The software was compiled and installed on a CentOS 5.9 x86_64 containing QDR Infiniband. The system uses SGE (Grid Engine) as it's scheduler. Intel compilers 13.1.1 were used to compile both OpenMPI and Gromacs.

Intel Compilers

I used version 13.1.1 of the Intel compilers. I'm including the module file here for reference
#%Module

set ver 13.1.1
set arch intel64

set root /share/apps/intel/parallel_studio_xe_2013_update3/composer_xe_2013.3.163
set ccroot /opt/intel/Compiler/$ver/$ccver
set fcroot /opt/intel/Compiler/$ver/$fcver
set mklroot $root/mkl

set msg "This module adds Intel compilers v$ver to various paths"

proc ModulesHelp { } {
   puts stderr $msg
}

module-whatis   $msg

setenv MKLROOT $mklroot
prepend-path MANPATH $root/man/en_US
prepend-path INTEL_LICENSE_FILE $root/licenses

prepend-path NLSPATH $root/compiler/lib/$arch/locale/en_US:$root/ipp/lib/$arch/locale/en_US:$root/mkl/lib/$arch/locale/en_US:$root/debugger/lib/$arch/locale/en_US

prepend-path LIBRARY_PATH $root/compiler/lib/$arch:$root/ipp/lib/$arch:$root/mkl/lib/$arch:$root/tbb/lib/$arch/gcc4.1
prepend-path MIC_LD_LIBRARY_PATH $root/compiler/lib/mic:$root/mkl/lib/mic:$root/tbb/lib/mic
prepend-path LD_LIBRARY_PATH $root/compiler/lib/$arch:$root/mpirt/lib/$arch:$root/ipp/lib/$arch:$root/mkl/lib/$arch:$root/tbb/lib/$arch/gcc4.1
prepend-path PATH $root/bin/$arch:$root/mpirt/bin/$arch:$root/bin/${arch}_mic:$root/debugger/gui/$arch

prepend-path CPATH $root/mkl/include:$root/tbb/include
prepend-path INCLUDE $root/mkl/include

prepend-path IPPROOT $root/ipp
prepend-path TBBROOT $root/tbb
prepend-path IDB_HOME $root/bin/$arch

Build OpenMPI 1.6.4

First, build the latest OpenMPI with the Intel compilers. This version of OpenMPI will reside in the Gromacs 4.6.1 install path.
  1. Create the install base directory
    cd /share/apps/gromacs/4.6.1/build
    wget http://www.open-mpi.org/software/ompi/v1.6/downloads/openmpi-1.6.4.tar.bz2
    
  2. Create the build script for Intel compilers: /share/apps/gromacs/4.6.1/build/build-openmpi-intel.sh
    #!/bin/sh
    . /etc/profile.d/modules.sh
    ver=1.6
    rel=1.6.4
    grover=4.6.1
    src="openmpi-${rel}.tar.bz2"
    url="http://www.open-mpi.org/software/ompi/v${ver}/downloads/${src}"
    compiler="intel"
    basedir="/share/apps/gromacs/${grover}/openmpi"
    prefix="${basedir}/${rel}-${compiler}"
    
    if [ -d $prefix ]; then
      echo "Installation directory already exists, exiting to prevent overwrite: $prefix";
      exit 1
    else
      echo "Verified installation directory does not exist: $prefix"
    fi
    
    if [ ! -f $src ]; then
      echo "Downloading source code from: $url";
      wget $url;
    else
      echo "Using existing source code: $src";
    fi
    
    if [ -d "openmpi-${rel}" ]; then
      echo "Removing existing build directory ./openmpi-${rel}"
      rm -rf openmpi-${rel};
    fi
    
    echo "Extracting $src"
    tar -jxf $src
    cd openmpi-${rel}
    
    echo "Building OpenMPI $rel for Intel compilers"
    echo "Running configure"
    module purge
    module load intel/intel-compilers-13.1.1
    CC=icc CXX=icpc F77=ifort FC=ifort ./configure --with-sge --with-openib --prefix=$prefix --enable-static --enable-shared
    
    make all install
    module purge
    
    cd ..
    
  3. Run the compile and install
    ./build-openmpi-intel.sh | tee openmpi-1.6.4-intel.log
    
  4. Create the module file (based off of [http://www.levlafayette.com/node/145 this example]) in the Gromacs base directory
    mkdir -p /share/apps/gromacs/4.6.1/modulefiles/gromacs-openmpi-intel
    vim /share/apps/gromacs/4.6.1/modulefiles/gromacs-openmpi-intel/1.6.4
    
    #%Module1.0#####################################################################
    ##
    ## $name modulefile
    ##
    # /share/apps/gromacs/4.6.1/openmpi/1.6.4-intel/bin
    # /share/apps/gromacs/4.6.1/openmpi/gromacs-openmpi-intel/1.6.4-intel/bin
    set ver [lrange [split [ module-info name ] / ] 1 1 ]
    set name [lrange [split [ module-info name ] / ] 0 0 ]
    set loading [module-info mode load]
    set subname [lrange [split $name - ] 0 0 ]
    #set compiler [lrange [split $name - ] 1 1 ]
    set compiler "intel"
    set compilerver "13.1.1"
    
    proc ModulesHelp { } {
      puts stderr "\tThis module sets the envinronment for $name v$ver compiled\n\twith Intel v13.1.1 compilers"
    }
    
    module-whatis   "Set environment variables to use $name version $ver"
    
    if { $loading && ![ is-loaded $compiler/$compilerver ] } {
      module load $compiler/$compilerver
    }
    
    set basedir /share/apps/gromacs/4.6.1/openmpi/${ver}-$compiler
    
    prepend-path --delim " " CPPFLAGS -I$basedir/include
    prepend-path --delim " " LDFLAGS -L$basedir/lib
    
    prepend-path LD_LIBRARY_PATH $basedir/lib
    prepend-path MANPATH $basedir/share/man
    prepend-path PATH $basedir/bin
    
    setenv  MPI_DIR         $basedir/
    setenv  MPI_HOME        $basedir/
    setenv  OPENMPI_ROOT    $basedir/
    
  5. Run a test
    • Create the input C file /share/apps/openmpi/build/mpi-helloworld.c
      #include <stdio>
      #include <string>
      #include <stddef>
      #include <stdlib>
      #include "mpi.h"
      
      main(int argc, char **argv ) {
          int rank, size;
          int buflen = 512;
          char name[buflen];
          
          MPI_Init(&argc, &argv);
          MPI_Comm_size(MPI_COMM_WORLD,&size);
          MPI_Comm_rank(MPI_COMM_WORLD, &rank);
      
          gethostname(name, buflen);
          
          printf( "P rank %d of %d, host %s\n", rank, size, name);
      
          MPI_Finalize();
      }
      
    • Compile mpi-helloworld.c
      module load /share/apps/gromacs/4.6.1/modulefiles/gromacs-openmpi-intel/1.6.4
      mpicc -o mpi-helloworld-intel mpi-helloworld.c
      
    • run it as a job
      module purge
      module load /share/apps/gromacs/4.6.1/modulefiles/gromacs-openmpi-intel/1.6.4
      qsub -V -b y \
         -l h_rt=00:15:00 \
         -l vf=256M \
         -j y \
         -pe openmpi\* 8 \
         mpirun -n 8 /share/apps/openmpi/build/mpi-helloworld-intel  
      

Build Gromacs 4.6.1

Official Gromacs 4.6 build instructions They have changed dramatically from versions 4.5 and prior. One requirement listed is that we need CMake version 2.8 or later. EPEL provides CMake 2.6.4, so we'll need to build CMake from scratch.
  1. Download the latest CMake from here: http://www.cmake.org/cmake/resources/software.html
    sudo mkdir /share/apps/cmake
    sudo chown mhanby:atlab /share/apps/cmake
    cd /share/apps/cmake
    wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2-Linux-i386.tar.gz
    tar -zxf cmake-2.8.10.2-Linux-i386.tar.gz 
    
  2. Create the build directory and download the source
    mkdir -p /share/apps/gromacs/4.6.1/build
    cd /share/apps/gromacs/4.6.1/build
    wget ftp://ftp.gromacs.org/pub/gromacs/gromacs-4.6.1.tar.gz
    tar -zxf gromacs-4.6.1.tar.gz 
    mkdir gromacs-4.6.1/build
    cd gromacs-4.6.1/build
    
  3. Create the module files
    mkdir /share/apps/modulefiles/gromacs-intel
    vim /share/apps/modulefiles/gromacs-intel/4.6.1
    
    #%Module
    
    set ver 4.6.1
    set app "Gromacs"
    set url "http://gromacs.org/"
    set approot /share/apps/gromacs/$ver
    set msg "This module adds $app v$ver to various paths\nWebsite: $url\n\n"
    
    proc ModulesHelp { } {
       puts stderr $msg
    }
    
    module-whatis  $msg
    
    module use --append $approot/modulefiles
    module load intel/13.1.1
    #module load $approot/modulefiles/gromacs-openmpi-intel/1.6.4
    module load gromacs-openmpi-intel/1.6.4
    
    setenv GROMACSHOME $approot
    #setenv MKL_HOME $::env(MKLROOT)
    prepend-path PATH $approot/bin
    prepend-path LD_LIBRARY_PATH $approot/lib
    prepend-path MANPATH $approot/man
    prepend-path MODULEPATH $approot/modulefiles
    prepend-path PKG_CONFIG_PATH $approot/lib/pkgconfig
    
  4. The next steps will build single and double precision in serial and parallel
    • Serial single precision
      1. Run cmake to configure the build
        module purge
        module load gromacs-intel/4.6.1
        export PATH=/share/apps/cmake/cmake-2.8.10.2-Linux-i386/bin:$PATH
        
        cd /share/apps/gromacs/4.6.1/build/gromacs-4.6.1/build
        rm -rf *
        
        cmake .. \
           -DCMAKE_C_COMPILER=icc \
           -DCMAKE_CXX_COMPILER=icpc \
           -DGMX_BUILD_OWN_FFTW=ON \
           -DCMAKE_INSTALL_PREFIX=/share/apps/gromacs/4.6.1 \
           -DREGRESSIONTEST_DOWNLOAD=ON
        
      2. View the configuration
        ccmake ..
        
         BUILD_SHARED_LIBS                ON
         CMAKE_BUILD_TYPE                 Release
         CMAKE_INSTALL_PREFIX             /share/apps/gromacs/4.6.1
         CMAKE_PREFIX_PATH
         CUDA_HOST_COMPILER               /share/apps/intel/parallel_studio_xe_2013_update3/composer_xe_2013.3.163/bin/intel64/icc
         GMX_CPU_ACCELERATION             SSE4.1
         GMX_DEFAULT_SUFFIX               ON
         GMX_DOUBLE                       OFF
         GMX_FFT_LIBRARY                  fftw3
         GMX_GPU                          OFF
         GMX_GSL                          OFF
         GMX_MPI                          OFF
         GMX_OPENMP                       ON
         GMX_QMMM_PROGRAM                 none
         GMX_THREAD_MPI                   ON
         GMX_X11                          OFF
         REGRESSIONTEST_DOWNLOAD          OFF                              
        
      3. make
        make
        
      4. Run the tests
        make check
        [ 70%] Built target gmx
        [ 71%] Built target gmxfftw
        [ 80%] Built target md
        [ 92%] Built target gmxana
        [ 92%] Built target editconf
        [ 96%] Built target gmxpreprocess
        [ 97%] Built target grompp
        [ 97%] Built target pdb2gmx
        [ 97%] Built target gmxcheck
        [100%] Built target mdrun
        [100%] Built target gmxtests
        Test project /share/apps/gromacs/4.6.1/build/gromacs-4.6.1/build
            Start 1: regressiontests/simple
        1/5 Test #1: regressiontests/simple ...........   Passed   72.17 sec
            Start 2: regressiontests/complex
        2/5 Test #2: regressiontests/complex ..........   Passed  868.76 sec
            Start 3: regressiontests/kernel
        3/5 Test #3: regressiontests/kernel ...........   Passed  583.48 sec
            Start 4: regressiontests/freeenergy
        4/5 Test #4: regressiontests/freeenergy .......   Passed  695.84 sec
            Start 5: regressiontests/pdb2gmx
        5/5 Test #5: regressiontests/pdb2gmx ..........   Passed  379.29 sec
        
        100% tests passed, 0 tests failed out of 5
        
        Total Test time (real) = 2599.69 sec
        [100%] Built target check
        
      5. Install
        make install
        
        ...
        -- Installing: /share/apps/gromacs/4.6.1/lib/pkgconfig/libgmxana.pc
        -- Installing: /share/apps/gromacs/4.6.1/bin/GMXRC
        -- Installing: /share/apps/gromacs/4.6.1/bin/GMXRC.bash
        -- Installing: /share/apps/gromacs/4.6.1/bin/GMXRC.zsh
        -- Installing: /share/apps/gromacs/4.6.1/bin/GMXRC.csh
        -- Installing: /share/apps/gromacs/4.6.1/bin/completion.csh
        -- Installing: /share/apps/gromacs/4.6.1/bin/completion.bash
        -- Installing: /share/apps/gromacs/4.6.1/bin/completion.zsh
        -- Installing: /share/apps/gromacs/4.6.1/bin/demux.pl
        -- Installing: /share/apps/gromacs/4.6.1/bin/xplor2gmx.pl
        
    • Serial double precision (will append _d to applicable installed files, example, mdrun_d)
      1. Run cmake to configure the build
        module purge
        module load gromacs-intel/4.6.1
        export PATH=/share/apps/cmake/cmake-2.8.10.2-Linux-i386/bin:$PATH
        
        cd /share/apps/gromacs/4.6.1/build/gromacs-4.6.1/build
        rm -rf *
        
        cmake .. \
           -DCMAKE_C_COMPILER=icc \
           -DCMAKE_CXX_COMPILER=icpc \
           -DGMX_BUILD_OWN_FFTW=ON \
           -DGMX_DOUBLE=ON \
           -DCMAKE_INSTALL_PREFIX=/share/apps/gromacs/4.6.1 \
           -DREGRESSIONTEST_DOWNLOAD=ON
        
      2. View the configuration
        ccmake ..
        
         BUILD_SHARED_LIBS                ON
         CMAKE_BUILD_TYPE                 Release
         CMAKE_INSTALL_PREFIX             /share/apps/gromacs/4.6.1
         CMAKE_PREFIX_PATH
         GMX_CPU_ACCELERATION             SSE4.1
         GMX_DEFAULT_SUFFIX               ON
         GMX_DOUBLE                       ON
         GMX_FFT_LIBRARY                  fftw3
         GMX_GPU                          OFF
         GMX_GSL                          OFF
         GMX_MPI                          OFF
         GMX_OPENMP                       ON
         GMX_QMMM_PROGRAM                 none
         GMX_THREAD_MPI                   ON
         GMX_X11                          OFF
         REGRESSIONTEST_DOWNLOAD          OFF
        
      3. make
        make
        
      4. Run the tests
        make check
        
        Test project /share/apps/gromacs/4.6.1/build/gromacs-4.6.1/build
            Start 1: regressiontests/simple
        1/5 Test #1: regressiontests/simple ...........   Passed    3.33 sec
            Start 2: regressiontests/complex
        2/5 Test #2: regressiontests/complex ..........   Passed    6.80 sec
            Start 3: regressiontests/kernel
        3/5 Test #3: regressiontests/kernel ...........   Passed   52.89 sec
            Start 4: regressiontests/freeenergy
        4/5 Test #4: regressiontests/freeenergy .......   Passed    9.19 sec
            Start 5: regressiontests/pdb2gmx
        5/5 Test #5: regressiontests/pdb2gmx ..........   Passed   22.82 sec
        
        100% tests passed, 0 tests failed out of 5
        
        Total Test time (real) =  95.08 sec
        [100%] Built target check
        
      5. Install
        make install
        
    • Parallel single precision (will append _mpi to applicable installed files, example, mdrun_mpi)
      1. Run cmake to configure the build
        module purge
        module load gromacs-intel/4.6.1
        export PATH=/share/apps/cmake/cmake-2.8.10.2-Linux-i386/bin:$PATH
        
        cd /share/apps/gromacs/4.6.1/build/gromacs-4.6.1/build
        rm -rf *
        
        cmake .. \
           -DCMAKE_C_COMPILER=icc \
           -DCMAKE_CXX_COMPILER=icpc \
           -DGMX_BUILD_OWN_FFTW=ON \
           -DGMX_MPI=ON \
           -DCMAKE_INSTALL_PREFIX=/share/apps/gromacs/4.6.1 \
           -DREGRESSIONTEST_DOWNLOAD=ON
        
      2. View the configuration
        ccmake ..
        
         BUILD_SHARED_LIBS                ON
         CMAKE_BUILD_TYPE                 Release
         CMAKE_INSTALL_PREFIX             /share/apps/gromacs/4.6.1
         CMAKE_PREFIX_PATH
         CUDA_HOST_COMPILER               /share/apps/intel/parallel_studio_xe_2013_update3/composer_xe_2013.3.163/bin/intel64/icc
         GMX_CPU_ACCELERATION             SSE4.1
         GMX_DEFAULT_SUFFIX               ON
         GMX_DOUBLE                       OFF
         GMX_FFT_LIBRARY                  fftw3
         GMX_GPU                          OFF
         GMX_GSL                          OFF
         GMX_MPI                          ON
         GMX_OPENMP                       ON
         GMX_QMMM_PROGRAM                 none
         GMX_THREAD_MPI                   OFF
         GMX_X11                          OFF
         MPI_EXTRA_LIBRARY                /usr/lib64/librdmacm.so;/usr/lib64/libibverbs.so;/usr/lib64/librt.so;/usr/lib64/libnsl.so;/usr/lib64/libutil.so;/usr/lib64/libdl.so;/usr/lib64/libm.so;/usr/lib64/librt.so;
         MPI_LIBRARY                      /share/apps/gromacs/4.6.1/openmpi/1.6.4-intel/lib/libmpi.so
         REGRESSIONTEST_DOWNLOAD          OFF
        
      3. make
        make
        
      4. Run the tests
        make check
        
        Test project /share/apps/gromacs/4.6.1/build/gromacs-4.6.1/build
            Start 1: regressiontests/simple
        1/5 Test #1: regressiontests/simple ...........   Passed   22.68 sec
            Start 2: regressiontests/complex
        2/5 Test #2: regressiontests/complex ..........   Passed   29.49 sec
            Start 3: regressiontests/kernel
        3/5 Test #3: regressiontests/kernel ...........   Passed  222.08 sec
            Start 4: regressiontests/freeenergy
        4/5 Test #4: regressiontests/freeenergy .......   Passed   19.17 sec
            Start 5: regressiontests/pdb2gmx
        5/5 Test #5: regressiontests/pdb2gmx ..........   Passed   75.39 sec
        
        100% tests passed, 0 tests failed out of 5
        
        Total Test time (real) = 368.83 sec
        [100%] Built target check
        
      5. Install
        make install
        
    • Parallel double precision (will append _mpi_d to applicable installed files, example, mdrun_mpi_d)
      1. Run cmake to configure the build
        module purge
        module load gromacs-intel/4.6.1
        export PATH=/share/apps/cmake/cmake-2.8.10.2-Linux-i386/bin:$PATH
        
        cd /share/apps/gromacs/4.6.1/build/gromacs-4.6.1/build
        rm -rf *
        
        cmake .. \
           -DCMAKE_C_COMPILER=icc \
           -DCMAKE_CXX_COMPILER=icpc \
           -DGMX_BUILD_OWN_FFTW=ON \
           -DGMX_MPI=ON \
           -DGMX_DOUBLE=ON \
           -DCMAKE_INSTALL_PREFIX=/share/apps/gromacs/4.6.1 \
           -DREGRESSIONTEST_DOWNLOAD=ON
        
      2. View the configuration
        ccmake ..
        
         BUILD_SHARED_LIBS                ON 
         CMAKE_BUILD_TYPE                 Release
         CMAKE_INSTALL_PREFIX             /share/apps/gromacs/4.6.1
         CMAKE_PREFIX_PATH
         GMX_CPU_ACCELERATION             SSE4.1
         GMX_DEFAULT_SUFFIX               ON
         GMX_DOUBLE                       ON
         GMX_FFT_LIBRARY                  fftw3
         GMX_GPU                          OFF
         GMX_GSL                          OFF
         GMX_MPI                          ON
         GMX_OPENMP                       ON
         GMX_QMMM_PROGRAM                 none
         GMX_THREAD_MPI                   OFF
         GMX_X11                          OFF
         MPI_EXTRA_LIBRARY                /usr/lib64/librdmacm.so;/usr/lib64/libibverbs.so;/usr/lib64/librt.so;/usr/lib64/libnsl.so;/usr/lib64/libutil.so;/usr/lib64/libdl.so;/usr/lib64/libm.so;/usr/lib64/librt.so;/usr/lib64/libnsl.so;/usr/lib64/libutil.so                       
         MPI_LIBRARY                      /share/apps/gromacs/4.6.1/openmpi/1.6.4-intel/lib/libmpi.so
         REGRESSIONTEST_DOWNLOAD          OFF
        
      3. make
        make
        
      4. Run the tests
        make check
        
        Test project /share/apps/gromacs/4.6.1/build/gromacs-4.6.1/build
            Start 1: regressiontests/simple
        1/5 Test #1: regressiontests/simple ...........   Passed   22.65 sec
            Start 2: regressiontests/complex
        2/5 Test #2: regressiontests/complex ..........   Passed   32.25 sec
            Start 3: regressiontests/kernel
        3/5 Test #3: regressiontests/kernel ...........   Passed  232.23 sec
            Start 4: regressiontests/freeenergy
        4/5 Test #4: regressiontests/freeenergy .......   Passed   21.13 sec
            Start 5: regressiontests/pdb2gmx
        5/5 Test #5: regressiontests/pdb2gmx ..........   Passed   82.39 sec
        
        100% tests passed, 0 tests failed out of 5
        
        Total Test time (real) = 390.67 sec
        [100%] Built target check
        
      5. Install
        make install
        

Wednesday, February 27, 2013

Ubuntu 13.04 on Google Nexus 7

Canonical has recently released a developer preview of Ubuntu 13.04 for Google Nexus devices.

I figured, what the heck, may as well try it out on my Google Nexus 7. Following these instructions, the installation went off without a hitch.

I used a laptop running Ubuntu 12.10 to perform the installation.

Following the installation, I ran into the issue during First Boot where the on screen keyboard didn't work. I don't have an OTG adapter cable, but do have a Bluetooth Logitech Android tablet keyboard. As stated in the instructions, the Bluetooth keyboard doesn't work during first boot.

That is, initially :-)

I got around this by clicking the Gear icon in the upper right corner and clicking System Settings -> Bluetooth. I clicked the add button and put the keyboard into connect mode. The keyboard successfully synced with the tablet.

Great, however now I couldn't find a way to close the System Settings window. I could move it around, but couldn't get the focus away and back to the First Boot screen.

No problem, click the Gear icon again and select restart. Upon reboot, the Bluetooth keyboard works fine on the First Boot windows.

Wednesday, January 23, 2013

How To: Recursively Create Numeric Directories

I was asked by a colleague how to do the following:

I have a root folder that I need to create a directory based on job numbers.

From the root folder, I'd like to create the following:

1000
1000\1100
1000\1100\1101
1000\1100\1102

all the way up to 

9000\9900\9999

To explain, I'll use the 5000 folder:

I would need:
5000
5000\5100
5000\5100\5101 through 5000\5100\5199
5000\5200
5000\5200\5201 through 5200\5200\5299
and so on.

What would be the easiest way?

The solution isn't a big deal for anyone familiar with scripting, but I figured I'd share here in case other none coders need help with a similar problem.

I wasn't sure whether they were on a Windows computer (figured most likely based on the slashes) or Linux / Mac, so I provided both a Bash and Windows command shell solutions.

There are any number of ways to approach this, I chose nested for loops.

First the Bash solution:

for x in {1..9}; do
  mkdir ${x}000
  cd ${x}000
  for y in {1..9}; do
    mkdir ${x}${y}00
    cd ${x}${y}00
    for ((z=1; z<=99; z+=1)); do
      mkdir `printf "%s%s%02d" $x $y $z`
    done
    cd ..
  done
  cd ..
done

Now the Windows solution:

setlocal EnableDelayedExpansion
for /l %x in (1, 1, 9) do (
  mkdir %x000
  cd %x000
  for /l %y in (1, 1, 9) do (
    mkdir %x%y00
    cd %x%y00
    for /l %z in (1, 1, 99) do (
      if %z LSS 10 (
        mkdir %x%y0%z
      ) else (
        mkdir %x%y%z
      )
    )
    cd ..
  )
  cd ..  
)

Wednesday, June 20, 2012

Build Firewall Builder 'FWbuilder' 5.1.0 for Fedora 17

Howdy, FirewallBuilder released version 5.1.0 without providing an officially built rpm for Fedora 17. This post will build an rpm for Fedora 17 using the src rpm for Fedora 16 If you need help configuring the rpmbuild environment, start here. First, download the fwbuilder-5.1.0.3599-1.fc16.src.rpm file to your local directory. Next, extract the src.rpm
$ cd ~/tmp/fwbuilder
$ rpm2cpio fwbuilder-5.1.0.3599-1.fc16.src.rpm | cpio -idvm
$ mv fwbuilder-5.1.0.3599.tar.gz ~/rpmbuild/SOURCES/
$ mv fwbuilder-5.1.0.3599.spec ~/rpmbuild/SPECS/
A patch file is required due to the following build error:
../fwbuilder/uint128.h: In member function 'std::string uint128::to_string() const':
../fwbuilder/uint128.h:469:95: warning: format '%lX' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat]
../fwbuilder/uint128.h:469:95: warning: format '%lX' expects argument of type 'long unsigned int', but argument 4 has type 'long long unsigned int' [-Wformat]
../fwbuilder/uint128.h:471:58: warning: format '%lX' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat]
In file included from ThreadTools.cpp:31:0:
../fwbuilder/ThreadTools.h:168:5: error: 'ssize_t' does not name a type
ThreadTools.cpp:182:82: error: no 'ssize_t libfwbuilder::TimeoutCounter::read(int, void*, size_t) const' member function declared in class 'libfwbuilder::TimeoutCounter'
make[4]: *** [.obj/ThreadTools.o] Error 1
The patch was built using the following diff (patch credit debian bug 674349)
$ diff -u src/libfwbuilder/src/fwbuilder/ThreadTools.h.orig src/libfwbuilder/src/fwbuilder/ThreadTools.h > ~/rpmbuild/SOURCES/fwbuilder-5.1.0.3599.ssize_t.patch
--- src/libfwbuilder/src/fwbuilder/ThreadTools.h.orig 2012-06-20 11:31:12.029364056 -0500
+++ src/libfwbuilder/src/fwbuilder/ThreadTools.h 2012-06-20 11:09:36.000000000 -0500
@@ -31,6 +31,7 @@
 
 #include  //for time_t definition
 #include 
+#include 
 
 #include 
 #include 
Either run through the diff to generate the patch file or copy and paste the above diff into the new patch file ~/rpmbuild/SOURCES/fwbuilder-5.1.0.3599.ssize_t.patch Now edit the fwbuilder-5.1.0.3599.spec file to include the new patch file
--- fwbuilder-5.1.0.3599.spec.orig 2012-03-22 04:17:55.000000000 -0500
+++ fwbuilder-5.1.0.3599.spec 2012-06-20 11:51:09.901734348 -0500
@@ -20,6 +20,7 @@
 Group:          %{guigroup}
 Url:            http://www.fwbuilder.org/
 Source:         http://prdownloads.sourceforge.net/fwbuilder/%{name}-%{version}.tar.gz
+Patch1:         fwbuilder-5.1.0.3599.ssize_t.patch
 Packager:       Vadim Kurland 
 
 Buildroot:      %{_tmppath}/%{name}-%{version}-root
@@ -48,6 +49,7 @@
 
 %prep
 %setup 
+%patch1 -p0
 ./autogen.sh
 
 %build

Then run the build
$ cd ~/rpmbuild/SPECS
$ rpmbuild -ba fwbuilder-5.1.0.3599.spec
The result is the rpm containing
$ rpm -qpl ../RPMS/x86_64/fwbuilder-5.1.0.3599-1.fc17.uabeng.x86_64.rpm |more
/usr/bin/fwb_iosacl
/usr/bin/fwb_ipf
/usr/bin/fwb_ipfw
/usr/bin/fwb_ipt
/usr/bin/fwb_pf
/usr/bin/fwb_pix
/usr/bin/fwb_procurve_acl
/usr/bin/fwbedit
/usr/bin/fwbuilder
/usr/share/applications/fwbuilder.desktop
/usr/share/doc/fwbuilder-5.1.0.3599
...
Install the rpm using yum
$ sudo yum install ../RPMS/x86_64/fwbuilder-5.1.0.3599-1.fc17.uabeng.x86_64.rpm 
Loaded plugins: fs-snapshot, langpacks, presto, refresh-packagekit
Examining ../RPMS/x86_64/fwbuilder-5.1.0.3599-1.fc17.uabeng.x86_64.rpm: fwbuilder-5.1.0.3599-1.fc17.uabeng.x86_64
Marking ../RPMS/x86_64/fwbuilder-5.1.0.3599-1.fc17.uabeng.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package fwbuilder.x86_64 0:5.1.0.3599-1.fc17.uabeng will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================
 Package         Arch         Version                         Repository                                        Size
=====================================================================================================================
Installing:
 fwbuilder       x86_64       5.1.0.3599-1.fc17.uabeng        /fwbuilder-5.1.0.3599-1.fc17.uabeng.x86_64        36 M

Transaction Summary
=====================================================================================================================
Install  1 Package
Hope this helps other FC17 FWbuilder users out there!

Friday, June 1, 2012

HowTo: Converting EXT4 to BTRFS in Fedora 17

This HowTo documents the steps I used on a Fedora 17 x86_64 test machine to convert the root file system from Ext4 to Btrfs.

Anaconda (Fedora installer) doesn't support the creation or manipulation of Btrfs file systems in the graphical installer. Support for this is slated for Fedora 18, at which time, Btrfs may become the default file system!

It is possible, however, to create Btrfs file systems at install time via Kickstart.

The virtual machine was installed with Fedora 17 x86_64 using default partitioning (LVM and Ext4) and selecting the Desktop profile.

If possible, create the partitions without LVM. (see section at the bottom for an example of this and UUID)

In the examples, the root file system is a logical volume: /dev/mapper/vg_f17vm-lv_root

Following the install and the initial boot, I rebooted using the Fedora 17 x86_64 Live CD and chose the option to Try Fedora.

I initially tried to perform the conversion using the Fedora 17 DVD and rescue mode, however the btrfs-convert utility isn't included. The live CD, however, includes the Btrfs utilities.

Convert EXT4 root

All of the steps are performed using the terminal, so open a Gnome Terminal and SU to root:
$ su -

Run fsck on the file system
# fsck.ext4 -f /dev/mapper/vg_f17vm-lv_root

Convert from ext4 to btrfs. The metadata stage can take a while on a large populated file system (on an 1.5TB ext4 file system with approx 500GB of data, a good mix of large and small files, this step took about 1.5 hours)
# btrfs-convert /dev/mapper/vg_f17vm-lv_root

creating btrfs metadata.
creating ext2fs image file.
cleaning up system chunk.
conversion complete.

Mount the freshly converted btrfs root file system so that we can make some modifications (fstab, SELinux)
# mkdir /mnt/btrfs
# mount -t btrfs /dev/mapper/vg_f17vm-lv_root /mnt/btrfs

Edit fstab to change the root file system from ext4 to btrfs
# vi /mnt/btrfs/etc/fstab

#/dev/mapper/vg_f17vm-lv_root              ext4   defaults    1 1
/dev/mapper/vg_f17vm-lv_root              btrfs   defaults    1 1

Force the system to automatically relabel the SELinux context for the root file system during boot.
# touch /mnt/btrfs/.autorelabel

NOTE: In my test, the Fedora 17 system would hang with systemd library permissions errors prior to getting to the SELinux auto relabel step.

To work around this, I rebooted back into the Live CD and change the SELinux policy to "permissive" from "enforcing". During the next boot, the permission errors went by and then the SELinux autorelabel ran to completion.
# vi /mnt/btrfs/etc/selinux/config

#SELINUX=enforcing
SELINUX=permissive

The Btrfs conversion process created a subvolume of the old ext4 file system. The following commands mount the subvolume and file system, demonstrating the power of Btrfs.
# mkdir /mnt/{ext2_saved,ext4}
# mount -t btrfs -o subvol=ext2_saved /dev/mapper/vg_f17vm-lv_root /mnt/ext2_saved
# mount -t ext4 -o loop,ro /mnt/ext2_saved/image /mnt/ext4

The contents of the ext4 and btrfs mounts should be identical, sans the changes made above to fstab and config.

It's possible to roll back the conversion by first unmounting the file systems and then rolling it back using the -r switch
# umount /dev/mapper/vg_f17vm-lv_root
# btrfs-convert -r /dev/mapper/vg_f17vm-lv_root

If you decide to stay with btrfs, you can delete the subvolume snapshot of the original ext4 system
# btrfs subvolume delete /mnt/btrfs/ext2_saved

Reboot into the installed OS and the system should perform the relabel and then come up with your shiny new btrfs file system.

To make things really cool, install the yum-plugin-fs-snapshot Yum plugin. This plugin will create a btrfs subvolume of your root file system prior to installing updates. The end result, you can roll back from yum updates. Test that you can mount the snapshot of the ext4 file system

Once the system is up and running, don't forget to set the SELinux policy back to "enforcing"

Issues:
  1. It appears that some of the systemd services attempt to start prior to the SELinux .autorelabel step. This results in permission errors that prevent the system from booting. Temporarily change the SELinux policy to "permissive" to work past this.
  2. During boot, you may see errors logged by the systemd-fsck service failing for lv_root due to missing fsck.btrfs. I suspect that the btrfs-progs rpm failed to create a symlink of fsck.btrf pointing to /usr/sbin/btrfsck
systemd-fsck[858]: fsck: fsck.btrfs: not found
systemd-fsck[858]: fsck: error 2 while executing fsck.btrfs for /dev/mapper/vg_f17vm-lv_root

Convert Luks Encrypted EXT4 home

If your file system is encrypted with Luks, you'll have the additional step of decrypting the file system prior to running the conversion
# cryptsetup luksOpen /dev/mapper/vg_f17vm-lv_home luks_home
# fsck.ext4 -f /dev/mapper/luks_home
# btrfs-convert /dev/mapper/luks_home

creating btrfs metadata.
creating ext2fs image file.
cleaning up system chunk.
conversion complete.

Converting Non LVM Ext4 and UUID in /etc/fstab

If you don't use LVM (recommended based on everything I've ready, since it's not needed for btrfs), your /etc/fstab may mount the partitions using the UUID. After converting the file system to btrfs, the UUID will change.

These steps demonstrate how to convert the root file syste, a non LVM ext4 partition, /dev/sda2.
# fsck.ext4 -f /dev/sda2
# btrfs-convert /dev/sda2

creating btrfs metadata.
creating ext2fs image file.
cleaning up system chunk.
conversion complete.
Identify the UUID using blkid (can also look under /dev/disk/by-uuid
# blkid /dev/sda2

/dev/sda2: UUID="56d1e02b-3120-44c3-b8f8-d3289012e447" UUID_SUB="13f7b26b-42b1-41bb-a9dc-c928ad033f6d" TYPE="btrfs" 


# mkdir /mnt/btrfs
# mount -t btrfs /dev/sda2 /mnt/btrfs


Edit fstab to change the root file system from ext4 to btrfs and replace the UUID with the new UUID
# vi /mnt/btrfs/etc/fstab

#UUID=e14bd8d6-ac8a-4f15-8169-f0a9bdf4b69e /                       ext4    defaults        1 1
UUID=56d1e02b-3120-44c3-b8f8-d3289012e447 /                       btrfs    defaults        1 1
UUID=f4cdf95d-66eb-4428-960d-23b289ffb63e /boot                   ext4    defaults        1 2

Chroot to the real root file system and update grub.cfg using grub2-mkconfig

# mount -o bind /dev /mnt/btrfs/dev
# mount -o bind /proc /mnt/btrfs/proc
# mount -o bind /sys /mnt/btrfs/sys
# mount /dev/sda1 /mnt/btrfs/boot

# chroot /mnt/btrfs

# grub2-mkconfig -o /boot/grub2/grub.cfg 

Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.4.3-1.fc17.x86_64
Found initrd image: /boot/initramfs-3.4.3-1.fc17.x86_64.img
Found linux image: /boot/vmlinuz-3.3.4-5.fc17.x86_64
Found initrd image: /boot/initramfs-3.3.4-5.fc17.x86_64.img
Warning: Please don't use old title `Fedora Linux, with Linux 3.3.4-5.fc17.x86_64' for GRUB_DEFAULT, use `Advanced options for Fedora Linux>Fedora Linux, with Linux 3.3.4-5.fc17.x86_64' (for versions before 2.00) or `gnulinux-advanced-/dev/sda2>gnulinux-3.3.4-5.fc17.x86_64-advanced-/dev/sda2' (for 2.00 or later)
done
Exit out of the chroot and unmount the file systems
# exit
# umount /mnt/btrfs/boot
# umount /mnt/btrfs/dev
# umount /mnt/btrfs/proc
# umount /mnt/btrfs/sys
# umount /mnt/btrfs


Reboot and you should be good to go. The selinux relabeling can take a while!

References:

Friday, May 4, 2012

Script to Query Dell Warranty Status

I'm sure there are more elegant ways of obtaining the warranty status for your Dell hardware, but none-the-less, here's a Ruby script I wrote that does just that :-)

Script: query_dell_st.rb

The script currently has two modes, single lookup and batch lookup.

Single lookup takes two arguments:
  • --host HOSTNANE
  • --svctag SERVICE_TAG
Bulk requires only a single argument pointing to an input file containing a single entry "HOSTNAME SERVICE_TAG" per line for each device.
  • --file FILE
Example single lookup:

$ ./query_dell_st.rb --svctag GT7D8P1 --host lin-srv01
Host: lin-srv01
 Model: PowerEdge R410
 Service Tag: GT7D8P1
 Warranty Exp: 617 days left


Over the next few days I'll add more features (CSV and tab delimited output, for example) as well as address bugs and error handling.

Hopefully the script is useful to others.

Friday, April 13, 2012

HowTo: Disable User List on RHEL6 / CentOS6 Login Window

Quick bit of code to disable the user list on the RHEL6 / CentOS6 login screen.

# gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set /apps/gdm/simple-greeter/disable_user_list true

Useful Gconf References:

Thursday, March 29, 2012

Ghetto-timemachine Ruby Backup Script

I decided to try my hand at some Ruby scripting and figured, what better way than to port one of my existing Perl scripts.

The result is the Ruby ghetto-timemachine.rb backup script!

The code is maintained here:
https://github.com/flakrat/ghetto-timemachine

So, what does it do? In a nutshell, it performs daily backups using a combination of hard links and rsync that result in a Time Machine like backup that uses very little additional space beyond the initial backup and the size of any files that change.

Example usage:
  • Local source to local destination with comma separated list of excludes
    
    ./ghetto-timemachine.rb --src ~/Pictures --dest /media/USB/backup --excludes \*.raw,\*.bmp
    
  • Local source to remote destination
    
    ./ghetto-timemachine.rb --src ~/Pictures --dest flakrat@rathole:/backup --excludes \*.raw,\*.bmp
    
Nightly cron job running at 1:10AM

10 1 * * * /home/flakrat/bin/ghetto-timemachine.rb --src ~/Pictures --dest flakrat@rathole:/backup --excludes \*.raw,\*.bmp

See the README for a more detailed description of the backup and rotation process.