File Coverage

blib/lib/SNMP/Insight/MIB/HostResources.pm
Criterion Covered Total %
statement 9 15 60.0
branch n/a
condition n/a
subroutine 3 5 60.0
pod 2 2 100.0
total 14 22 63.6


line stmt bran cond sub pod time code
1             package SNMP::Insight::MIB::HostResources;
2              
3             #ABSTRACT: Support for data in UCD MIB
4              
5 1     1   520 use Moose::Role;
  1         2  
  1         7  
6              
7 1     1   4114 use SNMP::Insight::Moose::MIB;
  1         1  
  1         7  
8 1     1   2525 use namespace::autoclean;
  1         2  
  1         7  
9              
10             our $VERSION = '0.001'; #TRIAL VERSION:
11              
12             mib_oid '1.3.6.1.2.1.25';
13             mib_name 'HOST-RESOURCES-MIB';
14              
15             with 'SNMP::Insight::MIB';
16              
17             has_scalar 'hrSystemUptime' => (
18             oid => '1.1',
19             );
20              
21             has_scalar 'hrSystemNumUsers' => (
22             oid => '1.5',
23             );
24              
25             has_scalar 'hrSystemProcesses' => (
26             oid => '1.6',
27             );
28              
29             has_table 'hrStorageTable' => (
30             oid => '2.3',
31             index => 'hrStorageIndex',
32             columns => {
33             'hrStorageIndex' => 1,
34             'hrStorageType' => 2,
35             'hrStorageAllocationUnits' => 3,
36             'hrStorageSize' => 4,
37             'hrStorageUsed' => 5,
38             'hrStorageAllocationFailures' => 6,
39             },
40             );
41              
42             has_table 'hrDeviceTable' => (
43             oid => '3.2',
44             index => 'hrDeviceIndex',
45             columns => {
46             'hrDeviceIndex' => 1,
47             'hrDeviceType' => 2,
48             'hrDeviceDescr' => 3,
49             'hrDeviceID' => 4,
50             'hrDeviceStatus' => [ 5, 'munge_device_status' ],
51             'hrDeviceErrors' => 6,
52             },
53             );
54              
55             has_table 'hrProcessorTable' => (
56             oid => '3.2',
57             index => 'hrDeviceIndex',
58             columns => {
59             'hrProcessorFrwID' => 1,
60             'hrProcessorLoad' => 2,
61             },
62             );
63              
64             has_table 'hrDiskStorageTable' => (
65             oid => '3.6',
66             index => 'hrDiskStorageAccess',
67             columns => {
68             'hrDiskStorageAccess' => 1,
69             'hrDiskStorageMedia' => 2,
70             'hrDiskStorageRemoveble' => 3,
71             'hrDiskStorageCapacity' => 4,
72             },
73             );
74              
75             #TODO hrPartitionTable
76             #TODO hrFSTable
77              
78             has_table 'hrSWRunTable' => (
79             oid => '4.2',
80             index => 'hrSWRunIndex',
81             columns => {
82             'hrSWRunIndex' => 1,
83             'hrSWRunName' => 2,
84             'hrSWRunID' => 3,
85             'hrSWRunPath' => 4,
86             'hrSWRunParameters' => 5,
87             'hrSWRunType' => 6,
88             'hrSWRunStatus' => 7,
89              
90             },
91             );
92              
93             # TODO hrSWRunPerl
94              
95             has_table 'hrSWInstalledEntry' => (
96             oid => '6.3',
97             index => 'hrSWInstalledIndex',
98             columns => {
99             'hrSWInstalledIndex' => 1,
100             'hrSWInstalledIndex' => 2,
101             'hrSWInstalledID' => 3,
102             'hrSWInstalledType' => 4,
103             'hrSWInstalledDate' => [ 5, 'munge_installed_date' ],
104             },
105             );
106              
107             sub munge_device_status {
108 0     0 1   my $val = shift;
109 0           my @stati = qw(INVALID unknown running warning testing down);
110 0           return $stati[$val];
111             }
112              
113             sub munge_installed_date {
114 0     0 1   my $val = shift;
115              
116 0           my ( $y, $m, $d, $hour, $min, $sec ) = unpack( 'nCCCCC', $val );
117              
118 0           return "$y-$m-$d $hour:$min:$sec";
119              
120             }
121              
122             1;
123              
124             # Local Variables:
125             # mode: cperl
126             # indent-tabs-mode: nil
127             # cperl-indent-level: 4
128             # cperl-indent-parens-as-block: t
129             # End:
130              
131             __END__
132              
133             =pod
134              
135             =head1 NAME
136              
137             SNMP::Insight::MIB::HostResources - Support for data in UCD MIB
138              
139             =head1 VERSION
140              
141             version 0.001
142              
143             =head1 FUNCTIONS
144              
145             =head2 munge_device_status
146              
147             Convert device status to a string like unknown running warning testing down.
148              
149             =head2 munge_installed_date
150              
151             Convert hrSWInstalledDate to a human readble date time.
152              
153             =head1 AUTHOR
154              
155             Gabriele Mambrini <g.mambrini@gmail.com>
156              
157             =head1 COPYRIGHT AND LICENSE
158              
159             This software is copyright (c) 2015 by Gabriele Mambrini.
160              
161             This is free software; you can redistribute it and/or modify it under
162             the same terms as the Perl 5 programming language system itself.
163              
164             =cut