#!/bin/sh
memuse=$(ps -p $(pidof java) -o %mem | awk ‘{if(NR>1)print}’);
thresholdVal=50;
if [ $memuse > $thresholdVal ];
then
message=”Memory usage for jboss service on application server exceeded threshold.nCurrent use is $memuse %.”
echo -e $message | mail -s “Alert : Memory monitoring UHMB” “prahlad20@gmail.com”;
fi
cpuuse=$(ps -p $(pidof java) -o %cpu | awk ‘{if(NR>1)print}’);
if [ $cpuuse > $thresholdVal ];
then
message=”CPU usage for jboss service on application server exceeded threshold.nCurrent use is $cpuuse %.”;
echo -e $message | mail -s “Alert : CPU monitoring UHMB” “prahlad20@gmail.com”;
fi
memuse=$(ps -p $(pidof java) -o %mem | awk ‘{if(NR>1)print}’);
thresholdVal=50;
if [ $memuse > $thresholdVal ];
then
message=”Memory usage for jboss service on application server exceeded threshold.nCurrent use is $memuse %.”
echo -e $message | mail -s “Alert : Memory monitoring UHMB” “prahlad20@gmail.com”;
fi
cpuuse=$(ps -p $(pidof java) -o %cpu | awk ‘{if(NR>1)print}’);
if [ $cpuuse > $thresholdVal ];
then
message=”CPU usage for jboss service on application server exceeded threshold.nCurrent use is $cpuuse %.”;
echo -e $message | mail -s “Alert : CPU monitoring UHMB” “prahlad20@gmail.com”;
fi