Skip to content

Instantly share code, notes, and snippets.

@imv7
Created June 1, 2017 23:15
Show Gist options
  • Save imv7/0d1f8bc4d40b670a22dca6683c9688a3 to your computer and use it in GitHub Desktop.
Save imv7/0d1f8bc4d40b670a22dca6683c9688a3 to your computer and use it in GitHub Desktop.
IBM Communications Server ( SNA ) Monitor
#!/bin/ksh
#
#=======================================================================
#
# Script: mon_sna
#
# Purpose: Verify the SNA Link Station is active.
# If inactive, acivate.
# If still inactive, generate page.
#
# Parms: None.
#
#
usage="$0"
#
#=======================================================================
#
function Now {
echo `date '+%Y-%m-%d-%H.%M.%S'`
}
function chkSNA {
SNAresp=`sna -d l -p $1 2>&1`
rc=0
sndate=`date +'%d/%m/%Y %T'`
if [[ -n `echo $SNAresp|grep "SNA software has not been initialised"` ]];
then
echo $sndate $(hostname) SNA is NOT working properly. See more: $(snaadmin status_all) $(sna -d sl) | mail -s "$(hostname) SNA is not running" igor@icloud.com
echo $sndate $(hostname) SNA is NOT working properly. See more: $(snaadmin status_all) $(sna -d sl) > /tmp/sna.log
print "`Now` $Script : SNA is not active. Starting...."
sna stop
sleep 20
sna start
sleep 20
snaadmin init_node
sleep 20
SNAresp=`sna -d l -p $1 2>&1`
else
echo $sndate $(hostname) SNA is ACTIVE. > /tmp/sna.log
if [[ -n `echo $SNAresp|grep "SNA software has not been initialised"` ]];
then
rc=16
fi
fi
if [[ $rc = '0' ]]; then
SNAresp=`sna -d l -p $1 2>&1`
if [[ -z `echo $SNAresp|grep "Active"` ]]; then
print "`Now` $Script : $1 is not active. Starting...."
# sna stop
# sleep 20
# sna start
# sleep 20
snaadmin start_ls,ls_name=$1
sleep 20
SNAresp=`sna -d l -p $1 2>&1`
if [[ -z `echo $SNAresp|grep "Active"` ]]; then
print "`Now` $Script : $1 is not active. Starting....$2"
snaadmin start_ls,ls_name=$2
SNAresp=`sna -d l -p $2 2>&1`
if [[ -z `echo $SNAresp|grep "Active"` ]]; then
rc=8
fi
fi
# else
# snaadmin stop_ls,ls_name=$2
fi
fi
if [[ $rc != '0' ]]; then
print "`Now` $Script : $1 Not Active : $SNAresp"
fi
return $rc
}
#=======================================================================
#
# Main Routine
#
#=======================================================================
export PATH=$PATH:$HOME
Script=${0##/*/}
chkSNA IPL0 IPL1
rc=$?
if [[ $rc != '0' ]]; then
print "`Now` $Script : SNA Link inactive ... paging. "
#print "`Now` $Script : SNA Link inactive .... paging"
#GenPage "`uname -n`:SNA:1" "SNA or Link down on `uname -n`"
fi
print "`Now` $Script : Ended rc=$rc."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment