{"id":131,"date":"2005-05-25T18:51:11","date_gmt":"2005-05-25T15:51:11","guid":{"rendered":"https:\/\/void.gr\/kargig\/blog\/2005\/05\/25\/simple-port-accounting-part-2\/"},"modified":"2005-05-25T18:52:21","modified_gmt":"2005-05-25T15:52:21","slug":"simple-port-accounting-part-2","status":"publish","type":"post","link":"https:\/\/www.void.gr\/kargig\/blog\/2005\/05\/25\/simple-port-accounting-part-2\/","title":{"rendered":"Simple Port Accounting &#8211; part 2"},"content":{"rendered":"<p>A small addition to the <a href=\"https:\/\/void.gr\/kargig\/blog\/2004\/08\/10\/simple-port-accounting\/\">previous post about port accounting<\/a> with iptables and mrtg.<\/p>\n<p>A new script to count tcp and udp connections.<br \/>\nconns.sh<br \/>\n<code><br \/>\n#!\/bin\/bash<br \/>\nHOSTNAME=\"\/bin\/hostname\"<br \/>\nNETSTAT=\"\/bin\/netstat\"<br \/>\nUPTIME=\"\/usr\/bin\/uptime\"<br \/>\n$NETSTAT -ant | grep -v LISTEN | grep -v Active | grep -v Proto | wc -l<br \/>\n$NETSTAT -anu | grep -v LISTEN | grep -v Active | grep -v Proto | wc -l<br \/>\n$UPTIME | awk '{ print $3, $4, $5 }'<br \/>\n$HOSTNAME<br \/>\n<\/code><\/p>\n<p>and the part that goes inside your mrtg.conf<\/p>\n<p><code><br \/>\nTarget[conns]: `\/etc\/mrtg\/conns.sh`<br \/>\nOptions[conns]: growright, nopercent, gauge<br \/>\nMaxBytes[conns]: 20000<br \/>\nTitle[conns]: Connections<br \/>\nYLegend[conns]: Connections<br \/>\nLegendI[conns]: &nbsp;TCP:<br \/>\nLegendO[conns]: &nbsp;UDP:<br \/>\nShortLegend[conns]: conns<br \/>\nPageTop[conns]: &lt;h1&gt;Connection Stats &lt;\/h1 &gt;<br \/>\n<\/code><\/p>\n<p>enjoy \ud83d\ude42 It works for me..I hope it works for you too \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A small addition to the previous post about port accounting with iptables and mrtg. A new script to count tcp and udp connections. conns.sh #!\/bin\/bash HOSTNAME=&#8221;\/bin\/hostname&#8221; NETSTAT=&#8221;\/bin\/netstat&#8221; UPTIME=&#8221;\/usr\/bin\/uptime&#8221; $NETSTAT -ant | grep -v LISTEN | grep -v Active | grep -v Proto | wc -l $NETSTAT -anu | grep -v LISTEN | grep -v Active [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false,"footnotes":""},"categories":[1,3],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-general","category-linux"],"aioseo_notices":[],"views":2876,"_links":{"self":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":0,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.void.gr\/kargig\/blog\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}