simple examples of how to

Thursday, October 20, 2011

[AWK] colored ifstat

here goes a Linux command for colored ifstat using awk


ifstat -nb -i $1 | awk -v WARN=10000 -v ERR=20000 '{c++; if( c > 2 ) { if( $1 > ERR || $2 > ERR ) {print "\033[1;31m[***********************]\033[0m"; print "\033[1;31m[ERRO] ", $1, $2, "\033[0m"; }else if( $1 > WARN || $2 > WARN ) print "\033[1;34m[WARN] \033[0m", $1, $2; else print "\033[1;32m[OK] \033[0m", $1, $2; }}'

No comments:

Post a Comment