Updating node IPs in WM

I ran into this issue after changing the IP of an SM. Prizm has the very handy “Modify element IP/MAC” in the Define Networks window, but WM does not seem to have any equivalent function at all. I let the nightly rediscovery process run, no change. I did not want to delete the node and lose all of the polled statistics… just update the IP so WM could contact it again!

So after hearing nothing from support for about 4.5 hours on the matter I decided to write this little utility to do it right in the database. On my system, I only closed the client before running the script. The SMs were already not being updated since the IPs did not respond to SNMP pings. On a busier server - certainly with more than one user - I would certainly recommend STOPPING Wireless Manager before doing these operations, if you run this without stopping the server it is at your own risk. So if you get data corruption you only have yourself to blame.

Anyway… looks like I can’t attach files so here’s the contents of “update_node_ip.sh”


#!/bin/bash

###
# Configurable Variables
###
DEBUGGING=“0”

DBUSER=“root”


###
# Input Validation
###
function error_usage {
echo $1
echo -e “Please correct the above problems.'n’nUsage: ‘$0 [old IP] [new IP]’”
exit
}


if [ -z $1 ]; then
error_usage “Please provide the original IP address”
fi

if [ -z $2 ]; then
error_usage “Please provide the desired new IP address”
fi

stty -echo
read -p “Please enter the password for WMSDB user ‘$DBUSER’: " DBPASS
echo
stty echo

if [ -z $DBPASS ]; then
error_usage “Password was not entered.”
fi

OLDIP=$1
NEWIP=$2
DBPARAM=”-u $DBUSER --password=$DBPASS WMSDB"


###
# Execute the MySQL query and provide query debugging
###
function mysql_query {
if [ “$DEBUGGING” == “1” ]; then
echo $1
fi

if mysql $DBPARAM -e “$1”; then
echo -n “.”
else
echo -e “'nThe query failed with the above error.”
exit $?
fi
}


###
# Header
###
echo -e “'nUpdating the following stored data:'n”


###
# Alert history
###
echo -ne “'tAlert History’t’t”
mysql_query “UPDATE Alert SET ENTITY = ‘Disc-$NEWIP’ WHERE ENTITY = ‘Disc-$OLDIP’”
mysql_query “UPDATE Alert SET SOURCEIP = ‘$NEWIP’ WHERE SOURCEIP = ‘$OLDIP’”
echo -e “'t [ OK ]”


###
# Event history
###
echo -ne “'tEvent history’t’t”
mysql_query “UPDATE Event SET ENTITY = ‘Disc-$NEWIP’ WHERE ENTITY = ‘Disc-$OLDIP’”
mysql_query “UPDATE Event SET SOURCEIP = ‘$NEWIP’ WHERE SOURCEIP = ‘$OLDIP’”
mysql_query “UPDATE Event SET NODE = ‘$NEWIP’ WHERE NODE = ‘$OLDIP’”
echo -e “'t [ OK ]”


###
# Discovery annotations
###
echo -ne “'tDiscovery Annotations’t”
mysql_query “UPDATE ANNOTATION SET ENTITY = ‘Disc-$NEWIP’ WHERE ENTITY = ‘Disc-$OLDIP’”
echo -e “'t [ OK ]”


###
# Device auditing, previous configuration tasks
###
echo -ne “'tDevice Task History’t”
TASKNAMES=mysql $DBPARAM -N -s -e "SELECT TASKNAME FROM DeviceAudit WHERE DEVICENAME = '$OLDIP'"

for task in $TASKNAMES; do
mysql_query “UPDATE DeviceAudit SET SUBTASKNAME = ‘$task_$NEWIP_0’, DEVICENAME = ‘$NEWIP’ WHERE TASKNAME = ‘$task’”
done
echo -e “'t [ OK ]”


###
# Managed Objects
###
echo -ne “'tManaged Objects’t’t”
mysql_query “UPDATE ManagedObject SET DISPLAYNAME = ‘$NEWIP’ WHERE DISPLAYNAME = ‘$OLDIP’”
echo -e “'t [ OK ]”


###
# Polled Data
###
echo -ne “'tPolled Statistics’t”
mysql_query “UPDATE PolledData SET DNSNAME = ‘$NEWIP’ WHERE DNSNAME = ‘$OLDIP’”
echo -e “'t [ OK ]”


###
# Topology Objects
###
echo -ne “'tTopology Objects’t”
mysql_query “UPDATE TopoObject SET IPADDRESS = ‘$NEWIP’ WHERE IPADDRESS = ‘$OLDIP’”
echo -e “'t [ OK ]”


###
# Wireless Manager object properties
###
echo -ne “'tStored Configuration’t”
mysql_query “UPDATE WMS_CUSTOMUSERPROPS SET PROPVAL = ‘$NEWIP’ WHERE PROPVAL = ‘$OLDIP’”
echo -e "'t [ OK ]"


exit 0


Yes I know that transactions would be a lot better, but the WM DB is all setup with MyISAM which do not support them. I didn’t really feel like changing all the tables to InnoDB.


Again, use this script AT YOUR OWN RISK I cannot be held responsible for any damage caused.