diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
commit | 47e6e7c84f008a53061e661f31ae96629bc694ef (patch) | |
tree | 648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /src/pmdas/netfilter | |
download | pcp-debian.tar.gz |
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'src/pmdas/netfilter')
-rw-r--r-- | src/pmdas/netfilter/GNUmakefile | 55 | ||||
-rwxr-xr-x | src/pmdas/netfilter/Install | 33 | ||||
-rwxr-xr-x | src/pmdas/netfilter/Remove | 25 | ||||
-rw-r--r-- | src/pmdas/netfilter/pmdanetfilter.pl | 100 | ||||
-rw-r--r-- | src/pmdas/netfilter/pmlogconf.config | 5 | ||||
-rw-r--r-- | src/pmdas/netfilter/pmlogconf.summary | 4 |
6 files changed, 222 insertions, 0 deletions
diff --git a/src/pmdas/netfilter/GNUmakefile b/src/pmdas/netfilter/GNUmakefile new file mode 100644 index 0000000..53e9051 --- /dev/null +++ b/src/pmdas/netfilter/GNUmakefile @@ -0,0 +1,55 @@ +#!gmake +# +# Copyright (c) 2009 Aconex. All Rights Reserved. +# +# 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; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# + +TOPDIR = ../../.. +include $(TOPDIR)/src/include/builddefs + +IAM = netfilter +PMDADIR = $(PCP_PMDAS_DIR)/$(IAM) +LSRCFILES = Install Remove pmda$(IAM).pl pmlogconf.config pmlogconf.summary +LDIRT = domain.h root pmns *.log $(MAN_PAGES) + +ifneq ($(POD2MAN),) +MAN_SECTION = 1 +MAN_PAGES = pmda$(IAM).$(MAN_SECTION) +MAN_DEST = $(PCP_MAN_DIR)/man$(MAN_SECTION) +endif + +default: check_domain $(MAN_PAGES) + +pmda$(IAM).1: pmda$(IAM).pl + $(POD_MAKERULE) + +include $(BUILDRULES) + +ifeq "$(TARGET_OS)" "linux" +install: default + $(INSTALL) -m 755 -d $(PMDADIR) + $(INSTALL) -m 755 Install Remove $(PMDADIR) + $(INSTALL) -m 644 pmda$(IAM).pl $(PMDADIR)/pmda$(IAM).pl + @$(INSTALL_MAN) + $(INSTALL) -m 755 -d $(PCP_VAR_DIR)/config/pmlogconf/$(IAM) + $(INSTALL) -m 644 pmlogconf.summary $(PCP_VAR_DIR)/config/pmlogconf/$(IAM)/summary + $(INSTALL) -m 644 pmlogconf.config $(PCP_VAR_DIR)/config/pmlogconf/$(IAM)/config +else +install: +endif + +default_pcp : default + +install_pcp : install + +check_domain: ../../pmns/stdpmid + $(DOMAIN_PERLRULE) diff --git a/src/pmdas/netfilter/Install b/src/pmdas/netfilter/Install new file mode 100755 index 0000000..621f639 --- /dev/null +++ b/src/pmdas/netfilter/Install @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright (c) 2009 Aconex. All Rights Reserved. +# +# 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; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# Install the NetFilter PMDA +# + +. $PCP_DIR/etc/pcp.env +. $PCP_SHARE_DIR/lib/pmdaproc.sh + +iam=netfilter +perl_opt=true +daemon_opt=false +forced_restart=false + +if ! test -d /proc/sys/net/ipv4/netfilter; then + echo "IP connection tracking not enabled in your kernel" + exit 1 +fi + +pmdaSetup +pmdaInstall +exit 0 diff --git a/src/pmdas/netfilter/Remove b/src/pmdas/netfilter/Remove new file mode 100755 index 0000000..77f002c --- /dev/null +++ b/src/pmdas/netfilter/Remove @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (c) 2009 Aconex. All Rights Reserved. +# +# 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; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# Remove the NetFilter PMDA +# + +. $PCP_DIR/etc/pcp.env +. $PCP_SHARE_DIR/lib/pmdaproc.sh + +iam=netfilter + +pmdaSetup +pmdaRemove +exit 0 diff --git a/src/pmdas/netfilter/pmdanetfilter.pl b/src/pmdas/netfilter/pmdanetfilter.pl new file mode 100644 index 0000000..21aafa0 --- /dev/null +++ b/src/pmdas/netfilter/pmdanetfilter.pl @@ -0,0 +1,100 @@ +# +# Copyright (c) 2012 Red Hat. +# Copyright (c) 2009 Aconex. All Rights Reserved. +# +# 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; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# + +use strict; +use warnings; +use PCP::PMDA; + +my $pmda = PCP::PMDA->new('netfilter', 97); +my $procfs = '/proc/sys/net/ipv4/'; + +sub netfilter_fetch_callback +{ + my ($cluster, $item, $inst) = @_; + my $metric_name = pmda_pmid_name($cluster, $item); + my ($path, $name, $value, $fh, @vals); + + if ($inst != PM_IN_NULL) { return (PM_ERR_INST, 0); } + if (!defined($metric_name)) { return (PM_ERR_PMID, 0); } + + $metric_name =~ s/\./\//; + $name = $procfs . $metric_name; + open($fh, $name) || return (PM_ERR_APPVERSION, 0); + $value = <$fh>; + close $fh; + chomp $value; + + return ($value, 1); +} + +$pmda->add_metric(pmda_pmid(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT, + pmda_units(0,0,0,0,0,0), 'netfilter.ip_conntrack_max', '', ''); +$pmda->add_metric(pmda_pmid(0,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT, + pmda_units(0,0,0,0,0,0), 'netfilter.ip_conntrack_count', '', ''); + +$pmda->set_fetch_callback(\&netfilter_fetch_callback); +$pmda->set_user('pcp'); +$pmda->run; + +=pod + +=head1 NAME + +pmdanetfilter - Linux netfilter IP connection tracking performance metrics domain agent (PMDA) + +=head1 DESCRIPTION + +B<pmdanetfilter> is a Performance Metrics Domain Agent (PMDA) which +exports metric values from IP connection tracking module in the Linux +kernel. + +=head1 INSTALLATION + +If you want access to the names and values for the netfilter performance +metrics, do the following as root: + + # cd $PCP_PMDAS_DIR/netfilter + # ./Install + +If you want to undo the installation, do the following as root: + + # cd $PCP_PMDAS_DIR/netfilter + # ./Remove + +B<pmdanetfilter> is launched by pmcd(1) and should never be executed +directly. The Install and Remove scripts notify pmcd(1) when +the agent is installed or removed. + +=head1 FILES + +=over + +=item $PCP_PMDAS_DIR/netfilter/Install + +installation script for the B<pmdanetfilter> agent + +=item $PCP_PMDAS_DIR/netfilter/Remove + +undo installation script for the B<pmdanetfilter> agent + +=item $PCP_LOG_DIR/pmcd/netfilter.log + +default log file for error messages from B<pmdanetfilter> + +=back + +=head1 SEE ALSO + +pmcd(1). diff --git a/src/pmdas/netfilter/pmlogconf.config b/src/pmdas/netfilter/pmlogconf.config new file mode 100644 index 0000000..d699905 --- /dev/null +++ b/src/pmdas/netfilter/pmlogconf.config @@ -0,0 +1,5 @@ +#pmlogconf-setup 2.0 +ident Netfilter configuration +probe netfilter.ip_conntrack_max exists ? include : exclude +delta once + netfilter.ip_conntrack_max diff --git a/src/pmdas/netfilter/pmlogconf.summary b/src/pmdas/netfilter/pmlogconf.summary new file mode 100644 index 0000000..91669c4 --- /dev/null +++ b/src/pmdas/netfilter/pmlogconf.summary @@ -0,0 +1,4 @@ +#pmlogconf-setup 2.0 +ident Netfilter summary information +probe netfilter.ip_conntrack_count exists ? include : exclude + netfilter.ip_conntrack_count |