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.

Free(BSD)
Search for duplicated files

This will be short (but hopefully I will find more time to show entire process to search duplicated files together with some examples). In case you are searching for duplicated files I can recommend two software which actually rocks in openSource world

Azure
NFS issue, cannot be mounted or is not visible

The same kind of issue I have encountered numerous times while working across different environments and with various customers. The problem with NFS mounts connected from remote locations is so common. This issue extends beyond communication solely over WAN and also include connections between datacenters (DC) where we lack control …

Azure
Why Firefox is important and people should use this browser in 2024, my thoughts.

Can you remember the times when everyone was using Internet Explorer? Back in the ’90s and the early part of this century, Internet Explorer dominated the browser market. Software Incompatibility with Other Browsers Incompatibility issues with software and other browsers have been a persistent problem. Even in 2022, this remains …