
shell
shell实战以及日常shell总结
张哲溪
日拱一卒,功不唐捐
展开
-
使用shell脚本来监控域名证书过期时间
使用shell脚本来监控域名过期时间原创 2022-08-17 16:47:44 · 1636 阅读 · 1 评论 -
定时清理三个月以外的docker镜像
使用shell脚本来实现清理三个月以外的镜像,然后使用crontab定期执行shell脚本。#!/bin/bashtime=`docker images |grep 'months' |awk '{print $4}'`for i in $timedo if [ $i -ge 3 ]; then docker images | awk '{print $3}' |xargs docker rmi fidone容器化环境可以将这个shell脚本做成一个镜像,然后cronjob来原创 2021-08-07 20:11:24 · 1204 阅读 · 0 评论 -
获取kubernetes集群下pod里的resoures下的cpu和memory的脚本
cat get_cpu_mem_pod.sh#!/bin/bashkubectl -n $1 get po |awk ‘{print $1}’ |grep -v NAME > pod_filefor name in cat pod_filedocpu=kubectl -n $1 get po $name -o yaml |grep " cpu:"memory=kubectl -n $1 get po $name -o yaml |grep " memory:"echo “name"原创 2021-06-18 13:55:28 · 443 阅读 · 2 评论 -
获取kubernetes集群下deployment里的resoures下的cpu和memory的脚本
cat get_cpu_mem_deploy.sh#!/bin/bashkubectl -n $1 get deploy |awk ‘{print $1}’ | grep -v NAME > deploy_filefor name in cat deploy_filedocpu=kubectl -n $1 get deploy $name -o yaml |grep " cpu:"memory=kubectl -n $1 get deploy $name -o yaml |grep "原创 2021-06-18 13:54:34 · 612 阅读 · 0 评论 -
linux shell编写监控脚本,实现计算机各个性能数据监控的功能
[root@master shell]# cat monitoring_host.sh#!/bin/baship=ifconfig ens33 | awk '/inet/{print $2}'echo “本机的IP是:” $ipcpu=uptime |awk '{print "CPU的负载情况\t1分钟负载情况:"$8"\t5分钟负载情况:"$9"\t15分钟负载情况"$10}'echo “本机的CPU负载情况:”$cpunet_in=ifconfig ens33 | awk '/RX p/{p原创 2021-01-09 12:52:06 · 855 阅读 · 2 评论 -
kubernetes过滤指定主机集群状态是否是NotReady的命令
需要创建一个iot.sh的文件for i in cat iot.shdo kubectl --kubeconfig=/etc/kubernetes/kubeconfig get node | awk ‘{print $1" "$2}’ |grep $idone原创 2021-01-06 21:45:02 · 344 阅读 · 0 评论 -
linux命令---删除14天以外的数据
find /data/gitlab-backup/ *.tar -mtime +14 | xargs rm -rf原创 2021-01-06 21:43:40 · 590 阅读 · 0 评论 -
使用shell脚本统计日志信息
写一个完整的脚本(shell/python),统计各个 IP 错误日志([error])的次数并按错误数由高到低输出统计情况上面例子log 的输出结果如下:IP error_cnt118.124.94.110 3118.124.94.173 2118.124.94.27 1118.124.94.75 ...原创 2020-02-28 15:41:30 · 1453 阅读 · 2 评论