Monday, June 8, 2015

How to collect COW heap free size and poll in to data store

 Since I'm not Linux guy, I have created  basic script to  poll COW heap free size percentage per second to my NFS data store

example: I  have created perf folder in my nfs data store and every second the free size percentage will be polled in to perf folder
/bin # cat getPerf.sh
#!/bin/sh

########################################################
#
# getPerf.sh
#
# Gather necessary ESXi performance data.
# Permenantly store in _nfs_00/Perf/,
# Also forwards to syslog server for monitoring.
#
#
########################################################

#### Varibles ####
HOSTNAME=`hostname -s`
DATE=`date +%Y-%m-%d`
COWHEAP_ENTRY=`vsish -e ls /system/heaps/ |grep cow`
COWHEAP_FULLENTRY=/system/heaps/"$COWHEAP_ENTRY"stats

OUTPUTLOCATION=/vmfs/volumes/datastore_nfs_00/Perf
OUTPUTFILE=$OUTPUTLOCATION/COWHeap_"$HOSTNAME"_$DATE

COWHEAP_FREE=`vsish -e cat $COWHEAP_FULLENTRY | grep "percent free of max size:" |sed 's/percent free of max size://'`

#### Outputs ####
echo `date +%Y-%m-%d_%H:%M:%S;` $HOSTNAME $COWHEAP_FREE >> $OUTPUTFILE
logger -t COWHeap $HOSTNAME $COWHEAP_FREE



out put is as below

date and time Host name ( black marked) and free size



don't worry about the out put file size and it's about only 45KB per day.

 how to schedule the script in ESXi.

just add your script in to your crontab root file as follow. here I have added my getperf.sh script to run every minute





 for more details about crontab refer to this http://www.nncron.ru/help/EN/working/cron-format.htm