标签:like database variable col grep app ash base ble
shell比较:
大于 -gt (greater than) 小于 -lt (less than) 大于或等于 -ge (greater than or equal) 小于或等于 -le (less than or equal) 不相等 -ne (not equal)
1、统计 Nginx 异常4x、5x 状态码百分比。
脚本内容:
#!/bin/bash
#tigergao pwd=/app/nginx/logs/access.log for num1 in `cat $pwd | awk ‘{print $9}‘ | grep -Ei "^4|^5" | wc -l` do echo 异常状态码总数:$num1 for num2 in `cat $pwd | awk ‘{print $9}‘| wc -l` do echo 请求状态码总数:$num2 k=$(echo "scale=2;$num1 * 100 / $num2"| bc)% echo 异常百分比:$k done done
2、查看 MySQL 参数脚本。
脚本内容:
#!/bin/bash mysql -u root -p‘shsnc!@#‘ <<EOF show databases; use performance_schema; show tables like ‘%global%status%‘; select * from global_status where VARIABLE_NAME like ‘%slow%‘; EOF
3、查看 memcached 指标。
#!/bin/bash i=`ps -ef | grep -i memcached | grep -v grep | wc -l` echo $i if [ $i -ne 0 ];then telnet 10.131.156.170 11111 stats else echo "process is not running!" fi
标签:like database variable col grep app ash base ble
原文地址:https://www.cnblogs.com/tigergaonotes/p/11073952.html