1# SNMP::Info::Layer3::VMware 2# 3# Copyright (c) 2014-2016 Max Kosmach 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are met: 8# 9# * Redistributions of source code must retain the above copyright notice, 10# this list of conditions and the following disclaimer. 11# * Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# * Neither the name of the University of California, Santa Cruz nor the 15# names of its contributors may be used to endorse or promote products 16# derived from this software without specific prior written permission. 17# 18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28# POSSIBILITY OF SUCH DAMAGE. 29 30package SNMP::Info::Layer3::VMware; 31 32use strict; 33use warnings; 34use Exporter; 35use SNMP::Info::Layer3; 36use SNMP::Info::IEEE802dot3ad 'agg_ports_lag'; 37 38@SNMP::Info::Layer3::VMware::ISA = qw/SNMP::Info::IEEE802dot3ad SNMP::Info::Layer3 Exporter/; 39@SNMP::Info::Layer3::VMware::EXPORT_OK = qw/agg_ports/; 40 41our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); 42 43$VERSION = '3.81'; 44 45%MIBS = ( 46 %SNMP::Info::IEEE802dot3ad::MIBS, 47 %SNMP::Info::Layer3::MIBS, 48 'VMWARE-PRODUCTS-MIB' => 'vmwProducts', 49 'VMWARE-SYSTEM-MIB' => 'vmwProdName', 50); 51 52%GLOBALS = ( 53 %SNMP::Info::Layer3::GLOBALS, 54 # VMWARE-SYSTEM-MIB 55 'vmwProdVersion' => 'vmwProdVersion', 56 'vmwProdBuild' => 'vmwProdBuild', 57 'vmwProdUpdate' => 'vmwProdUpdate', 58 'vmwProdPatch' => 'vmwProdPatch', 59 'os' => 'vmwProdName', 60); 61 62%FUNCS = ( 63 %SNMP::Info::Layer3::FUNCS, 64 %SNMP::Info::IEEE802dot3ad::FUNCS, 65); 66 67%MUNGE = ( 68 %SNMP::Info::Layer3::MUNGE, 69 %SNMP::Info::IEEE802dot3ad::MUNGE, 70); 71 72sub vendor { 73 return 'vmware'; 74} 75 76sub os_ver { 77 my $vmware = shift; 78 my $vmwProdVersion = $vmware->vmwProdVersion(); 79 my $vmwProdBuild = $vmware->vmwProdBuild() || ''; 80 my $vmwProdUpdate = $vmware->vmwProdUpdate() || ''; 81 my $vmwProdPatch = $vmware->vmwProdPatch() || ''; 82 83 my $ver = "$vmwProdVersion" . "-" . "$vmwProdUpdate.$vmwProdPatch.$vmwProdBuild"; 84 return $ver; 85} 86 87sub agg_ports { 88 return agg_ports_lag(@_); 89} 90 91#sub layers { 92# return '01001010'; 93#} 94 951; 96__END__ 97 98=head1 NAME 99 100SNMP::Info::Layer3::VMware - SNMP Interface to VMware ESXi 101 102=head1 AUTHORS 103 104Max Kosmach 105 106=head1 SYNOPSIS 107 108 # Let SNMP::Info determine the correct subclass for you. 109 my $host = new SNMP::Info( 110 AutoSpecify => 1, 111 Debug => 1, 112 DestHost => 'myhost', 113 Community => 'public', 114 Version => 2 115 ) 116 or die "Can't connect to DestHost.\n"; 117 118 my $class = $host->class(); 119 print "SNMP::Info determined this device to fall under subclass : $class\n"; 120 121=head1 DESCRIPTION 122 123Subclass for VMware ESXi 124 125=head2 Inherited Classes 126 127=over 128 129=item SNMP::Info::Layer3 130 131=item SNMP::Info::IEEE802dot3ad 132 133=back 134 135=head2 Required MIBs 136 137=over 138 139=item F<VMWARE-SYSTEM-MIB> 140 141=item F<VMWARE-PRODUCTS-MIB> 142 143=back 144 145=head2 Inherited Classes' MIBs 146 147See L<SNMP::Info::Layer3/"Required MIBs"> for its MIB requirements. 148 149See L<SNMP::Info::IEEE802dot3ad/"Required MIBs"> for its MIB requirements. 150 151=head1 GLOBALS 152 153These are methods that return scalar value from SNMP 154 155=over 156 157=item $vmware->vendor() 158 159Returns C<'vmware'>. 160 161=item $vmware->os() 162 163Returns the value of C<vmwProdName.0>. 164 165=item $vmware->os_ver() 166 167Returns the software version specified as major-update.patch.build (ex. 5.1.0-3.55.2583090). 168 169(C<vmwProdVersion>)-(C<vmwProdUpdate>).(C<vmwProdPatch>).(C<vmwProdBuild>) 170 171=back 172 173=head2 Globals imported from SNMP::Info::Layer3 174 175See documentation in L<SNMP::Info::Layer3> for details. 176 177=head1 TABLE ENTRIES 178 179These are methods that return tables of information in the form of a reference 180to a hash. 181 182=over 183 184=item C<agg_ports> 185 186Returns a HASH reference mapping from slave to master port for each member of 187a port bundle on the device. Keys are ifIndex of the slave ports, Values are 188ifIndex of the corresponding master ports. 189 190=back 191 192=head2 Table Methods imported from SNMP::Info::Layer3 193 194See documentation in L<SNMP::Info::Layer3> for details. 195 196=head2 Table Methods imported from SNMP::Info::IEEE802dot3ad 197 198See documentation in L<SNMP::Info::IEEE802dot3ad> for details. 199 200=cut 201