<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David&#039;s technobabble &#187; cacti</title>
	<atom:link href="http://bable.cybermarshall.com/tag/cacti/feed/" rel="self" type="application/rss+xml" />
	<link>http://bable.cybermarshall.com</link>
	<description>David&#039;s thoughts about this and that</description>
	<lastBuildDate>Fri, 22 Jan 2010 18:29:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tracking VMWare ESX 3.x or ESXi Host resources with Cacti</title>
		<link>http://bable.cybermarshall.com/2008/12/14/tracking-vmware-esx-3x-or-esxi-host-resources-with-cacti/</link>
		<comments>http://bable.cybermarshall.com/2008/12/14/tracking-vmware-esx-3x-or-esxi-host-resources-with-cacti/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 04:22:28 +0000</pubDate>
		<dc:creator>david</dc:creator>
				<category><![CDATA[virtualization]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[esx]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[esxtop]]></category>
		<category><![CDATA[resxtop]]></category>
		<category><![CDATA[rrdtool]]></category>
		<category><![CDATA[snmp]]></category>
		<category><![CDATA[vmware esx]]></category>

		<guid isPermaLink="false">http://bable.cybermarshall.com/?p=71</guid>
		<description><![CDATA[I&#8217;ve been using Cacti,  RRDTool, SNMP and custom scripts running on Linux for several years to collect and display historical data regarding Network, System, and FlexLM license resource usage. I recently began tracking the Host resources used by ESX.  I was interested in tracking the following:

CPU utilization
Memory Free
Total Memory
IO activity
Network traffic


I found that the IO [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Cacti,  RRDTool, SNMP and custom scripts running on Linux for several years to collect and display historical data regarding Network, System, and FlexLM license resource usage. I recently began tracking the Host resources used by ESX.  I was interested in tracking the following:</p>
<ul>
<li>CPU utilization</li>
<li>Memory Free</li>
<li>Total Memory</li>
<li>IO activity</li>
<li>Network traffic</li>
</ul>
<p><span id="more-71"></span></p>
<p>I found that the IO activity and Network traffic could be obtained via standard SNMP. The network traffic can be obtained by summing the results from an snmpwalk of VMWARE-RESOURCES-MIB::netHCKbRx and VMWARE-RESOURCES-MIB::netHCKbTx.  Similarly, the IO can be obtained by summing the results from an snmpwalk of VMWARE-RESOURCES-MIB::kbRead and VMWARE-RESOURCES-MIB::kbWritten.</p>
<p style="text-align: left;">I did not identify items in the vmware esx mib that I could use via SNMP for the CPU utilization or Free Memory. I did find that these items are available by running esxtop or resxtop in batch mode. Running the utility esxtop on the ESX service console in batch outputs a comma separated file, csv. For example: running the command <em></em></p>
<ul><em>esxtop -b -n 2 -d 10 &gt; esxtop-output.csv</em></ul>
<p style="text-align: left;">will run esxtop in batch, take 2 samples with a delay of 10 seconds and write a 3 row csv file named &#8220;esxtop-output.csv&#8221;. The 1<sup>st</sup> line of the .csv file contains the column headers. The ESX Host cpu utilization time will be in a column named:</p>
<p style="margin-left: 40px; text-align: left;">&#8220;\\[your-esx-hostname]\Physical Cpu(_Total)\% Processor Time&#8221;</p>
<p style="text-align: left;">The ESX Host free memory will be in a column named:</p>
<p style="margin-left: 40px; text-align: left;">&#8220;\\[your-esx-hostname]\Memory\Free MBytes&#8221;.</p>
<p style="text-align: left;">The ESX Host total memory will be in a column named:</p>
<p style="margin-left: 40px; text-align: left;">&#8220;\\[your-esx-hostname]\Memory\Machine MBytes&#8221;.</p>
<p style="text-align: left;">Today, I run 2 cronjobs; 1 on my ESX service console to run esxtop in batch and save the data to a .csv file; and the 2<sup>nd</sup> on my Cacti monitoring server.  On the Cacti monitoring server, I run a &#8220;driver&#8221; <a href="#get_update_esx_stats">script</a> to collect data items into an RRDTool database every 5 minutes. My Cacti monitoring server uses identity based ssh/scp to get the .csv file that is produced by the cronjob that runs on the ESX service console.The RRD database is mapped as a datasource and graphed via Cacti.  I&#8217;m currently looking at using the VMWare remote cli version of esxtop, rexstop. The use of resxtop, would eliminate the need for a cronjob on the ESX service console. This will allow my utilities to run against both ESX and ESXi.</p>
<hr />
<p style="text-align: left;">Scripts</p>
<hr /><a id="get_update_esx_stats" name="get_update_esx_stats"></a></p>
<p>ESX RRDTool Data update Script. Call with Arguments DBName, Hostname and community, this driver ccript calls this script to obtain the <a href="#get_esx_perf">individual items</a></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p71code5'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p715"><td class="code" id="p71code5"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
. <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>setrrdtool_vars
<span style="color: #007800;">PERF_BASE</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>perfmon-esx
<span style="color: #007800;">PATH</span>=<span style="color: #800000;">${PERF_BASE}</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #800000;">${PATH}</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># arg 1 - DBNAME</span>
<span style="color: #666666; font-style: italic;"># arg 2 - monitor host</span>
<span style="color: #666666; font-style: italic;"># arg 3 - community</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;must supply rrd dbname&quot;</span>
   <span style="color: #007800;">call_errror</span>=<span style="color: #ff0000;">&quot;yes&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${2}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;must supply host&quot;</span>
   <span style="color: #007800;">call_errror</span>=<span style="color: #ff0000;">&quot;yes&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${3}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;must supply community&quot;</span>
   <span style="color: #007800;">call_errror</span>=<span style="color: #ff0000;">&quot;yes&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${call_error}</span>&quot;</span> = <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">DBNAME</span>=<span style="color: #800000;">${1}</span>
<span style="color: #007800;">MHOST</span>=<span style="color: #800000;">${2}</span>
<span style="color: #007800;">COMMUNITY</span>=<span style="color: #800000;">${3}</span>
&nbsp;
<span style="color: #007800;">RRD_DB</span>=<span style="color: #800000;">${PERF_BASE}</span><span style="color: #000000; font-weight: bold;">/</span>db<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${DBNAME}</span>
<span style="color: #007800;">RRD_LOG</span>=<span style="color: #800000;">${PERF_BASE}</span><span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${DBNAME}</span>.log
&nbsp;
<span style="color: #007800;">TOD</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> tline <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${T}</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">itemname</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${tline}</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">itemval</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${tline}</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${itemname}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
	<span style="color: #ff0000;">&quot;total_cpu&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	   <span style="color: #007800;">CPU</span>=<span style="color: #800000;">${itemval}</span>
	   <span style="color: #000000; font-weight: bold;">;;</span>
      <span style="color: #ff0000;">&quot;available_memory&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
         <span style="color: #007800;">MEMAVAIL</span>=<span style="color: #800000;">${itemval}</span>
         <span style="color: #000000; font-weight: bold;">;;</span>
      <span style="color: #ff0000;">&quot;total_memory&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
         <span style="color: #007800;">TOTMEM</span>=<span style="color: #800000;">${itemval}</span>
         <span style="color: #000000; font-weight: bold;">;;</span>
      <span style="color: #ff0000;">&quot;iokb_total&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
         <span style="color: #007800;">IOKB</span>=<span style="color: #800000;">${itemval}</span>
         <span style="color: #000000; font-weight: bold;">;;</span>
       <span style="color: #ff0000;">&quot;netkb_total&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
         <span style="color: #007800;">NETKB</span>=<span style="color: #800000;">${itemval}</span>
         <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
	  <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
rrdtool update <span style="color: #800000;">${RRD_DB}</span> <span style="color: #660033;">--template</span> \
CPU_utilization:Memory_available:IO_KBytes:Net_KBytes \
N:<span style="color: #800000;">${CPU}</span>:<span style="color: #800000;">${MEMAVAIL}</span>:<span style="color: #800000;">${IOKB}</span>:<span style="color: #800000;">${NETKB}</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></td></tr></table></div>

<p><a id="get_esx_perf" name="get_esx_perf"></a></p>
<p>ESX Data capture Script. Call with Arguments Hostname and community. This uses SSH/SCP, SNMP and some <a href="#get_stats">additional helper scripts to parse </a>the csv data returned by esxtop</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p71code6'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p716"><td class="code" id="p71code6"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
. <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>setrrdtool_vars
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">MIBS</span>=ALL
<span style="color: #666666; font-style: italic;"># arg 1 - monitor host</span>
<span style="color: #666666; font-style: italic;"># arg 2 - community</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;must supply host to monitor&quot;</span>
   <span style="color: #007800;">call_errror</span>=<span style="color: #ff0000;">&quot;yes&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
   <span style="color: #007800;">MHOST</span>=<span style="color: #800000;">${1}</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${2}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;must supply community&quot;</span>
   <span style="color: #007800;">call_errror</span>=<span style="color: #ff0000;">&quot;yes&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
   <span style="color: #007800;">COMMUNITY</span>=<span style="color: #800000;">${2}</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${call_error}</span>&quot;</span> = <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">PERFDIR</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>perfmon-esx
<span style="color: #007800;">PATH</span>=<span style="color: #800000;">${PATH}</span>:<span style="color: #800000;">${PERFDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #800000;">${PERFDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>esxstats
<span style="color: #007800;">WORKDIR</span>=<span style="color: #800000;">${PERFDIR}</span><span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #007800;">ESXTOPCSV</span>=mrtg-esxtop.csv
<span style="color: #007800;">CSVfile</span>=<span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-<span style="color: #800000;">${ESXTOPCSV}</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PATH
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #800000;">${WORKDIR}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #800000;">${WORKDIR}</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># use identity based ssh to copy latest csv file from ${MHOST}</span>
<span style="color: #666666; font-style: italic;"># could replace with resxtop and output output to ${CSVfile}</span>
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-Bq</span> <span style="color: #800000;">${MHOST}</span>:<span style="color: #800000;">${ESXTOPCSV}</span> <span style="color: #800000;">${CSVfile}</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Begin CPU</span>
get_cpustats <span style="color: #800000;">${CSVfile}</span> <span style="color: #800000;">${PERFDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>esxstats <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-cpustat.tmp
<span style="color: #007800;">CPUTOT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-cpustat.tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #800000;">${MHOST}</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">linenum</span>=<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">for</span> line <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${CPUTOT}</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${linenum}</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
     <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
     <span style="color: #007800;">cpupct_total</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${line}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #666666; font-style: italic;">#End CPU</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Host Available Memory</span>
get_machine_mem <span style="color: #800000;">${CSVfile}</span> <span style="color: #800000;">${PERFDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>esxstats <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-machinemem.tmp
<span style="color: #007800;">MACHINEMEM</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-machinemem.tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #800000;">${MHOST}</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">linenum</span>=<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">for</span> line <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${MACHINEMEM}</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${linenum}</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
     <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
     <span style="color: #007800;">tMachineMem</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${line}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #666666; font-style: italic;"># Adjust answer to bytes</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;MachineMem = tMachineMem * 1024&quot;</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;TotalMem = MachineMem&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Begin Used Memory</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Kernel Used Memory</span>
<span style="color: #007800;">linecnt</span>=<span style="color: #000000;">0</span>
get_kern_used_mem <span style="color: #800000;">${CSVfile}</span> <span style="color: #800000;">${PERFDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>esxstats <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-kernused.tmp
<span style="color: #007800;">KERNMEM</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-kernused.tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #800000;">${MHOST}</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">linenum</span>=<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">for</span> line <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${KERNMEM}</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${linenum}</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
     <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
     <span style="color: #007800;">tKernMem</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${line}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #666666; font-style: italic;"># Adjust answer to bytes</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;KernMem = tKernMem * 1024&quot;</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Non-Kernel Used Memory</span>
get_nonkern_used_mem <span style="color: #800000;">${CSVfile}</span> <span style="color: #800000;">${PERFDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>esxstats <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-nonkernused.tmp
<span style="color: #007800;">NONKERNMEM</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-nonkernused.tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #800000;">${MHOST}</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">linenum</span>=<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">for</span> line <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${NONKERNMEM}</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${linenum}</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
     <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
     <span style="color: #007800;">tNonKernMem</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${line}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #666666; font-style: italic;"># Adjust answer to bytes</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;NonKernMem = tNonKernMem * 1024&quot;</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># End Used Memory</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Begin Free Memory</span>
get_free_mem <span style="color: #800000;">${CSVfile}</span> <span style="color: #800000;">${PERFDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>esxstats <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-freemem.tmp
<span style="color: #007800;">FREET</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${WORKDIR}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${MHOST}</span>-freemem.tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #800000;">${MHOST}</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">linenum</span>=<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">for</span> line <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${FREET}</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${linenum}</span>&quot;</span> = <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${line}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
     <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
     <span style="color: #007800;">tAvailMem</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${line}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">'&quot;'</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #666666; font-style: italic;"># Adjust answer to bytes</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;AvailMem = tAvailMem * 1024&quot;</span>
     <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;linenum = linenum + 1&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #666666; font-style: italic;"># End Free Memory</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#IO </span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Get IO READ Write each VM</span>
<span style="color: #007800;">ALLREAD</span>=<span style="color: #000000; font-weight: bold;">`</span>snmpwalk <span style="color: #660033;">-m</span> ALL <span style="color: #660033;">-c</span> <span style="color: #800000;">${COMMUNITY}</span> <span style="color: #660033;">-v</span> 2c <span style="color: #800000;">${MHOST}</span> VMWARE-RESOURCES-MIB::kbRead <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">ALLWRITE</span>=<span style="color: #000000; font-weight: bold;">`</span>snmpwalk <span style="color: #660033;">-m</span> ALL <span style="color: #660033;">-c</span> <span style="color: #800000;">${COMMUNITY}</span> <span style="color: #660033;">-v</span> 2c <span style="color: #800000;">${MHOST}</span> VMWARE-RESOURCES-MIB::kbWritten<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">IORead</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">for</span> iobr <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${ALLREAD}</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${iobr}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${iobr}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">else</span>
       <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;IORead = IORead + iobr&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #007800;">IOWritten</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">for</span> iobw <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${ALLWRITE}</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${iobw}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${iobw}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">else</span>
       <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;IOWritten = IOWitten + iobw&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;IOTotal=IORead + IOWritten&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Get NetworkBytesTotalPerSec from each interface and calculate the total</span>
<span style="color: #007800;">ALLNET_RX</span>=<span style="color: #000000; font-weight: bold;">`</span>snmpwalk <span style="color: #660033;">-m</span> ALL <span style="color: #660033;">-c</span> <span style="color: #800000;">${COMMUNITY}</span> <span style="color: #660033;">-v</span> 2c <span style="color: #800000;">${MHOST}</span> VMWARE-RESOURCES-MIB::netHCKbRx <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">ALLNET_TX</span>=<span style="color: #000000; font-weight: bold;">`</span>snmpwalk <span style="color: #660033;">-m</span> ALL <span style="color: #660033;">-c</span> <span style="color: #800000;">${COMMUNITY}</span> <span style="color: #660033;">-v</span> 2c <span style="color: #800000;">${MHOST}</span> VMWARE-RESOURCES-MIB::netHCKbTx <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">NetRX</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">for</span> netr <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${ALLNET_RX}</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${netr}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${netr}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">else</span>
       <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;NetRX = NetRX + netr&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">NetTX</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">for</span> nett <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${ALLNET_TX}</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${nett}</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${nett}</span>&quot;</span> = <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">skipping</span>=<span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">else</span>
       <span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;NetTX = NetTX + nett&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;NetTotal=NetRX + NetTX&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> total_cpu:<span style="color: #800000;">${cpupct_total}</span> total_memory:<span style="color: #800000;">${TotalMem}</span> available_memory:<span style="color: #800000;">${AvailMem}</span> iokb_total:<span style="color: #800000;">${IOTotal}</span> netkb_total:<span style="color: #800000;">${NetTotal}</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></td></tr></table></div>

<p><a id="get_stats" name="get_stats"></a></p>
<p>ESX Data parse script(s). Call each one with the esxtop csv file to grab the data. Uses this <a href="#get_index_awk">awk script</a></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p71code7'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p717"><td class="code" id="p71code7"><pre class="bash" style="font-family:monospace;">each script is a seperate <span style="color: #c20cb9; font-weight: bold;">file</span>
<span style="color: #666666; font-style: italic;"># get_cpustats</span>
<span style="color: #007800;">CSVfile</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">NDX</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">str</span>=<span style="color: #ff0000;">&quot;Physical Cpu(_Total)&quot;</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${2}</span><span style="color: #000000; font-weight: bold;">/</span>get_index_awk<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">i</span>=<span style="color: #007800;">$NDX</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;,&quot;</span> <span style="color: #ff0000;">'{print $i}'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get_free_mem</span>
<span style="color: #007800;">CSVfile</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">NDX</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">str</span>=<span style="color: #ff0000;">&quot;Free MBytes&quot;</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${2}</span><span style="color: #000000; font-weight: bold;">/</span>get_index_awk<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">i</span>=<span style="color: #007800;">$NDX</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;,&quot;</span> <span style="color: #ff0000;">'{print $i}'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get_machine_mem</span>
<span style="color: #007800;">CSVfile</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">NDX</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">str</span>=<span style="color: #ff0000;">&quot;Machine MBytes&quot;</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${2}</span><span style="color: #000000; font-weight: bold;">/</span>get_index_awk<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">i</span>=<span style="color: #007800;">$NDX</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;,&quot;</span> <span style="color: #ff0000;">'{print $i}'</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#get_kern_used_mem</span>
<span style="color: #007800;">CSVfile</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">NDX</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">str</span>=<span style="color: #ff0000;">&quot;Kernel MBytes&quot;</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${2}</span><span style="color: #000000; font-weight: bold;">/</span>get_index_awk<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">i</span>=<span style="color: #007800;">$NDX</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;,&quot;</span> <span style="color: #ff0000;">'{print $i}'</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#get_managed_mem</span>
<span style="color: #007800;">CSVfile</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">NDX</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">str</span>=<span style="color: #ff0000;">&quot;Kernel Managed MBytes&quot;</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${2}</span><span style="color: #000000; font-weight: bold;">/</span>get_index_awk<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">i</span>=<span style="color: #007800;">$NDX</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;,&quot;</span> <span style="color: #ff0000;">'{print $i}'</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#get_nonkern_used_mem</span>
<span style="color: #007800;">CSVfile</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">NDX</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">str</span>=<span style="color: #ff0000;">&quot;NonKernel MBytes&quot;</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${2}</span><span style="color: #000000; font-weight: bold;">/</span>get_index_awk<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${CSVfile}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">i</span>=<span style="color: #007800;">$NDX</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot;,&quot;</span> <span style="color: #ff0000;">'{print $i}'</span></pre></td></tr></table></div>

<p><a id="get_index_awk" name="get_index_awk"></a></p>
<p>awk script used by get_cpustats, etc</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p71code8'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p718"><td class="code" id="p71code8"><pre class="none" style="font-family:monospace;">BEGIN {FS=&quot;,&quot;}
      {colndx=0;
       for (i=1; i&amp;lt;=NF; i++) {
           if (index($i,str) &amp;gt;0 ) {
               colndx=i;
               print colndx;
               i=NF;
               break;
               }
           }
      }</pre></td></tr></table></div>

<p style="text-align: left;"><center><script type="text/javascript"><!--
google_ad_client = "pub-5633552336244805";
google_ad_slot = "5649858591";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://bable.cybermarshall.com/2008/12/14/tracking-vmware-esx-3x-or-esxi-host-resources-with-cacti/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
