- Tạo file log-openstack.sh với nội dung dưới
#!/bin/bash
# rapid CLI oneliner log inspection inside all log files
# Lookig for keywords "fail", "error", "unable", "warning".
for i in $(ls /var/log/*/*.log); do echo "=========="; echo $i; echo "========="; tail $i| egrep -i $1; done
- Thưc thi script với cú pháp
bash log-openstack.sh ERROR
- Lưu ý: Có thể thay
ERROR
bằngFAIL
hoặcWarning
hoặc từ khóa muốn tìm - Hoặc có thể đưa 2 hoặc nhiều từ khóa như ví dụ dưới
bash log-openstack.sh "ERROR|Warning"
Tham khảo từ: https://raw.githubusercontent.com/AJNOURI/COA/master/misc/oneliner_log_inspection.sh