Debian Codegraph @

src/network/citrix/appacceleration/snmp/mode/listserviceclass.pm

raw
1 #
2 # Copyright 2024 Centreon (http://www.centreon.com/)
3 #
4 # Centreon is a full-fledged industry-strength solution that meets
5 # the needs in IT infrastructure and application monitoring for
6 # service performance.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20
21 package network::citrix::appacceleration::snmp::mode::listserviceclass;
22
23 use base qw(centreon::plugins::mode);
24
25 use strict;
26 use warnings;
27
28 my $oid_wsServiceClassName = '.1.3.6.1.4.1.3845.30.4.1.1.2.2.1.2';
29
30 sub new {
31 my ($class, %options) = @_;
32 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
33 bless $self, $class;
34
35 $options{options}->add_options(arguments =>
36 {
37 "filter-name:s" => { name => 'filter_name' },
38 });
39 return $self;
40 }
41
42 sub check_options {
43 my ($self, %options) = @_;
44 $self->SUPER::init(%options);
45 }
46
47 sub manage_selection {
48 my ($self, %options) = @_;
49
50 my $snmp_result = $self->{snmp}->get_table(oid => $oid_wsServiceClassName, nothing_quit => 1);
51 $self->{sc} = {};
52 foreach my $oid (keys %{$snmp_result}) {
53 if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
54 $snmp_result->{$oid} !~ /$self->{option_results}->{filter_name}/) {
55 $self->{output}->output_add(long_msg => "skipping service class '" . $snmp_result->{$oid} . "'.", debug => 1);
56 next;
57 }
58
59 $self->{sc}->{$snmp_result->{$oid}} = { name => $snmp_result->{$oid} };
60 }
61 }
62
63 sub run {
64 my ($self, %options) = @_;
65 $self->{snmp} = $options{snmp};
66
67 $self->manage_selection();
68 foreach my $name (sort keys %{$self->{sc}}) {
69 $self->{output}->output_add(long_msg => "'" . $name . "'");
70 }
71
72 $self->{output}->output_add(severity => 'OK',
73 short_msg => 'List Service Class:');
74 $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
75 $self->{output}->exit();
76 }
77
78 sub disco_format {
79 my ($self, %options) = @_;
80
81 $self->{output}->add_disco_format(elements => ['name']);
82 }
83
84 sub disco_show {
85 my ($self, %options) = @_;
86 $self->{snmp} = $options{snmp};
87
88 $self->manage_selection();
89 foreach my $name (sort keys %{$self->{sc}}) {
90 $self->{output}->add_disco_entry(name => $name);
91 }
92 }
93
94 1;
95
96 __END__
97
98 =head1 MODE
99
100 List Service Class.
101
102 =over 8
103
104 =item B<--filter-name>
105
106 Filter by service class name.
107
108 =back
109
110 =cut
111