User Tools

Site Tools


scripts:bash:add-description-to-interface.sh
add-description-to-interface.sh
#!/bin/bash
# Written by Thomas York to name interfaces in Zenoss
 
# Check to make sure the supplied an argument to the script
if [ "x$2" == "x" ] ; then
        echo "Usage:";
        echo "         $0 <device name> <interface>";
        echo "";
        exit 1;
fi
 
readonly DEVICENAME=$1;
readonly INTERFACE=$2;
 
# Read description from user..
echo -ne "Description: ";
read DESC;
 
# Start building commands...
 
COMMAND="d=dmd.Devices.findDevice('$DEVICENAME')\n";
COMMAND=$COMMAND"i=d.os.interfaces._getOb('$INTERFACE')\n";
COMMAND=$COMMAND"i.unlock()\n";
COMMAND=$COMMAND"commit()\n";
COMMAND=$COMMAND"i.description = '$DESC'\n";
COMMAND=$COMMAND"i.lockFromUpdates()\n";
COMMAND=$COMMAND"commit()\n";
COMMAND=$COMMAND"exit()\n";
 
echo -en $COMMAND | /opt/zenoss/bin/zendmd &> /dev/null
/var/www/vhost/www.fuhell.com/data/pages/scripts/bash/add-description-to-interface.sh.txt · Last modified: 2014/09/01 15:00 (external edit)