| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ixchel::Actions::snmp_extends; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
84806
|
use 5.006; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
78
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'Ixchel::Actions::base'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
394
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Ixchel::Actions::snmp_extends - List or install/update SNMP extends |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.1.0 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 CLI SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
ixchel -a snmp_extends B<-l> |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
ixchel -a snmp_extends B<-u> |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 CODE SYNOPSIS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Data::Dumper; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $results=$ixchel->action(action=>'', opts=>{u=>1}); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 FLAGS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 -l |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
List the extends enabled. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 -u |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Update or install extends. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 RESULT HASH REF |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
.errors :: A array of errors encountered. |
|
45
|
|
|
|
|
|
|
.status_text :: A string description of what was done and the results. |
|
46
|
|
|
|
|
|
|
.ok :: Set to zero if any of the above errored. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
0
|
0
|
|
sub new_extra { } |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub action_extra { |
|
53
|
0
|
|
|
0
|
0
|
|
my $self = $_[0]; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
0
|
0
|
|
|
|
if ( !$self->{opts}{l} && !$self->{opts}{u} ) { |
|
|
|
0
|
0
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$self->status_add( error => 1, status => 'Neither -l or -u specified' ); |
|
57
|
0
|
|
|
|
|
|
return undef; |
|
58
|
|
|
|
|
|
|
} elsif ( $self->{opts}{l} && $self->{opts}{u} ) { |
|
59
|
0
|
|
|
|
|
|
$self->status_add( error => 1, status => 'Both -l and -u specified' ); |
|
60
|
0
|
|
|
|
|
|
return undef; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ( $self->{opts}{l} ) { |
|
64
|
0
|
|
|
|
|
|
my @extends = keys( %{ $self->{config}{snmp}{extends} } ); |
|
|
0
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my @enabled; |
|
66
|
|
|
|
|
|
|
my @disabled; |
|
67
|
0
|
|
|
|
|
|
foreach my $item (@extends) { |
|
68
|
0
|
0
|
|
|
|
|
if ( $self->{config}{snmp}{extends}{$item}{enable} ) { |
|
69
|
0
|
|
|
|
|
|
push( @enabled, $item ); |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
0
|
|
|
|
|
|
push( @disabled, $item ); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
0
|
|
|
|
|
|
$self->status_add( status => 'Currently Enabled: ' . join( ',', @enabled ) ); |
|
75
|
0
|
|
|
|
|
|
$self->status_add( status => 'Currently Disabled: ' . join( ',', @disabled ) ); |
|
76
|
|
|
|
|
|
|
} ## end if ( $self->{opts}{l} ) |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
if ( $self->{opts}{u} ) { |
|
79
|
0
|
|
|
|
|
|
my @extends = keys( %{ $self->{config}{snmp}{extends} } ); |
|
|
0
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my @disabled; |
|
81
|
|
|
|
|
|
|
my @errored; |
|
82
|
0
|
|
|
|
|
|
my @installed; |
|
83
|
0
|
|
|
|
|
|
push( @extends, 'distro' ); |
|
84
|
0
|
|
|
|
|
|
foreach my $item (@extends) { |
|
85
|
0
|
0
|
|
|
|
|
if ( $self->{config}{snmp}{extends}{$item}{enable} ) { |
|
86
|
0
|
|
|
|
|
|
my $results; |
|
87
|
0
|
|
|
|
|
|
my $error = 0; |
|
88
|
0
|
|
|
|
|
|
$self->status_add( status => 'Calling xeno for librenms/extends/' . $item ); |
|
89
|
0
|
|
|
|
|
|
eval { |
|
90
|
|
|
|
|
|
|
$results |
|
91
|
0
|
|
|
|
|
|
= $self->{ixchel}->action( action => 'xeno', opts => { r => 'librenms/extends/' . $item } ); |
|
92
|
|
|
|
|
|
|
}; |
|
93
|
0
|
0
|
0
|
|
|
|
if ( $@ || !defined($results) || defined( $results->{errors}[0] ) ) { |
|
|
|
|
0
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$error = 1; |
|
95
|
1
|
|
|
1
|
|
551
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
6858
|
|
|
|
1
|
|
|
|
|
277
|
|
|
96
|
0
|
|
|
|
|
|
print Dumper($results); |
|
97
|
0
|
|
|
|
|
|
$self->status_add( |
|
98
|
|
|
|
|
|
|
np => 1, |
|
99
|
|
|
|
|
|
|
error => $error, |
|
100
|
|
|
|
|
|
|
status => 'Errored installing/updating librenms/extends/' . $item |
|
101
|
|
|
|
|
|
|
); |
|
102
|
0
|
|
|
|
|
|
push( @errored, $item ); |
|
103
|
|
|
|
|
|
|
} else { |
|
104
|
0
|
|
|
|
|
|
push( @installed, $item ); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} else { |
|
107
|
0
|
|
|
|
|
|
push( @disabled, $item ); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
} ## end foreach my $item (@extends) |
|
110
|
0
|
|
|
|
|
|
$self->status_add( status => 'Currently Disabled: ' . join( ',', @disabled ) ); |
|
111
|
0
|
|
|
|
|
|
$self->status_add( status => 'Installed/Updated: ' . join( ',', @installed ) ); |
|
112
|
0
|
|
|
|
|
|
$self->status_add( status => 'Errored: ' . join( ',', @errored ) ); |
|
113
|
|
|
|
|
|
|
} ## end if ( $self->{opts}{u} ) |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return undef; |
|
116
|
|
|
|
|
|
|
} ## end sub action_extra |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub short { |
|
119
|
0
|
|
|
0
|
1
|
|
return 'List or install/update SNMP extends'; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub opts_data { |
|
123
|
0
|
|
|
0
|
1
|
|
return ' |
|
124
|
|
|
|
|
|
|
l |
|
125
|
|
|
|
|
|
|
u |
|
126
|
|
|
|
|
|
|
'; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |