Adding Memory utilization script monitor for HP-UX devices

Adding Memory utilization script monitor for HP-UX devices

Question: CLI based memory utilization monitor shows wrong value in OpManager for HP-UX servers , how do I add custom script monitor as a work around?

Solution: You can add script monitor and associate to HP-UX devices , go to admin > Script Templates > New Template  , fill in monitor name , Description, Interval , Units under Monitor details.

command line  : sh ${FileName}.sh  

Script body 

T=`/usr/contrib/bin/machinfo |awk '/Memory/'|awk -v c=0 '{for (i=0;i<=NF;i++) if($i=="MB") c=i-1;}{print $c}'`;
F=`vmstat 1 3|awk -v c=0 '{for (i=0;i<=NF;i++) if ($i=="free") c=i;} {print $c}'|tail -1`;


echo Data:
echo Memory   `echo "scale=3; ((($T-($F*4/1024))/$T)*100)"|bc`


Execute From : Monitored Machine

Save the template , go to device snapshot page > Monitors >  Script Monitors > Click here to add Script Monitors> click add on the one you created .