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.

Linux
Migrate WordPress site to another hosting service.

IntroductionThis article details the migration of WordPress site (exactly this site you are now on) from one service provider to Amazon Lightsail. There might be various reason to do that (mine is outlined below) but in general I hope to share the message that especially with WordPress, migration can be …

VMware
VMware Workstation and Fusion can be installed and use for free (even for the enterprise)

For a while now, the VMware Workstation (and Fusion for MacOS) can be used without any additional fee for Personal use. That was a great Broadcom news and nice gesture from that software vendor. Recently Broadcom announced that the software will be available for all, even the commercial sector. This …

Linux
Salt, VMware implementation – part 1, introduction

As every IT administrator knows, the infrastructure (meaning storages, compute, VMware virtualisation stack) is just a fundaments to run various operating systems (OS) and finally (containerized) application. Therefore, installation of (let’s call it) infrastructure in the datacenter (SDDC), in that sense is just the beginning of the adventure. No wonder, …