2Jan/110

Pingdom Update Contact for On Call Roster


#!/bin/bash
# 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

USERNAME=username@company.com
PASSWD=XXXXXX
MAIL=oncall-update@company.com
DIR=/opt/scripts/pingdom

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
fi

# 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 "
`date`

Pingdom active On-Call : $PINGDOM_ACTIVE_ONCALL

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

Posted by Rianto Wahyudi

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


+ one = 2

No trackbacks yet.