Some old school Unix tricks to pacer VMware logs.

Probably most of you already are using some tool to collect, manage and search log files. One of them can be vRealize Log Insight which is very handy.

But in some other scenario you will be happy to know the below commands to check in the fast way ESXi logs. 

Keep in mind that most of the command should work (as it was tested) but without any guarantee as ESXi uses busybox instead of a full shell environment. 

Most of the commands is not presented in the most elegant way, but should be easy to remember:

  1. Show all lines in log file:

    cat /var/log/LOG.log (ie: cat /var/log/vmkernel.log)

    This will produce a lot of lines of code (probably hundreds of lines). To scroll up (if you are using linux terminal) you can try to use shift+pg_up. Most of the terminal’s clients (putty) can have specified the number of lines to remember.
  1. Check the number of lines with two entries:

    grep 'first entry with lines' FILE | grep 2020-07-14 | wc -l
  2. Check the number of lines but ignore case

    grep -i "H:0x7 D:0x0 P:0x0" vmkernel.all | awk '{print$12}' | sort | uniq -c | grep naa.XXX | less
  3. Check the number of lines with are unique with the number of occurrences for specified rows:

    grep 'first entry with lines' FILE | grep 2020-07-14 | awk '{print$12,$15}' | sort | uniq -c | less
  4. Search for all lines without a given string:

    grep -v “string” /var/log/File.log
  1. grep can lines count by its own:

    cat FILE.txt | grep -c “string

  2. sort output (in reverse order) considering the first line as a number:

    du -sm * | sort -rn
  3. print just those lines with number from given column:

    cat FILE.txt | awk ‘{print $5}’ | grep ‘[0-9]’
  1. if you do not want to print some rows use sed FROM_NR,TO_NR,d

    cat FILE.txt | awk ‘{print $4}’ | sed 1,4,d
  2. show first and last lines in the file:

    tail -NUMBER FILE.txt
    head -NUMBER FILE.txt
  1. show change in the file on the fly:

    tail -f FILE.txt
  1. finding only the filenames with string:

    grep -l “string” FILE.txt

https://blogs.vmware.com/kb/2016/01/host-disconnected-from-vcenter-and-vms-showing-as-inaccessible.html

http://web.stanford.edu/class/cs124/kwc-unix-for-poets.pdf

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

VMware
VCF, backup configuration

Backup implementation for VMware component is fairly easy. Just the requirements is to configure SFTP server in proper way and make it network available to the VMware components. SDDC Manager and NSX Manager backup In VCF Operations it is possible to configure backup for SDDC Manager and NSX Manager. Go …

VMware
VCF Automation, fresh environment configuration with identity providers and access control.

Introduction Login Login as user admin to the Organization name: system or if selected manual: Check the connections (in Administration section), where you should see connection to the vCenter and NSX-t manager as those are provided automatically via VCF Operations: the same for VCF Instances: Also check your networking: Identity …

VMware
VCF SoS

SoS (Supportability and Serviceability) command can be used for troubleshooting purpose to generate VCF (per component) log bundle, massively enable/disable ssh service on ESXi, vCenter, password and certificates expiry status, verify cluster health and many other. while troubleshooting, the following commands can be helpful: