The Brain Vault

Using Ansible to communicate with rest API

Ansible to interact with a rest API Sometimes you may want to interact with a rest api where an Ansible module doesn’t already exist. For those cases you may want to try using the uri module. Ansible already supports interacting with json so its pretty easy. Below I show an example of interacting with the Vault api. Link You may want to use Vault in cases where there is more sensitive information that you need to ensure that it is encrypted as well as has an audit trail.

Tricks for finding directory space usage.

Tricks for finding directory space usage. find . -iname "*regex" -printf "%s\n" | awk '{f+=$1}END{print f/(1024 *1024 * 1024),"GB"}' find . -iname "*.regex" -printf "%s\n" | awk '{f+=$1}END{print f}' another way. find -name \*.regex -print0 | du -ch --files0-from=- |tail -1 du -ch -b --max-depth=1 |sort -n|awk '{ print $1/(1024 *1024 * 1024),"gb", $2 }' Heres almost the same command excluding anything requiring special notation close to zero. du -ch -b --max-depth=1 |sort -n|awk '{ print $1/(1024 *1024 * 1024),"gb", $2 }' |grep -v e-0 another way.

Infiniband performance tuning

I’ll present the caveat and warning that all these things I tested not with a view to stability for a production environment but this allowed me to get an idea of what things I could do to eke out more performance. There were a few of basic designs I tested with. The hardware was a supermicro chassis with E5 series intel cpu’s 2x quad core 64GB ram. The raid card was LSI 9266-8i (capacitor bbu + fastpath and cachecade addons) that connected to a supermicro sas expander backplane.

SMP affinity makes a difference

A good driver. Having a driver that uses the proper interrupt handling makes a difference in high bandwidth pci devices like RAID cards and Infiniband. For example having the stock 2.6.32-220 megasas driver only makes use of one interrupt. This was the stock driver in the centos 2.6.32-220 kernel [root@demo mnt]# cat /proc/interrupts |grep megasas 79: 2506 0 0 0 0 0 0 0 IR-PCI-MSI-edge megasas This is the driver from LSI compiled against the same kernel sources.

BASH tricks

Just a bunch of bash tricks i’ve picked up. Save a backup copy of a file with a datestamp. cp script.sh script.sh.$(date +%Y%m%d%H%M) Generate a random string maybe for api key or password. cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 Find empty directories. find . -mindepth 1 -maxdepth 1 -type d -empty List processes being used by remote terminals and then show the files that may be opened by them.