Advertisement
METAJIJI

Untitled

Sep 19th, 2014
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.55 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. /usr/bin/env ss -ant | \
  4.     awk '{
  5.         if (NR>1) {
  6.             state[$1]++;
  7.         }
  8.     }
  9.     END {
  10.         for (i in state) {
  11.             s=i;
  12.             sub(/ESTAB/, "establ", s);
  13.             sub(/LISTEN/, "listen", s);
  14.             sub(/SYN-SENT/, "synsent", s);
  15.             sub(/SYN-RECV/, "synrecv", s);
  16.             sub(/FIN-WAIT-1/, "finw1", s);
  17.             sub(/FIN-WAIT-2/, "finw2", s);
  18.             sub(/CLOSE-WAIT/, "closew", s);
  19.             sub(/TIME-WAIT/, "timew", s);
  20.             print "- tcp."s, state[i]
  21.         }
  22.     }' | /usr/bin/env zabbix_sender \
  23.     --config /etc/zabbix/zabbix_agentd.conf \
  24.     --input-file - >/dev/null 2>&1
  25. echo $?
  26. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement