Pingdom Update Contact for On Call Roster

Posted by Rianto Wahyudi

# Script to update contact details on pingdom
# Accept phone number as the first argument
# Pingdom will automatically add +61[mobile number] - so the zero '0' prefix in front of mobile number need to be stripped
# Valid input : 432123456
# No error checking on this script as 'we know what we are doing(tm)'

# Change Log:
# 20100809 (rwahyudi) - Create script
# 20100820 (rwahyudi) - Add simple check


if [ $# -lt 1 ]; then
echo "Usage: $0 [mobile number]"
echo " Pingdom will automatically add +61[mobile number] - so the zero '0' prefix in front of mobile number need to be stripped"
echo "Example: $0 432123456"
exit 1

# Remove Cookie and login
rm $DIR/cookie.txt
curl -x proxy.company.com:8080 -c $DIR/cookie.txt -d "username=$USERNAME&password=$PASSWD " https://pp.pingdom.com/index.php/login

# Edit OnCall contact
# OnCall ID = 12345
# See posting on how to get this value
curl -x proxy.company.com:8080 -b $DIR/cookie.txt -d "name=OnCall&email=OnCall%40company.com&country=15&phone=$1&twitter_dm=1&twitter_user=&defaultprovider=3&retryprovider=1&Submit=Update+Contact" https://pp.pingdom.com/index.php/member/contacts/edit/12345

# Check contact and email details on update to confirm that contact has been updated
PINGDOM_ACTIVE_NUMBER=$(curl -sq -b $DIR/cookie.txt https://pp.pingdom.com/index.php/member/contacts | grep -A1 " OnCall

"  | grep "+61-" | cut -d '-' -f2 | cut -d'<' -f1)
PINGDOM_ACTIVE_ONCALL=$(grep $PINGDOM_ACTIVE_NUMBER $DIR/phonelist.csv  | cut -d ',' -f1)

echo "

Pingdom active On-Call : $PINGDOM_ACTIVE_ONCALL

"| mail -s "$PINGDOM_ACTIVE_ONCALL ($CRT_ACTIVE_ONCALL) is now the active On-Call contact"  $MAIL

Bash script : DNS Check match between reverse and forward lookup

Posted by Rianto Wahyudi

Basic bash lookup script to check if forward / reverse IP address is matching.

  • The script use host command, it'llĀ  automatically add DNS prefix based on /etc/resolv.conf
  • Support for hostnamesĀ  or PTR address with multiple RR
Usage: ./checkhost <IP or hostname> checkhost<IP or hostname> ...
Example: ./checkhost www pop3.iinet.net.au
This script will check if forward and reverse match

./checkhost shadow pop3.iinet.net.au
shadow <-> : Match
pop3.iinet.net.au <-> : Match
mud.starway.net.au <-> : Match

Download the script here :


NFS Monitoring Scripts

Posted by Rianto Wahyudi

I've tried few different NFS mount check, but most of them hang or freeze when the remote server is not responding. So I created a simple script to monitor and automatically mount NFS which kill it self .

I put this script on crontab which then run every 15 minutes :
cron entries :

*/15 * * * * /root/bin/check_nfs.sh

check_nfs.sh :

# Script to check if NFS is mounted properly
# Change Log :

# Script to check and monitor NFS mounted file system

# When NFS is not working, it may hang the process that try to access it.
# As a work around, we start a process in the background that will kill nfs_check script after 30 seconds
# However, if check command works then kill the process that was about to kill me ( killmyparrent.sh )


# Exit if another instance is running
if [ `ps auxwww | grep check_nfs.sh | wc -l` -gt 3 ]
echo `pgrep check_nfs.sh | wc -l`

if mount | grep -q $mnt_partition
then :

/root/bin/killmyparent.sh $ "Email Subject - eg : NFS mount failed on xxx server" "Some issue with $mnt_parition. Please check it will you !" &
killerpid=`pgrep killmyparent.sh`

# NFS file system appear to be mounted - lets check if we can access it ..
if df | grep -q $mnt_partition
then :
# df command works .. kill "killmyparent.sh" script before it kill us
kill $killerpid
exit 1;
# Wait until server is contactible and then mount the partition
until [ `ping -q -c3 -w5 $REMOTE_SERVER > /dev/null 2>&1; echo $?` -eq 0 ]
sleep 10;
mount $mnt_partition
exit $?


if [ -z $1 ]
echo "Usage $0 "
sleep 20
kill -9 $1
echo $3 | mail -s $2