netiq-menu

netiq_menu
code format="bash"
 * 1) !/bin/sh


 * 1)       Author:         Chad Crider             #
 * 2)       Date Written:   12/9/2010               #
 * 3)       Purpose:        Automate interation     #
 * 4)                       with NetIQ Agent    #
 * 5)       Version:        1.0                     #
 * 1)                       with NetIQ Agent    #
 * 2)       Version:        1.0                     #

if $EUID -ne 0 ; then echo "This script must be run as root" 1>&2 exit 1 fi
 * 1) Check to see if the user is root

upload_netdiag { if [ -d /ovtools/netiq/UnixAgent/bin/ ]; then rm /ovtools/netiq/UnixAgent/diag/* /ovtools/netiq/UnixAgent/bin/NetiqDiag DIAG_DIR="/ovtools/netiq/UnixAgent/diag/" fi if [ -d /opt/netiq/UnixAgent/bin/ ]; then rm /opt/netiq/UnixAgent/diag/* /opt/netiq/UnixAgent/bin/NetiqDiag DIAG_DIR="/opt/netiq/UnixAgent/diag/" fi
 * 1) Function to run and upload the netdiag

cd $DIAG_DIR


 * 1) FTP UP THE NETDIAG

if [ `uname` = "Linux" ]; then FTP="ftp -inv" PASSIVE="" elif [ `uname` = "HP-UX" ]; then FTP="ftp -inv" PASSIVE="passive" else FTP="ftp -invp" PASSIVE="" fi
 * 1) Check which OS it's running on and set the FTP command accordingly

HOST="" USER="" PASSWD="" DIR="/upload/$ticket" FILE=`basename $DIAG_DIR/*tar*`

$FTP $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD mkdir $DIR cd $DIR $PASSIVE binary put $FILE END_SCRIPT }

remove_core_files { echo "Removing core files" if [ -d /ovtools/netiq/UnixAgent/bin/ ]; then rm /ovtools/netiq/UnixAgent/bin/core* fi if [ -d /opt/netiq/UnixAgent/bin/ ]; then rm /opt/netiq/UnixAgent/bin/core* fi }
 * 1) Function to remove core files

restart_agent { echo "NetIQ Agent restarting" if [ `uname` = "HP-UX" ]; then cd /sbin/init.d/   /sbin/init.d/nqmdaemon stop /sbin/init.d/nqmdaemon start else cd /etc/init.d/   /etc/init.d/nqmdaemon stop /etc/init.d/nqmdaemon start fi
 * 1) Function to restart agent

echo -e "\n\nCopy the line below to the TT and reassign to ESM\n" echo "Core files removed and agent restarted. Sending back to ESM for verification." }

cold_restart { if [ `uname` = "HP-UX" ]; then cd /sbin/init.d/   /sbin/init.d/nqmdaemon stop /usr/bin/perl -i -pe 's/NIQ_AGENT_STARTUP_OPTIONS_ADDITION=""/NIQ_AGENT_STARTUP_OPTIONS_ADDITION="-C"/g' * /sbin/init.d/nqmdaemon start /usr/bin/perl -i -pe 's/NIQ_AGENT_STARTUP_OPTIONS_ADDITION="-C"/NIQ_AGENT_STARTUP_OPTIONS_ADDITION=""/g' * else cd /etc/init.d/   /etc/init.d/nqmdaemon stop /usr/bin/perl -i -pe 's/NIQ_AGENT_STARTUP_OPTIONS_ADDITION=""/NIQ_AGENT_STARTUP_OPTIONS_ADDITION="-C"/g' * /etc/init.d/nqmdaemon start /usr/bin/perl -i -pe 's/NIQ_AGENT_STARTUP_OPTIONS_ADDITION="-C"/NIQ_AGENT_STARTUP_OPTIONS_ADDITION=""/g' * fi
 * 1) Function to do a cold restart of the agent

echo -e "\n\nCopy the line below to the TT and reassign to ESM\n" echo -e "Core files removed and agent cold-started. Sending back to ESM for verification.\n" }

display_menu { clear echo -e "\n\nNetIQ Menu
 * 1) Function to display the menu

1)     Restart the NetIQ Agent

2)     Cold-Restart the NetIQ Agent

3)     Run a NetDiag and upload it to the server


 * Options 1 and 2 remove core files before restarting agent

Selection: \c " read choice

case "$choice" in

1 )clear

remove_core_files restart_agent ;;

2 )clear       remove_core_files                cold_restart                ;;

3 )clear       if [ `uname -r` = "5.8" ]; then                echo "Solaris 8 doesn't support Passive FTP by default.  Therefore, at this time there  is no workaround for uploading a NetDiag to ESM's ftp as it requires passive mode."            exit 1        fi                echo -e "Please enter the TT #  \c"        read ticket        upload_netdiag                echo -e "\n\nCopy the line below to the TT and reassign to ESM\n"                echo -e "NetDiag uploaded to the ftp.  Sending back to ESM for verification.\n"        ;; esac }

USAGE { echo "" echo "USAGE: " echo "   netiq_menu [-c|-n|-r]" echo "   netiq_menu if run locally for menu" echo "" echo "OPTIONS:" echo "   -c  Remove core files and Cold-start Netiq" echo "   -n  NetDiag Selected" echo "   -r  Remove core files and Restart Netiq" echo "" echo "EXAMPLE:" echo "   netiq_menu -c" echo "" exit $E_OPTERROR   # Exit and explain usage, if no argument(s) given. }

if [ "$1" != "" ]; then while getopts "cnr" OPTION do case $OPTION in c )       echo "Cold-start Netiq Selected"    remove_core_files    cold_restart    exit 0;; n ) echo "NetDiag Selected" if [ `uname -r` = "5.8" ]; then echo "Solaris 8 doesn't support Passive FTP by default. Therefore, at this time there  is no workaround for uploading a NetDiag to ESM's ftp as it requires passive mode." exit 1 fi   echo -e "Please enter the TT #  \c" read ticket upload_netdiag echo -e "\n\nCopy the line below to the TT and reassign to ESM\n" echo -e "NetDiag uploaded to the ftp. Sending back to ESM for verification.    \n" exit 0;; r )       echo "Restart Netiq Selected"    remove_core_files    restart_agent    exit 0;; esac done else    display_menu fi code
 * 1) Check to see if there is an argument and act accordingly
 * 1) Process Arguments
 * ) USAGE

netiq_verdugo
code format="bash"
 * 1) !/bin/bash


 * 1) Purpose of this script is to copy the netiq_menu script to a remote server and
 * 2) and execute it with the desired flag.

USAGE { echo "" echo "USAGE: " echo "     /netiq [-c|-n|-r] " echo "" echo "OPTIONS:" echo "     -c  Remove core files and Cold-start Netiq" echo "     -n  NetDiag Selected" echo "     -r  Remove core files and Restart Netiq" echo "" echo "EXAMPLE:" echo "     /netiq -c icux1262" echo "" exit $E_OPTERROR   # Exit and explain usage, if no argument(s) given. }

ARG="" while getopts "cnr" OPTION do case $OPTION in c ) #SERVER=$OPTARG   ARG="-c"    echo "Arg chosen is $1 and server given is $SERVER"    echo "Cold-start Netiq Selected";; n ) #SERVER=$OPTARG ARG="-n" echo "Arg chosen is $1 and server given is $SERVER" echo "NetDiag Selected";; r ) #SERVER=$OPTARG   ARG="-r"    echo "Arg chosen is $1 and server given is $SERVER"    echo "Restart Netiq Selected";; esac done
 * 1) Process Arguments
 * ) USAGE

shift $(($OPTIND - 1)) SERVER=$1
 * 1)  Decrements the argument pointer so it points to next argument.
 * 2)  $1 now references the first non option item supplied on the command line
 * 3) + if one exists.

if -z "$1" ; then echo "NO SERVER NAME GIVEN" USAGE exit 1 fi
 * 1) whatever you want to do when no parms
 * 1) echo "Usage: `basename $0` " >&2

scp /home/u8x1464/scripts/netiq_menu root@$SERVER:/var/tmp/ ssh $SERVER /var/tmp/netiq_menu $ARG

code