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:
- 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.
- Check the number of lines with two entries:
grep 'first entry with lines' FILE | grep 2020-07-14 | wc -l
- 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
- 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
- Search for all lines without a given string:
grep -v “string” /var/log/File.log
- grep can lines count by its own:
cat FILE.txt | grep -c “string
” - sort output (in reverse order) considering the first line as a number:
du -sm * | sort -rn
- print just those lines with number from given column:
cat FILE.txt | awk ‘{print $5}’ | grep ‘[0-9]’
- 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
- show first and last lines in the file:
tail -NUMBER FILE.txt
head -NUMBER FILE.txt
- show change in the file on the fly:
tail -f FILE.txt
- finding only the filenames with string:
grep -l “string” FILE.txt
No Comments