Posts

Shell script for system and process monitor

Below is a simple shell script that can SSH from one host to four other remote hosts and checks the memory, CPU usage, and currently running processes for an application. If the CPU or memory usage exceeds 85%, the script will log it and send the output via email in a table format. Assumptions: 1. The script assumes SSH access to the remote hosts is already set up (using SSH keys or passwordless SSH). 2. The script uses `ps`, `top`, `free`, and `awk` for system resource information. 3. The `mail` command is available on the system for sending emails. Script: `check_resources.sh` ```bash #!/bin/bash Define the list of remote hosts HOSTS=("host1" "host2" "host3" "host4") Define the application name to monitor (replace with your app name) APP_NAME="your_application_name" Define the email recipient EMAIL_RECIPIENT="your_email@example.com" Define the log file LOG_FILE="/tmp/resource_usage_log.txt" Initialize the ...

Shell Script for WebSphere Patching

#!/bin/bash # Configuration WAS_HOME="/opt/IBM/WebSphere/AppServer" # WebSphere home directory PROFILE_NAME="AppSrv01" # WebSphere profile name IMCL_PATH="/opt/IBM/InstallationManager/eclipse/tools/imcl" # Installation Manager CLI path REPOSITORY_PATH="/path/to/repository" # Path to the repository containing the patches LOG_DIR="$WAS_HOME/logs/patching" # Directory to store patch logs PATCHES="com.ibm.websphere.ND.v85_8.5.5.15" # Patch ID(s) # Create log directory if it doesn't exist mkdir -p "$LOG_DIR" # Stop the server echo "Stopping WebSphere server..." "$WAS_HOME/profiles/$PROFILE_NAME/bin/stopServer.sh" server1 if [ $? -ne 0 ]; then echo "Failed to stop WebSphere server. Exiting." exit 1 fi # Apply the patch echo "Applying WebSphere patch..." "$IMCL_PATH" install "$PATCHES" -repositories "$REPOSITORY_PATH...

Was Patching

#!/bin/bash # Configuration WAS_HOME="/opt/IBM/WebSphere/AppServer" # WebSphere home directory PROFILE_NAME="AppSrv01" # WebSphere profile name IMCL_PATH="/opt/IBM/InstallationManager/eclipse/tools/imcl" # Installation Manager CLI path REPOSITORY_PATH="/path/to/repository" # Path to the repository containing the patches LOG_DIR="$WAS_HOME/logs/patching" # Directory to store patch logs PATCHES="com.ibm.websphere.ND.v85_8.5.5.15" # Patch ID(s) # Create log directory if it doesn't exist mkdir -p "$LOG_DIR" # Stop the server echo "Stopping WebSphere server..." "$WAS_HOME/profiles/$PROFILE_NAME/bin/stopServer.sh" server1 if [ $? -ne 0 ]; then echo "Failed to stop WebSphere server. Exiting." exit 1 fi # Apply the patch echo "Applying WebSphere patch..." "$IMCL_PATH" install "$PATCHES" -repositories "$REPOSITORY_PATH...

Script for WebSphere Log Housekeeping

#!/bin/bash # Configuration LOG_DIR="/path/to/websphere/logs" # Directory where logs are stored ARCHIVE_DIR="/path/to/websphere/archive" # Directory to move compressed logs DAYS_TO_KEEP=30 # Number of days to keep logs before deletion LOG_EXTENSION="log" # Log file extension (e.g., log, out) # Create archive directory if it doesn't exist mkdir -p "$ARCHIVE_DIR" # Find and compress log files older than $DAYS_TO_KEEP days find "$LOG_DIR" -name "*.$LOG_EXTENSION" -type f -mtime +$DAYS_TO_KEEP -exec gzip {} \; -exec mv {}.gz "$ARCHIVE_DIR" \; # Delete compressed log files older than $DAYS_TO_KEEP days from the archive directory find "$ARCHIVE_DIR" -name "*.$LOG_EXTENSION.gz" -type f -mtime +$DAYS_TO_KEEP -exec rm -f {} \; # Log the housekeeping activity echo "$(date +'%Y-%m-%d %H:%M:%S') - WebSphere log housekeeping completed" >>...

Some Exceptions in Websphere Application Server

Hi Friends , today we will discuss about some errors and exceptions in WAS.  Application profiling exceptions : The following exceptions are thrown in response to various illegal actions related to application profiling.  com.ibm.ws.exception.RuntimeWarning :  This exception is thrown when the application is started, if the application is configured incorrectly. The startup is consequently terminated. Some examples of bad configurations include: v A task configured on two different application profiles. v A method configured with two different task run-as policies .  com.ibm.websphere.appprofile.IllegalTaskNameException :  This exception is raised if an application attempts to programmatically set a task when that task has not been configured as a task name reference. Error: java.lang.NoClassDefFoundError: Explaination:  This exception is thrown when Java code cannot load the specified class. Possible Cause:  Invalid or non-existent class...

Some important unix commands and resolved deployment issue.

CPU for top 10 process: ps aux | sort -nrk 3,3 | head -n 10 Certificate Expiry date: ** gsk8capicmd_64 -cert -details -db key.kdb -stashed -label | sed -n -e 1,8p | cut -f1 ** echo q | openssl s_client -connect IHSHOSTNAME:443 | openssl x509 -noout -enddate grep "21:0[5-9]" logfile **Determines top 5 proceses  svmon -Pu -t 5 | grep -p Pid | grep '^.*[0-9]' ** Last Logged in user on system: last | head -n 10 | awk NR==1'{print $1}' *** Chk memory in GB and MB: **svmon -G -O unit=GB **svmon -G -O unit=MB ** svmon -C java -O filtertype=working,segment=category,filtercat=exclusive,unit=MB ** Chk the largest file size in dir: du -sk * | sort -rn | head -5 ==================================================================== Application was not deployed successfully: Deployment of the  1st  ear completed successfully however 2nd ear couldn’t be exploded in the container because of which you are not...

Java heap memory leak or sizing problem? .

Situation Occasionally when reviewing a heapdump that was generated from an out of memory event, the largest consumer of heap memory may consume slightly more memory than the other objects. Because of this, WebSphere users and moderators may incorrectly accuse the largest heap consumer as a memory leak.   If a Java™ heap is sized too small, an out of memory error will occur regardless if a memory leak exists. The leak suspect shown in IBM HeapAnalyzer or Memory Analyzer (MAT) will show a java object that is expected to exhaust a relatively larger portion of the heap.   Resolution The best course of action will be to increase the heap size and enable verboseGC (if not already enabled). Doing this will produce one of two results: it will alleviate the out of memory problem by letting your heap utilize more memory, or the leaking object will cause another out of memory event. If the test yields the first of the two outcomes, the administrator ca...