Average file size on directory using gawk

gawk gnu awk

 

While tuning and benchmarking an HP backup device (HPD2D backup system) I needed to estimate the average file size of the IMAP server storage.
You may think I could just count the number of files and the divide the used space by the number of files, but that wasn’t the case because I didn’t want all the files to count, in this case I just needed the maildir files that have the email content.
So I did a little script (just a command line) using gawk to do it for me:

find /home/vmail -type f -name [0-9]* -exec ls -l {} \; | gawk '{sum += $5; n++;} END {print sum/n;}'

First I find all the files that starts with a number on the base directory of my dovecot server (IMAP storage), and the I need to list them as the size info is needed.
Second I’ve a little gawk script that will do the sum and division.
Let me say this took a few hours as the storage holding the files has 8TB of data.
Well hope this will help some1 else.
Cheers,
Pedro

Listing storage (scsi) paths for use with multipath

Hi!

About a year ago I’ve setup some linux RHEL 6 with multipath access to an HP EVA storage.

Today I needed to do it again, and to do so i needed to list all the path available to the storage device, here’s my command line (hope it helps someone else) to list all the path and volumes:


ls /dev/sd* | grep -E -v '[0-9]' | while read D ; do F=$(echo $D) ; \
echo -n $F ; echo -n " " ; scsi_id --page=0x83 --whitelisted --device=$F | \
sort -k 2 ; done | sort -k 2

The output should be something like this:


/dev/sda 3600508b1001c927a634cedb90322b49e
/dev/sdb 3600508b4000744ff0000a00001fd0000
/dev/sdf 3600508b4000744ff0000a00001fd0000
/dev/sdj 3600508b4000744ff0000a00001fd0000
/dev/sdn 3600508b4000744ff0000a00001fd0000
/dev/sdd 3600508b4000744ff0000a000025c0000
/dev/sdh 3600508b4000744ff0000a000025c0000
/dev/sdl 3600508b4000744ff0000a000025c0000
/dev/sdp 3600508b4000744ff0000a000025c0000
/dev/sde 3600508b4000744ff0000a000025f0000
/dev/sdi 3600508b4000744ff0000a000025f0000
/dev/sdm 3600508b4000744ff0000a000025f0000
/dev/sdq 3600508b4000744ff0000a000025f0000
/dev/sdc 3600508b4000744ff0000a00002660000
/dev/sdg 3600508b4000744ff0000a00002660000
/dev/sdk 3600508b4000744ff0000a00002660000
/dev/sdo 3600508b4000744ff0000a00002660000


As you can see I’ve one available disk on this server, actually this one is a RAID1 (HW) config (sda), 16 paths to my storage device, that delivers 4 different volumes (4 paths to each volume).
Sometime later I’ll discuss the multipath configuration but for now i just wanted to leave the command line that help me list all the paths ids.
Cheers,
Pedro Oliveira

Tor RPM for RHEL 6.x, Centos 6.x, Scientific Linux 6.x (x86_64)

Hi,

Recently I installed a tor relay server but I couldn’t find the rpm for Scientific Linux, so i decided to get the source code and copile it myself, even better i decided to make the RPM.

I’m really short on time so I didn’t create a repo for it (if someone out there vulunters to help maintaining the repo I’ll do it)

For now here’s the rpm, enjoy.

Pedro M. S. Oliveira

 

[download id=”3″]

 

PS – For those of you that doesn’t know what tor project is you may check https://www.torproject.org/

MENTAL NOTE – Setup bridge device on centos, rhel, scientific linux

FROM: http://www.banym.de/linux/centos/setup-bridge-device-on-centos

1. Install all needed packages:

yum install bridge-utils

yum install tunctl

2. Disable NetworkManager and enable network at boot time:

chkconfig NetworkManager off

chkconfig –levels 35 network on

/etc/init.d/NetworkManager stop

/etc/init.d/network restart

3. Create br0 configuration

vi /etc/sysconfig/network-scripts/ifcfg-br0

Change following configuration to your needs.

DEVICE=br0

TYPE=Bridge

BOOTPROTO=static

DNS1=192.168.0.1

GATEWAY=192.168.0.1

IPADDR=192.168.0.100

NETMASK=255.255.255.0

ONBOOT=yes

SEARCH=”example.com”

4. Modify eth0 configuration:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

HWADDR=00:1e:90:f3:f0:02

ONBOOT=yes

TYPE=Ethernet

IPV6INIT=no

USERCTL=no

BRIDGE=br0

5. Restart network or reboot machine

/etc/init.d/network restart

or

reboot

Credits to: http://www.banym.de

Converting SSL-certificates from CRT format to PEM

MENTAL NOTE from http://moze.koze.net/?p=81
Converting SSL-certificates from CRT format to PEM

Dovecot, for example, seems to expect pem-files, while RapidSSL only issues
crt-files. The solution? Use OpenSSL to convert (via the DER-format) to pem:

openssl x509 -in input.crt -out input.der -outform DER

then

openssl x509 -in input.der -inform DER -out output.pem -outform PEM

Click to access the login or register cheese