| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ixchel::Actions::sys_info; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
100426
|
use 5.006; |
|
|
1
|
|
|
|
|
2
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
19
|
|
|
5
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
48
|
|
|
6
|
1
|
|
|
1
|
|
325
|
use Ixchel::functions::sys_info; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
81
|
|
|
7
|
1
|
|
|
1
|
|
10
|
use JSON qw(to_json); |
|
|
1
|
|
|
|
|
8227
|
|
|
|
1
|
|
|
|
|
5
|
|
|
8
|
1
|
|
|
1
|
|
173
|
use YAML::XS qw(Dump); |
|
|
1
|
|
|
|
|
2957
|
|
|
|
1
|
|
|
|
|
66
|
|
|
9
|
1
|
|
|
1
|
|
12
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
49
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use base 'Ixchel::Actions::base'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Ixchel::Actions::sys_info - Fetches system info via Rex::Hardware and prints it in various formats. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 0.3.0 |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.3.0'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 CLI SYNOPSIS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
ixchel -a sys_info [B<-o> ] |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 CODE SYNOPSIS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Fetches system info via Rex::Hardware and prints it in various formats. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 Switches |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 -o |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Format to print it in. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Available: json, yaml, toml, dumper |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Default: toml |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
0
|
0
|
|
sub new_extra { } |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub action_extra { |
|
47
|
0
|
|
|
0
|
0
|
|
my $self = $_[0]; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}->{o} ) ) { |
|
50
|
0
|
|
|
|
|
|
$self->{opts}->{o} = 'toml'; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
0
|
0
|
|
|
|
if ( $self->{opts}->{o} ne 'toml' |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
54
|
|
|
|
|
|
|
&& $self->{opts}->{o} ne 'json' |
|
55
|
|
|
|
|
|
|
&& $self->{opts}->{o} ne 'dumper' |
|
56
|
|
|
|
|
|
|
&& $self->{opts}->{o} ne 'yaml' ) |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
|
|
|
|
|
|
$self->status_add( |
|
59
|
0
|
|
|
|
|
|
status => '-o is set to "' . $self->{opts}->{o} . '" which is not a understood setting', |
|
60
|
|
|
|
|
|
|
error => 1, |
|
61
|
|
|
|
|
|
|
); |
|
62
|
0
|
|
|
|
|
|
return undef; |
|
63
|
|
|
|
|
|
|
} ## end if ( $self->{opts}->{o} ne 'toml' && $self...) |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $sys_info = sys_info; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my @net_ifs = keys( %{ $sys_info->{Network}{networkconfiguration} } ); |
|
|
0
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
foreach my $net_if (@net_ifs) { |
|
69
|
0
|
|
|
|
|
|
my @net_if_args = keys( %{ $sys_info->{Network}{networkconfiguration}{$net_if} } ); |
|
|
0
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
foreach my $net_if_arg (@net_if_args) { |
|
71
|
0
|
0
|
|
|
|
|
if ( !defined( $sys_info->{Network}{networkconfiguration}{$net_if}{$net_if_arg} ) ) { |
|
72
|
0
|
|
|
|
|
|
$sys_info->{Network}{networkconfiguration}{$net_if}{$net_if_arg} = ''; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $string; |
|
78
|
0
|
|
|
|
|
|
eval { |
|
79
|
0
|
0
|
|
|
|
|
if ( $self->{opts}->{o} eq 'toml' ) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $to_eval = 'use TOML::Tiny qw(to_toml); $string = to_toml($sys_info) . "\n";'; |
|
81
|
0
|
|
|
|
|
|
eval($to_eval); |
|
82
|
0
|
|
|
|
|
|
print $string; |
|
83
|
|
|
|
|
|
|
} elsif ( $self->{opts}->{o} eq 'json' ) { |
|
84
|
0
|
|
|
|
|
|
my $json = JSON->new; |
|
85
|
0
|
|
|
|
|
|
$json->canonical(1); |
|
86
|
0
|
|
|
|
|
|
$json->pretty(1); |
|
87
|
0
|
|
|
|
|
|
$string = $json->encode($sys_info); |
|
88
|
0
|
|
|
|
|
|
print $string; |
|
89
|
|
|
|
|
|
|
} elsif ( $self->{opts}->{o} eq 'yaml' ) { |
|
90
|
0
|
|
|
|
|
|
$string = Dump($sys_info); |
|
91
|
0
|
|
|
|
|
|
print $string; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
0
|
0
|
|
|
|
|
if ($@) { |
|
95
|
0
|
|
|
|
|
|
$self->status_add( |
|
96
|
|
|
|
|
|
|
error => 1, |
|
97
|
|
|
|
|
|
|
status => $@, |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
} else { |
|
100
|
0
|
|
|
|
|
|
$self->{results}{status_text} = $string; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return undef; |
|
104
|
|
|
|
|
|
|
} ## end sub action_extra |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub short { |
|
107
|
0
|
|
|
0
|
1
|
|
return 'Prints data from the sys_info function.'; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub opts_data { |
|
111
|
0
|
|
|
0
|
1
|
|
return 'o=s'; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |