Adding a XFS filesystem to CentOS 5

Howto use enterprise Linux ‘extras’ to mount a XFS filesystem on a CentOS v5.2 VM

Install RPM’s
Note: Due to this bug (3205), install binutils to overcome the error “xargs: nm: No such file or directory” while installing kmod-xfs-xen.

# yum install binutils
# yum install xfsprogs yum-kmod kmod-xfs-xen

# mkfs.xfs -f /dev/sda1

Check

A chunk of disk (2TB) has been allocated to a LVM partition for the VM, which is formatted with XFS. The device is mapped into the VM as /dev/xvdc1 (i.e. a whole device, c.f. partitioned device).

Before using the filesystem, perform a check:

# xfs_check /dev/xvdc1

Note: xfs_check requires a significant chunk of memory to run. With 2Gbyte of swap and 1Gbyte of RAM a check was unsuccessful.

Mount
Mount the disk by using it’s volume label. The label can be verified with the xfs_admin program:

# xfs_admin -l /dev/xvdc1
label = “purple-files”

Add the mount entry to ‘/etc/fstab’ so that the filesystem is automatically mounted at the next restart.

LABEL=purple-files /files xfs defaults 0 0
Mount the filesystem

# mount /files

NOTE: CENTOS 6.X

Centos 6.X (64bit) already supports XFS in kernel. You only need to
install xfsprogs package to mount xfs filesystems.

just yum install xfsprogs (it is included in centos 6.2 base)

Appendices

# yum install xfsprogs yum-kmod kmod-xfs-xen

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
kmod-xfs-xen x86_64 0.4-2 extras 256 k
xfsprogs x86_64 2.9.4-1.el5.centos extras 1.3 M
yum-kmod noarch 1.1.10-9.el5.centos base 15 k

Transaction Summary
=============================================================================
Install 3 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 1.6 M

Search entire filesystem for text in Linux

To search for text through the entire filesystem from the current path down in Linux use the following :

find / -type f -print0 | xargs -0  grep -l  "string to search" 2>/dev/null

Script to list all the MAC addresses on the system

Listing the mac addresses of nic cards excluding null or loopback MACs i.e. 00:00:00:00:00:00

grep -H . /sys/class/net/*/address | awk ‘{split($0,array,”address:”);print array[2]}’ | grep -v ’00:00:00:00:00:00′

 

 

 

Force fsck on next boot

Since live systems are near to impossible to fsck when running (unless you can pull one side of the mirror then clone it to the other (very messy).

Become Root

sudo su –

or

su –

As root create file in root folder a file named forcefsck

touch /forcefsck

Restart the system.

shutdown -r now


        

Using .htaccess to redirect a page with permanently moved 301

Though there are many ways to redirect using the HTTP 301 status code.

(make sure the AllowOverride is set to all on the apache config)

The .htaccess must be as follows:

Options +FollowSymlinks
 RewriteEngine on
 rewritecond %{http_host} ^orig.domain.com [nc]
 rewriterule ^(.*)$ http://new.domain.com/
 $1 [r=301,nc]

Replace the orig.domain.com and new.domain.com with the ones needed for your case of course.

You can setup logs for checking the rewriting though be warned enable them only when debugging they are hugely intensive on I/O and CPU on a heavy utilised server.

More info here : http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog

Nagios fail to run ifstatus

/usr/local/nagios/libexec/check_ifstatus -H localhost

&nbsp

Can’t locate Net/SNMP.pm in @INC (@INC contains: /usr/local/nagios/libexec /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at ./check_ifstatus line 38.

BEGIN failed–compilation aborted at ./check_ifstatus line 38.

 

Solution:

yum install perl-Net-SNMP

Nagios configuration debugging

After testing a nagios configuration update ( including a new service or renaming some host etc..) before committing the changes and reloading / restarting the nagios service a good test is the following:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
(more…)

iptraf boxes do not show up well

On one of my servers running CentOS 6 I had iptraf not displaying the boxes in dialogues correctly.  It’s usually fixed by updating the session configuration on putty to translate to utf-8 but in this case that did not work.

While the system is a clone from another machine where it works well (puppet confirms) all I had to do is create an alias in my ./bashrc for iptraf to NCURSES_NO_UTF8_ACS=1  iptraf as such :

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

alias iftop='NCURSES_NO_UTF8_ACS=1 iftop'
alias iptraf='NCURSES_NO_UTF8_ACS=1  iptraf'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

As you can deduce the same issue and solution happened with iftop. 🙂

Oh the result :

Ejnoy 🙂

Quick script to get path to latest nagios version

If you need to automate the retrieval of the latest Nagios version path to download this is how I do it.

Nothing fancy and it breaks if they change the sourceforge site but we can fix when that happens 🙂

 

curl -v http://www.nagios.org/download/core/thanks/ 2>&1 | grep tar\.gz | cut -d \” -f 2 | sort -r | head -n 1

Result:

http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz

Of course this comes in handy when pulling for the clients being monitored so by extension:

 curl -v http://www.nagios.org/download/plugins/ 2>&1 | grep tar\.gz | cut -d \” -f 2 | sort -r | head -n 1

Result:

http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz

Getting the files in a script is as easy as :

curl -v http://www.nagios.org/download/plugins/ 2>&1 | grep tar\.gz | cut -d \” -f 2 | sort -r | head -n 1 | xargs wget

Ping me if this stops working for you.

Enjoy.

Wireshark: cutting the crap

DisplayFilters

Wireshark uses display filters for general packet filtering while viewing and for its ColoringRules.

The basics and the syntax of the display filters are described in the User’s Guide.

The master list of display filter protocol fields can be found in the display filter reference.

If you need a display filter for a specific protocol, have a look for it at the ProtocolReference.

 

Examples

Show only SMTP (port 25) and ICMP traffic:

  •  tcp.port eq 25 or icmp

Show only traffic in the LAN (192.168.x.x), between workstations and servers — no Internet:

  • ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16

(more…)