{"id":381,"date":"2017-01-25T16:44:46","date_gmt":"2017-01-25T15:44:46","guid":{"rendered":"https:\/\/memo.xtranet.info\/?p=381"},"modified":"2017-01-25T16:44:46","modified_gmt":"2017-01-25T15:44:46","slug":"munin-portsentry","status":"publish","type":"post","link":"https:\/\/memo.xtranet.info\/?p=381","title":{"rendered":"Munin PortSentry"},"content":{"rendered":"<h1><span style=\"color: #33cccc;\">Munin PortSentry<\/span><\/h1>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #99cc00;\">portsentry_tcp :<\/span><\/h2>\n<p>#!\/usr\/bin\/perl -w<br \/>\n#<br \/>\n# Copyright (C) 2006 Rodolphe Quiedeville &lt;rodolphe@quiedeville.org&gt;<br \/>\n#<br \/>\n# This program is free software; you can redistribute it and\/or<br \/>\n# modify it under the terms of the GNU General Public License<br \/>\n# as published by the Free Software Foundation; version 2 dated June,<br \/>\n# 1991.<br \/>\n#<br \/>\n# This program is distributed in the hope that it will be useful,<br \/>\n# but WITHOUT ANY WARRANTY; without even the implied warranty of<br \/>\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\u00a0 See the<br \/>\n# GNU General Public License for more details.<br \/>\n#<br \/>\n# You should have received a copy of the GNU General Public License<br \/>\n# along with this program; if not, write to the Free Software<br \/>\n# Foundation, Inc., 59 Temple Place &#8211; Suite 330, Boston, MA\u00a0 02111-1307, USA.<br \/>\n#<br \/>\n# If you improve this script please send your version to my email address<br \/>\n# with the copyright notice upgrade with your name.<br \/>\n#<br \/>\n# Plugin to monitor number of tcp ports attack detected by portsentry<br \/>\n#<br \/>\n# $Log$<br \/>\n# Revision 1.1\u00a0 2006\/03\/28 21:04:01\u00a0 rodo<br \/>\n# Created by Rodolphe Quiedeville<br \/>\n#<br \/>\n# Add following lines to etc\/munin\/plugin-conf.d\/munin-node file<br \/>\n#<br \/>\n# [portsentry*]<br \/>\n#\u00a0\u00a0 user root<br \/>\n#<br \/>\n#%# family=network<br \/>\n#%# capabilities=autoconf<\/p>\n<p>use strict;<\/p>\n<p>my ($port,$number,$name);<br \/>\nmy (%ports, %names);<br \/>\nmy $a = \u00ab\u00a0&lt;\/var\/lib\/portsentry\/portsentry.blocked.tcp\u00a0\u00bb;<br \/>\nmy $line = undef;<\/p>\n<p>if ($ARGV[0] and $ARGV[0] eq \u00ab\u00a0config\u00a0\u00bb)<br \/>\n{<br \/>\nprint \u00ab\u00a0graph_title Portsentry TCP Attacks Detected\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0graph_args &#8211;base 1000 -l 0\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0graph_category network\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0graph_vlabel attacks blocked\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0graph_total total\\n\u00a0\u00bb;<\/p>\n<p>open(PTCP,$a) || die \u00ab\u00a0cannot open $a: $!\u00a0\u00bb;<br \/>\nwhile ($line = &lt;PTCP&gt;)<br \/>\n{<br \/>\n$ports{$1}++ if $line =~ \/.*Port: ([0-9]+) TCP Blocked$\/;<br \/>\n}<br \/>\nclose(PTCP);<\/p>\n<p>my @np = (keys(%ports));<br \/>\nforeach my $x (@np) {<br \/>\n$names{$x} = \u00ab\u00a0inconnu\u00a0\u00bb;<br \/>\nopen(PETC,\u00a0\u00bbgrep $x\/tcp \/etc\/services|\u00a0\u00bb) || die \u00ab\u00a0cannot open \/etc\/services : $!\u00a0\u00bb;<br \/>\nwhile ($line = &lt;PETC&gt;){<br \/>\n$names{$x} = $1 if $line =~ \/^(\\w*)\\s*$x\\\/tcp.*\/;<br \/>\n}<br \/>\nclose(PETC);<br \/>\n}<\/p>\n<p>while (($port,$number) = each(%ports))<br \/>\n{<br \/>\nprint \u00ab\u00a0port_$port.label Port $port\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0port_$port.info $names{$port}\\n\u00a0\u00bb;<br \/>\n}<\/p>\n<p>exit 0;<br \/>\n}<\/p>\n<p>open(PTCP,$a) || die \u00ab\u00a0cannot open $a: $!\u00a0\u00bb;<br \/>\nwhile ($line = &lt;PTCP&gt;)<br \/>\n{<br \/>\n$ports{$1}++ if $line =~ \/.*Port: ([0-9]+) TCP Blocked$\/;<br \/>\n}<br \/>\nclose(PTCP);<\/p>\n<p>while (($port,$number) = each(%ports))<br \/>\n{<br \/>\nprint \u00ab\u00a0port_$port.value $number\\n\u00a0\u00bb;<br \/>\n}<\/p>\n<p># vim:syntax=perl<\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #99cc00;\">portsentry_udp :<\/span><\/h2>\n<p>#!\/usr\/bin\/perl -w<br \/>\n#<br \/>\n# Copyright (C) 2006 Rodolphe Quiedeville &lt;rodolphe@quiedeville.org&gt;<br \/>\n#<br \/>\n# This program is free software; you can redistribute it and\/or<br \/>\n# modify it under the terms of the GNU General Public License<br \/>\n# as published by the Free Software Foundation; version 2 dated June,<br \/>\n# 1991.<br \/>\n#<br \/>\n# This program is distributed in the hope that it will be useful,<br \/>\n# but WITHOUT ANY WARRANTY; without even the implied warranty of<br \/>\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\u00a0 See the<br \/>\n# GNU General Public License for more details.<br \/>\n#<br \/>\n# You should have received a copy of the GNU General Public License<br \/>\n# along with this program; if not, write to the Free Software<br \/>\n# Foundation, Inc., 59 Temple Place &#8211; Suite 330, Boston, MA\u00a0 02111-1307, USA.<br \/>\n#<br \/>\n# If you improve this script please send your version to my email address<br \/>\n# with the copyright notice upgrade with your name.<br \/>\n#<br \/>\n# Plugin to monitor number of tcp ports attack detected by portsentry<br \/>\n#<br \/>\n# $Log$<br \/>\n# Revision 1.1\u00a0 2006\/03\/28 21:04:01\u00a0 rodo<br \/>\n# Created by Rodolphe Quiedeville<br \/>\n#<br \/>\n#%# family=network<br \/>\n#%# capabilities=autoconf<\/p>\n<p>use strict;<\/p>\n<p>my ($port,$number);<br \/>\nmy %ports;<br \/>\nmy $a = \u00ab\u00a0\/var\/lib\/portsentry\/portsentry.blocked.udp\u00a0\u00bb;<br \/>\nmy $line = undef;<\/p>\n<p>if ($ARGV[0] and $ARGV[0] eq \u00ab\u00a0config\u00a0\u00bb)<br \/>\n{<br \/>\nprint \u00ab\u00a0graph_title Portsentry UDP Attacks Detected\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0graph_args &#8211;base 1000 -l 0\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0graph_category network\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0graph_vlabel attacks blocked\\n\u00a0\u00bb;<\/p>\n<p>open(PUDP,$a) || die \u00ab\u00a0cannot open $a: $!\u00a0\u00bb;<br \/>\nwhile ($line = &lt;PUDP&gt;)<br \/>\n{<br \/>\n$ports{$1}++ if $line =~ \/.*Port: ([0-9]+) UDP Blocked$\/;<br \/>\n}<br \/>\nclose(PUDP);<\/p>\n<p>while (($port,$number) = each(%ports))<br \/>\n{<br \/>\nprint \u00ab\u00a0port_$port.label Port $port\\n\u00a0\u00bb;<br \/>\nprint \u00ab\u00a0port_$port.info Port UDP $port\\n\u00a0\u00bb;<br \/>\n}<\/p>\n<p>exit 0;<br \/>\n}<\/p>\n<p>open(PUDP,$a) || die \u00ab\u00a0cannot open $a: $!\u00a0\u00bb;<br \/>\nwhile ($line = &lt;PUDP&gt;)<br \/>\n{<br \/>\n$ports{$1}++ if $line =~ \/.*Port: ([0-9]+) UDP Blocked$\/;<br \/>\n}<br \/>\nclose(PUDP);<\/p>\n<p>while (($port,$number) = each(%ports))<br \/>\n{<br \/>\nprint \u00ab\u00a0port_$port.value $number\\n\u00a0\u00bb;<br \/>\n}<\/p>\n<p># vim:syntax=perl<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Munin PortSentry &nbsp; portsentry_tcp : #!\/usr\/bin\/perl -w # # Copyright (C) 2006 Rodolphe Quiedeville &lt;rodolphe@quiedeville.org&gt; # # This program is free software; you can redistribute it and\/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 2 dated June, # 1991. # #&#8230; <a href=\"https:\/\/memo.xtranet.info\/?p=381\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Munin PortSentry<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,4,38],"tags":[52],"class_list":["post-381","post","type-post","status-publish","format-standard","hentry","category-administration","category-linux","category-munin","tag-munin"],"_links":{"self":[{"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=\/wp\/v2\/posts\/381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=381"}],"version-history":[{"count":1,"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=\/wp\/v2\/posts\/381\/revisions"}],"predecessor-version":[{"id":382,"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=\/wp\/v2\/posts\/381\/revisions\/382"}],"wp:attachment":[{"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/memo.xtranet.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}