Pages

Tuesday, May 7, 2013

Sys Admin things...: Keeping your NetApp in check with Nagios

Sys Admin things...: Keeping your NetApp in check with Nagios: Recently we took delivery of a new NetApp. Two 3210′s with roughly 50TB of storage across five disk shelves. For monitoring we use Nagios ...

Thursday, May 2, 2013

Script to check the Forward/Reverse DNS entries are sane for host

#! /bin/bash
name=`hostname -f`
ip=$(ifconfig eth0 | grep "inet addr" | awk -F '[: ]' '{print $13}')

forward=$(host $name | awk -F " address " '{print $2}')
reverse=$(host $ip | awk -F "pointer " '{print $2}' | sed 's/\.$//g')


if [ "$ip" = "$forward" ]; then
echo -e "Forward Lookup is ok"
else
echo -e "\nForward lookup does not match with assigned IP address.IP address is $ip while DNS ponits to $forward."
fi

if [ "$name" = "$reverse" ]; then
echo -e "\nReverse Lookup is ok"
else
echo -e "\nReverse lookup does not match with hostname.Hostname is $name while Reverse DNS ponits to $reverse."
fi

Using multiple Field Separators in AWK

Most of the time working with awk we require multiple field separators, e.g. from the o/p of ifconfig you require ip address , BCast address as well netmask you can get all these details in one go as below

ifconfig eth0 | grep 'inet addr:' | awk -F '[: ]' '{print $13,$16,$19}' 

Here I am using the white space and colon both as field Separators