Kubernetes脚本——K8s日志检查
#!/bin/bash echo "docker日志采用建议的syslog收集检查,期望结果:1---------------------------------------------------------------------">log_check_result.txt ansible -i ./hosts all -m shell -a 'sudo find /apps/logs/docker/ -name dockerd.log|wc -l' >> log_check_result.txt echo -e "-----------------------------------------------------------------------------------------------------------------\n\n">>log_check_result.txt #echo "docker日志路径标准化检查,期望结果:若返回不为空(non-zero return code),则正常------------------------------------------------------------" >> log_check_result.txt #ansible -i ./hosts all -m shell -a 'sudo less /etc/rsyslog.d/docker.conf |grep "/apps/logs/docker/dockerd.log"'>>log_check_result.txt #echo -e "-----------------------------------------------------------------------------------------------------------------\n\n">>log_check_result.txt #echo "k8s集群组件的日志目录是否为logs检查,期望结果:若返回不为空,则正常-------------------------------------------------">>log_check_result.txt #ansible -i ./hosts k8s -m shell -a 'sudo find /apps/logs/ -name kube*'>>log_check_result.txt #echo -e "-----------------------------------------------------------------------------------------------------------------\n\n">>log_check_result.txt echo "docker日志切割检查,期望结果:若返回不为空,则正常-------------------------------------------------------------------">>log_check_result.txt ansible -i ./hosts all -m shell -a 'sudo ls -l /apps/logs/docker/'>>log_check_result.txt echo -e "-----------------------------------------------------------------------------------------------------------------\n">>log_check_result.txt echo "k8s master节点日志切割检查,期望结果:若返回不为空,则正常-----------------------------------------------------------">>log_check_result.txt ansible -i ./hosts k8smaster -m shell -a 'sudo ls -l /apps/logs/{docker,kube_apiserver,kube_controller_manager,kube_scheduler,kubelet}/'>>log_check_result.txt echo -e "-----------------------------------------------------------------------------------------------------------------\n">>log_check_result.txt echo "k8s node节点日志切割检查,期望结果:若返回不为空,则正常-----------------------------------------------------------">>log_check_result.txt ansible -i ./hosts k8snode -m shell -a 'sudo ls -l /apps/logs/{docker,kubelet}/'>>log_check_result.txt echo -e "-----------------------------------------------------------------------------------------------------------------\n">>log_check_result.txt
稳步前行,只争朝夕。