#!/usr/bin/perl use SNMP; use Getopt::Std; %opts = ( M => ".", D => "html"); getopts("M:D:WH:", \%opts) || die "usage: makehtml.pl -W [-M MIBDIR] [-D OUTDIR] files > index.html"; $SNMP::save_descriptions = 1; $ENV{'MIBDIRS'} = $opts{'M'}; $ENV{'SNMPCONFPATH'} = 'bogus'; if (-f "rfclist") { open(I,"rfclist"); while () { if (/^(\d+)\s+([-:\w]+)\s*$/) { my $mib = $2; my $rfc = $1; my @mibs = split(/:/,$mib); foreach my $i (@mibs) { $mibs{$i} = $rfc; } } } close(I); } if (-f "nodemap") { open(I,"nodemap"); while () { if (/^([-\w]+)\s+(\w+)\s*$/) { $nodemap{$1} = $2; } } close(I); } if ($opts{'W'}) { print '

Net-SNMP Distributed MIBs

The following are the MIB files distributed with Net-SNMP. Note that because they are distributed with Net-SNMP does not mean the agent implements them all. Another good place for finding other MIB definitions can be found at the MIB depot.

'; } my %didit; foreach my $mibf (@ARGV) { my $node; my $mib = $mibf; $mib =~ s/.txt//; next if ($didit{$mib}); $didit{$mib} = 1; open(I, "$opts{M}/$mibf"); while () { if (/(\w+)\s+MODULE-IDENTITY/) { $node = $1; } } close(I); if (!$node) { print STDERR "Couldn't find starting node for $mib $node $_\n"; next; } SNMP::loadModules($mib); $desc = $SNMP::MIB{$node}{'description'}; # get a different tree than the module identity though. if (exists($nodemap{$mib})) { $node = $nodemap{$mib}; } # Change tabs to spaces $desc =~ s/\t/ /g; # Clean up formatting my ($s) = ($desc =~ /\n(\s+)/); $desc =~ s/^$s//gm; $desc =~ s/&/&/g; $desc =~ s//>/g; print " \n"; print " \n"; print "
[conformance summary]\n"; print "
\n" if ($mibs{$mib}); print " \n" if (!$mibs{$mib}); print " \n"; print " \n"; system("MIBS=$mib mib2c -c mib2c.genhtml.conf $node"); system("mv $node.html $opts{D}"); } print "
MIBRFCDescription
$mib
\n"; print " [mib file]
rfc$mibs{$mib} 
$desc
\n";