BigIP-GTM-ParseConfig
view release on metacpan or search on metacpan
example/example.pl view on Meta::CPAN
say encode(
'cp936',
decode_utf8(
"\nperl $0 -d directory(ç®å½) || -f f5_GTM_config(å个é
ç½®æä»¶)\n"
)
);
say encode(
'cp936',
decode_utf8(
'使ç¨è¿ç¨å¦æä»»ä½çé®ï¼è¯·èç³»careline@126.com')
);
exit();
}
# use Getopt::Long qw(:config no_ignore_case bundling);
Getopt::Long::Configure( "bundling", "no_ignore_case" );
GetOptions(
'V' => \$opt_V,
'h' => \$opt_h,
'f=s' => \$opt_f,
'd=s' => \$opt_d,
) || die usage();
my %dc = (
"DC_ChaoSuan" => "è¶
ç®æºæ¿",
"DC_813" => "æé³é¨æºæ¿",
"DC_PengBoShi" => "é¹åå£«æºæ¿",
"DC_650" => "æ±å¤©æºæ¿",
"DC_HeFei" => "åè¥æºæ¿"
);
# option handling initialization
if ($opt_V) {
say "F5 DevCenter BIGIP GTM configuration Parser V2.020";
exit(-1);
}
if ( $opt_h || not( $opt_d || $opt_f ) ) {
usage();
}
my $dirname = $opt_d;
sub write_excel {
my $GTM = shift;
my $time = strftime( "%Y%m%d", localtime() );
my $bip = BigIP::GTM::ParseConfig->new($GTM);
my $dns_all = $bip->wideips_all();
# Create a new Excel workbook
my $workbook
= Spreadsheet::WriteExcel->new(
"bigip-GTM-reports_$GTM" . "_$time" . '.xls' );
# Add a worksheet
my $worksheet = $workbook->add_worksheet( $GTM . '_DNS_details' );
# Add and define a format
my $format = $workbook->add_format(); # Add a format
$format->set_bold();
$format->set_color('blue');
$format->set_bg_color('red');
$format->set_size(18);
$format->set_border(1);
$format->set_align('center');
$format->set_valign('vcenter');
my $format_1 = $workbook->add_format();
$format_1->set_size(12);
$format_1->set_border(1);
$format_1->set_align('left');
$format_1->set_valign('vcenter');
my $format_2 = $workbook->add_format();
$format_1->set_size(12);
$format_2->set_align('center');
$format_2->set_valign('vcenter');
# set column and row width;
$worksheet->set_column( 0, 6, 45, $format_2 );
# Write a formatted and unformatted string, row and column notation.
my $excel_array = [
decode_utf8("DNSæ¡ç®"),
decode_utf8("è´è½½æ¨¡å¼"),
decode_utf8("POOL-ä¼å
级"),
decode_utf8("VSæ å°å
³ç³»"),
decode_utf8("DNSè§£ææç»"),
decode_utf8("å¥åº·æ£æ¥-æå¡ç±»å"),
decode_utf8("å·¥åä¿¡æ¯"),
];
$worksheet->write_row( 0, 0, $excel_array, $format );
my ( $result, $dns_attr );
my $row = 0;
foreach my $dns ( keys %{$dns_all} ) {
foreach my $attr ( keys %{ $dns_all->{$dns} } ) {
$result->{$dns}{"wide_ip"} = $dns;
my $ret = $dns_all->{$dns}{$attr};
$result->{$dns}{"report"} ||= [];
$result->{$dns}{"server"} ||= [];
$result->{$dns}{"monitor"} ||= [];
$result->{$dns}{"pool_order"} ||= [];
if ( $attr =~ /\Apool-lb-mode\z/ ) {
$result->{$dns}{"mode"} = $ret;
}
elsif ( $attr =~ /\Apools\z/ ) {
my $pool;
foreach ( keys %{$ret} ) {
my $rev = $ret->{$_};
$pool = $_;
my $order;
foreach ( keys %{$rev} ) {
$order .= join( " ", $_, '->', $rev->{$_}, ' ' )
if exists $rev->{$_};
}
my $pool_order = $pool . " \( $order \) ";
( run in 0.484 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )