Page 1 of 1
plugin to monitor Memory usage on Non-global zone in Solaris
Posted: Thu Jul 31, 2014 8:28 am
by plakshmi
Team,
Is there any plugin to monitor Memory usage on Non-global zone in Solaris.
Regards,
Pratap.
Re: plugin to monitor Memory usage on Non-global zone in Sol
Posted: Fri Aug 01, 2014 11:28 am
by sreinhardt
Off the top of my head, I have do not have an answer. What options have you looked into so far, have you checked exchange, maybe an snmp oid could provide it, etc?
Re: plugin to monitor Memory usage on Non-global zone in Sol
Posted: Thu Aug 07, 2014 12:53 pm
by plakshmi
We have written customized script for this requirement. Script is working fine and we are getting desired output but graphs are not getting displayed. Can you plese suggest us.
Following is the script.
#! /bin/sh
#### usage is the function which tells what options and agruments to be passed to the script"
usage()
{
echo "Usage : $0 -u -w <warning> -c <critical>"
}
if [ $# -lt 1 ]
then
usage;
exit;
fi
###### Initialization of variables ############################
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
exitstatus=$STATE_WARNING
#host_name=`uname -n`
host_name=`hostname|cut -d "." -f1`
#############################################################################
######### calculating total memory used memory and free memory ##########
total_memory_mb=`/usr/sbin/prtconf 2>/dev/null|grep "Memory"|tail -1|cut -d":" -f 2|awk '{print $1}'`
used_memory=`prstat -s rss -Z 1 1|grep $host_name|awk '{print $4}'|sed 's/[GM]//'`
prstat -s rss -Z 1 1|grep $host_name|awk '{print $4}'|grep G > /dev/null
if [ $? -eq 0 ]
then
used_memory=`expr $used_memory \* 1024`
fi
free_memory=`expr $total_memory_mb - $used_memory`
#####################################################################################################
while getopts w:c:u choice
do
case $choice in
w ) warn_level=$OPTARG;
;;
c ) crit_level=$OPTARG;
;;
u ) echo -n
;;
? ) echo "Illegal option"
usage
exit
;;
esac
done
if [ $warn_level -ge 100 ]
then
echo "Warning level can not be greater than or equal to 100"
exit
fi
if [ $crit_level -ge 100 ]
then
echo "Critical level can not be greater than or equal to 100"
exit
fi
if [ $warn_level -ge $crit_level ]
then
echo "Warning level can not be greater or equal to critical level"
exit
fi
warning=`expr $warn_level \* $total_memory_mb / 100`
critical=`expr $crit_level \* $total_memory_mb / 100`
used_memory_temp=`expr $used_memory \* 100`
used_memory_percent=`echo "scale=2; $used_memory_temp / $total_memory_mb"|bc`
#echo "Percentage of used memory $used_memory_percent"
if [ $used_memory -ge $warning -a $used_memory -le $critical ]
then
echo "WARNING - $used_memory_percent% ($used_memory MB) used"
exitstatus=$STATE_WARNING
exit $exitstatus
fi
if [ $used_memory -ge $critical ]
then
echo "CRITICAL - $used_memory_percent% ($used_memory MB) used"
exitstatus=$STATE_CRITICAL
exit $exitstatus
fi
if [ $used_memory -lt $warning ]
then
echo " OK - $used_memory_percent% ($used_memory MB) used"
exitstatus=$STATE_OK
exit $exitstatus
fi
Re: plugin to monitor Memory usage on Non-global zone in Sol
Posted: Thu Aug 07, 2014 8:45 pm
by Box293
Your script is not generating a performance data string. Anything after a pipe symbol | will be treated as performance data, however it needs to be formatted correctly.
Here are some resources that explain all of this:
Nagios Plugin Development Guidelines
Here is a presentation I did at the Nagios World Conference:
Video
Slides
Re: plugin to monitor Memory usage on Non-global zone in Sol
Posted: Tue Aug 12, 2014 10:33 am
by plakshmi
we tried to change some code as per your suggestion it is now showing performance data in advanced tab but graphs are still not working.
Attached screenshots of output for refernce.please suggest if we missed out anything
here is code which we changed.
Code: Select all
if [ $used_memory -ge $warning -a $used_memory -le $critical ]
then
echo "WARNING - $used_memory_percent% ($used_memory MB) used|used_memory=$used_memory MB;$warning;$critical;0;$total_memory_mb"
exitstatus=$STATE_WARNING
exit $exitstatus
fi
if [ $used_memory -ge $critical ]
then
echo "CRITICAL - $used_memory_percent% ($used_memory MB) used|used_memory=$used_memory MB;$warning;$critical;0;$total_memory_mb"
exitstatus=$STATE_CRITICAL
exit $exitstatus
fi
if [ $used_memory -lt $warning ]
then
echo " OK - $used_memory_percent% ($used_memory MB) used|used_memory=$used_memory MB;$warning;$critical;0;$total_memory_mb"
exitstatus=$STATE_OK
exit $exitstatus
fi
-bash-3.2$ ~
Re: plugin to monitor Memory usage on Non-global zone in Sol
Posted: Tue Aug 12, 2014 5:03 pm
by tmcdonald
How long are you waiting before checking the graphs? And how often is the check run? It can take some time for results to show up in the graph depending on the specific check.
Re: plugin to monitor Memory usage on Non-global zone in Sol
Posted: Tue Aug 12, 2014 9:51 pm
by Box293
Great stuff, you're nearly there.
You need to remove the space between the value and the MB.
You have:
Code: Select all
$used_memory MB
Which outputs:
used_memory=13312 MB
It needs to be:
Code: Select all
${used_memory}MB
Which outputs:
used_memory=13312MB
Code: Select all
echo "WARNING - $used_memory_percent% ($used_memory MB) used|used_memory=${used_memory}MB;$warning;$critical;0;$total_memory_mb"
echo "CRITICAL - $used_memory_percent% ($used_memory MB) used|used_memory=${used_memory}MB;$warning;$critical;0;$total_memory_mb"
echo " OK - $used_memory_percent% ($used_memory MB) used|used_memory=${used_memory}MB;$warning;$critical;0;$total_memory_mb"
Also, you should probably delete the existing .rrd and .xml file to prevent any further issues from the past data received.
Re: plugin to monitor Memory usage on Non-global zone in Sol
Posted: Thu Aug 14, 2014 11:23 am
by plakshmi
We could able to see performance graphs after removing the space between variable and MB in the script and after deleting .rrd and .xml files.
Thank you very much for your support.
Thanks again.
You may close the ticket.