Monday, May 4, 2020

#!/bin/bash
# Middleware Port Monitor Script
# Author : Sampathkumar
# mkdir -p /home/mw/scripts/ ; touch /home/mw/scripts/PortMon.sh;chmod +x /home/mw/scripts/PortMon.sh;touch /home/mw/scripts/portlist
# crontab -e & add the below entry
# Monitor Middleware Instance's Port every minutes using PortMon.sh
# * * * * * /home/mw/scripts/PortMon.sh > /home/mw/scripts/PortMon.log 2>&1
# The following code may be needed on few of the servers to work the mailing services properly
# uuencode $MAIL_OP $MAIL_OP |/usr/bin/mail -r '' -s "$SUBJ" "$TOList"

TODAY=`date +%d%m%y`
TIME=`date +%R`
host=`hostname`
AppName=''
Env='PRD'
PortStatus=/home/mw/scripts/PortMon.log
cat /dev/null> $PortStatus
TOList=
SUBJ="["$Env"-"$AppName"]Port:"$port" on "$host" is DOWN!!! `date +%d-%m-%Y`"

for port in `cat /home/mw/scripts/portlist`
do

echo "^]" | telnet $host $port > /dev/null 2>&1
ec=`echo $?`

  if [ $ec -eq 0 ]
    then
                              echo "Port $port is up.." > /dev/null
    else
                              SUBJ="["$Env"-"$AppName"]Port:"$port" on "$host" is DOWN!!! `date +%d-%m-%Y`"
                              echo "Hi Service Desk," > $PortStatus
                              echo "Please raise an Incident Ticket & assign to Middleware team immediately to check the port "$port" & respective services as its is not running on the Server "$host"." >> $PortStatus
                              echo "" >> $PortStatus
                              echo "Importance: High" >> $PortStatus
                              echo "Time: `date`" >> $PortStatus
                              echo "Requestor Name: Middleware" >> $PortStatus
                              echo "">> $PortStatus
                              echo "Description: The port "$port" is on the server "$host" not running currently." >> $PortStatus
                              echo "Affected Application: ["$AppName"]" >> $PortStatus
                              echo "Port: ["$port"]" >> $PortStatus
                              echo "Environment: ["$Env"]" >> $PortStatus
                              echo "Initial Assignment Group:[Middleware]" >> $PortStatus
                              echo "Incident queue : []" >> $PortStatus
                              echo "Severity: [S3]" >> $PortStatus
                              echo "" >> $PortStatus
                              echo "With Regards," >> $PortStatus
                              echo "Middleware Team| Support" >> $PortStatus
                              echo "" >> $PortStatus
                              /usr/bin/mail -r "" -s "$SUBJ" "$TOList" < $PortStatus
                              #rm $PortStatus
fi

done
exit 0

01# Add a client certificate to the Queue manager keystore (using stashed password)
02ikeycmd -cert -add -db "key.kdb" -label ibmwebspheremqclient01 -file ibmwebspheremqclient01.crt -format ascii -stashed
03 
04# Remove certificate from Queue manager keystore (using stashed password)
05ikeycmd -cert -delete -label ibmwebspheremqclient01 -db "key.kdb" -stashed
06 
07# Set default certificate (using stashed password)
08ikeycmd -cert -setdefault -db key.kdb -stashed -label "mydefaultcertificate"
09 
10# List certificates
11ikeycmd -cert -list personal -db "key.kdb" -pw changeit
12ikeycmd -cert -list ca -db "key.kdb" -pw changeit
13 
14* List default signers
15ikeycmd -cert -listsigners