- 论坛徽章:
- 0
|
回复 8# jiaogeshahaone - [root@d453be13- ~]# free | awk 'NR>1&&NR<4{if($1~/Mem/)a=$2;else b=$3}END{split(b/a*100,d,".");if(d[1]>80)print "WARNING- Mem used:"d[1]"%";else print "OK - Mem used:"d[1]"%"}'
- OK - Mem used:9%
- [root@d453be13- ~]# free | awk 'NR>1&&NR<4{if($1~/Mem/)a=$2;else b=$3}END{split(b/a*100,d,".");if(d[1]>80)print "WARNING- Mem used:"d[1]"%";exit 1;else print "OK - Mem used:"d[1]"%"}'
- awk: NR>1&&NR<4{if($1~/Mem/)a=$2;else b=$3}END{split(b/a*100,d,".");if(d[1]>80)print "WARNING- Mem used:"d[1]"%";exit 1;else print "OK - Mem used:"d[1]"%"}
- awk: ^ syntax error
复制代码 |
|