#!/bin/sh
. /etc/sargraph.conf
##modify_srv ver3.0
##This script will be used to disable or remove server from servers.conf
if [ $# -eq 0 ]
then
echo "USAGE: modify_srv <server> <action>"
echo "Action: disable - to disable the sar collection for server"
echo "Action: enable - to enable the server in sargraph database"
echo "Action: remove - to remove the server from sargraph database"
exit -1;
fi
$EGREP $1 $SERVERSCONF
if [ $? -eq 0 ]
then
echo "Server found"
else
echo "ERROR: Server $1 not found!"
exit -1;
fi

case "$2" in
disable)
$SED -i s/$1/#$1/ $SERVERSCONF
if [ $? -eq 0 ]
then
echo "$1 disabled from SARGRAPH"
else
echo "ERROR: Action failed!"
exit -1;
fi
;;
remove)
$SED -i /$1/d $SERVERSCONF
if [ $? -eq 0 ]
then
echo "$1 removed from SARGRAPH"
else
echo "ERROR: Action failed!"
exit -1;
fi
;;
enable)
$SED -i s/#$1/$1/ $SERVERSCONF
if [ $? -eq 0 ]
then
echo "$1 enabled in SARGRAPH"
else
echo "ERROR: Action failed!"
exit -1;
fi
;;
esac
