From c2056a7a261cd6ee012d565dd0033e98c98d64a4 Mon Sep 17 00:00:00 2001 From: itoussies <65223458+itoussies@users.noreply.github.com> Date: Mon, 11 Jan 2021 16:23:16 +0100 Subject: [PATCH] enh(plugin)apps-pfsense-snmp metricsv2 (#2495) --- apps/pfsense/snmp/mode/listpfinterfaces.pm | 7 ++--- apps/pfsense/snmp/mode/packetstats.pm | 34 +++++++++++----------- apps/pfsense/snmp/mode/pfinterfaces.pm | 26 ++++++++--------- apps/pfsense/snmp/plugin.pm | 6 ++-- 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/apps/pfsense/snmp/mode/listpfinterfaces.pm b/apps/pfsense/snmp/mode/listpfinterfaces.pm index fe81a27c7..7ecf366e7 100644 --- a/apps/pfsense/snmp/mode/listpfinterfaces.pm +++ b/apps/pfsense/snmp/mode/listpfinterfaces.pm @@ -32,10 +32,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); return $self; } diff --git a/apps/pfsense/snmp/mode/packetstats.pm b/apps/pfsense/snmp/mode/packetstats.pm index 8f3e932fc..fdf98ad99 100644 --- a/apps/pfsense/snmp/mode/packetstats.pm +++ b/apps/pfsense/snmp/mode/packetstats.pm @@ -34,39 +34,39 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'match', set => { + { label => 'match', nlabel => 'packets.matched.persecond', set => { key_values => [ { name => 'pfCounterMatch', per_second => 1 } ], output_template => 'Packets Matched Filter Rule : %.2f/s', perfdatas => [ - { label => 'match', template => '%.2f', unit => '/s', min => 0 }, - ], + { label => 'match', template => '%.2f', unit => '/s', min => 0 } + ] } }, - { label => 'badoffset', set => { + { label => 'badoffset', nlabel => 'packets.badoffset.persecond', set => { key_values => [ { name => 'pfCounterBadOffset', per_second => 1 } ], output_template => 'Bad Offset Packets : %.2f/s', perfdatas => [ - { label => 'bad_offset', template => '%.2f', unit => '/s', min => 0 }, - ], + { label => 'bad_offset', template => '%.2f', unit => '/s', min => 0 } + ] } }, - { label => 'fragment', set => { + { label => 'fragment', nlabel => 'packets.fragmented.persecond', set => { key_values => [ { name => 'pfCounterFragment', per_second => 1 } ], output_template => 'Fragmented Packets : %.2f/s', perfdatas => [ - { label => 'fragment', template => '%.2f', unit => '/s', min => 0 }, - ], + { label => 'fragment', template => '%.2f', unit => '/s', min => 0 } + ] } }, - { label => 'short', set => { + { label => 'short', nlabem => 'packets.short.persecond', set => { key_values => [ { name => 'pfCounterShort', per_second => 1 } ], output_template => 'Short Packets : %.2f/s', perfdatas => [ - { label => 'short', template => '%.2f', unit => '/s', min => 0 }, - ], + { label => 'short', template => '%.2f', unit => '/s', min => 0 } + ] } }, - { label => 'normalize', set => { + { label => 'normalize', nlabel => 'packets.normalized.persecond',set => { key_values => [ { name => 'pfCounterNormalize', per_second => 1 } ], output_template => 'Normalized Packets : %.2f/s', perfdatas => [ @@ -74,14 +74,14 @@ sub set_counters { ], } }, - { label => 'memdrop', set => { + { label => 'memdrop', nlabel => 'packets.memorydropped.persecond',set => { key_values => [ { name => 'pfCounterMemDrop', per_second => 1 } ], output_template => 'Dropped Packets Due To Memory : %.2f/s', perfdatas => [ - { label => 'memdrop', template => '%.2f', unit => '/s', min => 0 }, - ], + { label => 'memdrop', template => '%.2f', unit => '/s', min => 0 } + ] } - }, + } ]; } diff --git a/apps/pfsense/snmp/mode/pfinterfaces.pm b/apps/pfsense/snmp/mode/pfinterfaces.pm index 3f35fafea..4b0f9fbfd 100644 --- a/apps/pfsense/snmp/mode/pfinterfaces.pm +++ b/apps/pfsense/snmp/mode/pfinterfaces.pm @@ -34,46 +34,46 @@ sub set_counters { ]; $self->{maps_counters}->{pfint} = [ - { label => 'traffic-in-pass', set => { + { label => 'traffic-in-pass', nlabel => 'pass.traffic.in.bitspersecond', set => { key_values => [ { name => 'pfInterfacesIf4BytesInPass', per_second => 1 }, { name => 'display' } ], output_change_bytes => 2, output_template => 'Traffic In Pass : %s %s/s', perfdatas => [ { label => 'traffic_in_pass', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'traffic-out-pass', set => { + { label => 'traffic-out-pass', nlabel => 'pass.traffic.out.bitspersecond', set => { key_values => [ { name => 'pfInterfacesIf4BytesOutPass', per_second => 1 }, { name => 'display' } ], output_change_bytes => 2, output_template => 'Traffic Out Pass : %s %s/s', perfdatas => [ { label => 'traffic_out_pass', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'traffic-in-block', set => { + { label => 'traffic-in-block', nlabel => 'block.traffic.in.bitspersecond', set => { key_values => [ { name => 'pfInterfacesIf4BytesInBlock', per_second => 1 }, { name => 'display' } ], output_change_bytes => 2, output_template => 'Traffic In Block : %s %s/s', perfdatas => [ { label => 'traffic_in_block', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'traffic-out-block', set => { + { label => 'traffic-out-block', nlabel => 'block.traffic.out.bitspersecond', set => { key_values => [ { name => 'pfInterfacesIf4BytesOutBlock', per_second => 1 }, { name => 'display' } ], output_change_bytes => 2, output_template => 'Traffic Out Block : %s %s/s', perfdatas => [ { label => 'traffic_out_block', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } diff --git a/apps/pfsense/snmp/plugin.pm b/apps/pfsense/snmp/plugin.pm index b310505d9..58c9ec5db 100644 --- a/apps/pfsense/snmp/plugin.pm +++ b/apps/pfsense/snmp/plugin.pm @@ -30,12 +30,12 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{modes} = { 'list-pfinterfaces' => 'apps::pfsense::snmp::mode::listpfinterfaces', 'packet-stats' => 'apps::pfsense::snmp::mode::packetstats', 'pfinterfaces' => 'apps::pfsense::snmp::mode::pfinterfaces', - 'runtime' => 'apps::pfsense::snmp::mode::runtime', - ); + 'runtime' => 'apps::pfsense::snmp::mode::runtime' + }; return $self; }