0% found this document useful (0 votes)
6 views1 page

Web Logic Status Email

This Bash script checks the status of specified WebLogic Server instances and categorizes them into failed and running servers. It uses curl to retrieve server status and jq to parse the JSON response. Finally, it sends an email report listing the status of the servers to a specified email address.

Uploaded by

sumitprasad0035
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Web Logic Status Email

This Bash script checks the status of specified WebLogic Server instances and categorizes them into failed and running servers. It uses curl to retrieve server status and jq to parse the JSON response. Finally, it sends an email report listing the status of the servers to a specified email address.

Uploaded by

sumitprasad0035
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#!

/bin/bash

# Define WebLogic Server details


WEBLOGIC_USER="weblogic"
WEBLOGIC_PASSWORD="weblogic123"
WEBLOGIC_PORT="7001"
IP_ADDRESS="localhost"

# Define email details


EMAIL_TO="[email protected]"
EMAIL_SUBJECT="WebLogic Server Status Report"
EMAIL_BODY=""

# Define arrays to store failed and running servers


failed_servers=()
running_servers=()

# Define the server instances


servers=("AdminServer" "cv2_dev_ms1" "cv2_dev_ms2")

# Loop through each server and check its status


for server in "${servers[@]}"
do
echo "Checking status of $server..."
server_status=$(curl -su $WEBLOGIC_USER:$WEBLOGIC_PASSWORD http://$IP_ADDRESS:
$WEBLOGIC_PORT/management/weblogic/latest/domainRuntime/serverRuntimes/$server)

# Parse JSON response to extract "title" and "state"


title=$(echo "$server_status" | jq -r '.title')
state=$(echo "$server_status" | jq -r '.state')

if [ "$title" == "FAILURE" ]; then


echo "$server is not reachable or an error occurred."
failed_servers+=("$server")
elif [ "$state" == "RUNNING" ]; then
echo "$server is running."
running_servers+=("$server")
else
echo "$server is in an unknown state."
fi
done

# Prepare email body


EMAIL_BODY+="Failed Servers: $(IFS=, ; echo "${failed_servers[*]}")"$'\n'
EMAIL_BODY+="Running Servers: ${running_servers[@]}"

# Send email
echo "$EMAIL_BODY" | mail -s "$EMAIL_SUBJECT" "$EMAIL_TO"
if [ $? -eq 0 ]; then
echo "Email sent successfully."
else
echo "Failed to send email."
fi

You might also like