Team,
Is there any plugin to monitor Memory usage on Non-global zone in Solaris.
Regards,
Pratap.
plugin to monitor Memory usage on Non-global zone in Solaris
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: plugin to monitor Memory usage on Non-global zone in Sol
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?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: plugin to monitor Memory usage on Non-global zone in Sol
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
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
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: plugin to monitor Memory usage on Non-global zone in Sol
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
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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: plugin to monitor Memory usage on Non-global zone in Sol
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.
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$ ~You do not have the required permissions to view the files attached to this post.
Re: plugin to monitor Memory usage on Non-global zone in Sol
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.
Former Nagios employee
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: plugin to monitor Memory usage on Non-global zone in Sol
Great stuff, you're nearly there.
You need to remove the space between the value and the MB.
You have:
It needs to be:
Also, you should probably delete the existing .rrd and .xml file to prevent any further issues from the past data received.
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 MBCode: Select all
${used_memory}MB
Which outputs:
used_memory=13312MBCode: 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: plugin to monitor Memory usage on Non-global zone in Sol
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.
Thank you very much for your support.
Thanks again.
You may close the ticket.