When you meet some performance issue on esxi platform , you will need the esxtop tools to trouble shooting .
Sometimes , I usually get a log files, but the issue time just in one csv . Use following command
But If you need pick up ten or more column , you need a python script.Thanks my friend Haojie help on that.
Here is summary :
1 Create header files from CSV
2 Generate your custom column number to a column files
3 Get your interesting data.
Now this article just discussed , how to find useful data from the esxtop perf data .
Get the performance data
How to collect data , you can read the KB
Gathering esxtop performance data at specific times using crontab (1033346)
Or write a simple bash script to collect 24 hours performance data . Depend on your real environment , you change the esxtop parameter.
!-- HTML generated using hilite.me -->#!/bin/bash for i in $(seq 1 24) do echo $i >> esxtop.log esxcli system time get >> esxtop.log esxtop -lab -d 2 -n 1800 >$i.csv esxcli system time get >> esxtop.log done
1 get interesting csv file
for i in $(ls *.csv); do echo ======$i====== ;head -2 $i |awk -F , '{print $1}'; done
2 generate the headers( this part ,I referenceed http://virtuallyhyper.com/)
$ head -1 esxtop-b.csv | sed 's/\,/\n/g' > headers
Now checking out the ‘headers’ file, I saw the following:
$ head headers
"(PDH-CSV 4.0) (UTC)(0)"
"\\local\Memory\Memory Overcommit (1 Minute Avg)"
"\\local\Memory\Memory Overcommit (5 Minute Avg)"
"\\local\Memory\Memory Overcommit (15 Minute Avg)"
"\\local\Physical Cpu Load\Cpu Load (1 Minute Avg)"
"\\local\Physical Cpu Load\Cpu Load (5 Minute Avg)"
"\\local\Physical Cpu Load\Cpu Load (15 Minute Avg)"
"\\local\Physical Cpu(0)\% Processor Time"
"\\local\Physical Cpu(1)\% Processor Time"
"\\local\Physical Cpu(2)\% Processor Time"
The columns are now separated by new lines, that's I want
Searching keyword , and get the number
grep -n 'SCSI.*Average Driver MilliSec/Command' heades
27183:"\\localhost\Physical Disk SCSI Device(naa.6005076801828732d800000000000151)\Average Driver MilliSec/Command"
29286:"\\localhost\Physical Disk SCSI Device(naa.6234567890abcde01e30fcc911b435f5)\Average Driver MilliSec/Command"
You can use awk >> to generate new file "column" and store the column number which you want .
grep -n 'SCSI.*Average Driver MilliSec/Command' heades | awk -F : '{print $1}' >> column
check the content
$ head column
27183
29286
If you just need pick up 2 or 3 column , you can use following command
1 | awk -F , '{print $1","$27183","$29286}' esxtop-b.csv > latency.csv
|
But If you need pick up ten or more column , you need a python script.Thanks my friend Haojie help on that.
import pandas as pd df = pd.read_csv('esxtop-b.csv', header=None) df_new = pd.DataFrame(df[[0]]) with open('coloumn') as f: for line in f: df_new = df_new.join(df[[int(line)]]) df_new.to_csv('out.csv')
Here is summary :
1 Create header files from CSV
2 Generate your custom column number to a column files
3 Get your interesting data.