Update: ++TomDLux , beat me to the punch! Signing up for
the monastery is a great idea.
HTML::Template will save your bacon. Specifically
its looping feature. Design the layout of a table/cell for one
switch status. Insert place holders into the relevant fields, and
a template loop around the whole deal.
<html> <body> <table border=3> <TMPL_LOOP switches> <tr> <td> <TMPL_VAR hostname> </td> <td> <TMPL_VAR status> </td> </tr> </TMPL_LOOP> </table> </body> </html>
Then you can feed your data into that with HTML::Template
#!/usr/bin/perl -w use strict; use Data::Dumper; use HTML::Template; my $template = HTML::Template->new( filename=>'./switch-status.tmpl' ) +; my @hosts = ( qw/ switch cisco1 cisco2 ninety nine cisco5 / ); my $info = []; foreach my $host ( @hosts ) { my $data = { hostname=> $host, status => Host2Status($host) , }; push @$info , $data; } $template->param(switches=>$info); print $template->output; sub Host2Status { my $host = shift; my $rand_status = int (rand 2)-1; my $status = ($rand_status) ? "Cool" : "Froody"; return $status; }
This code works for me , no guarantees though. The cpan documentation for HTML::Template is good. If you are familiar with creating semi-complex datastructures in perl like an array of hashes, you will have this done in _NO_ time.
In reply to Re: Generating HTML from SNMP data
by submersible_toaster
in thread Generating HTML from SNMP data
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |