Linux ops shell script gadget, if you want to share this article, please indicate the source of the article, the following script is for reference only, if the error placed on the server, the consequences please be conceited
1. Detecting CPU percent remaining
#!/bin/bash#inspect Cpu#sun Jul to -: -: ACst .PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport pathterm=Linuxexport Termcpuresult=$ (top-bn1|grep "Cpu"|awk '{print $}'|sed 's/\. *$//g')if[[$CpuResult < -]]; Then Echo "CPU WARNING: $CpuResult">/service/script/. Cpu_in.txt Top-bn1>>/service/script./Cpu_in.txt Mail-S"Inspcet CPU"WL </service/script/. Cpu_in.txtfi
2. Detecting Memory
#!/bin/Bash#inspect memory:if the Memory is Lessthan -, ThenSend mail to Wl#tue2 the: -: +Cst .PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport Pathmem=$( Free-M |grep "Mem"|awk '{print $4}')if[MEM < -]]; Then Echo-E"Memory warning:memory Free $MEM">/service/script/. Memorywarning Mail-S"Memory Warning"WL </service/script/. Memorywarningfi
3. Detecting disk space remaining
#!/bin/bash#insepct harddisk, If The remaining space is Morethan the%, the message is sent to the Wl#tue2 the: $: AboutCst .PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport PATH forRemainingspaceinch$(DF-H |awk '{print $}'|grep-V' Use'|sed-E's/[%]//g') Do if[[$RemainingSpace > the]]; Then Echo-E"$RemainingSpace" Echo-E"$ (df-h | grep $RemainingSpace)">/service/script/. Harddiskwarning Mail-S"Disk Warning"WL </service/script/. Harddiskwarningfi Done
4. Detecting remaining Inode
#!/bin/Bash#inspcet Inode:if the FreeINODE is Lessthan $, the message is sent to the Wl#tue2 Ten: +: inCst .PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport PATH forFreeinodeinch$(DF-I. |grep-V"Filesystem"|awk '{print $4}') Do if[[$FreeInode < $]]; Then Echo-E"$ (df-i | grep"$FreeInode")">/service/script/. Freeinode Mail-S"Freeinode Warning"WL </service/script/. Freeinodefi Done
Time:2016-08-02 10:56:00
Name: Wang
Mail:[email protected]
Linux OPS automation shell scripting gadget