#!/usr/bin/perl use Net::SSH2; use warnings; use strict; use diagnostics; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); my $datestring = sprintf("%4d_%02d_%02d_%02d",($year + 1900),($mon+1),$mday,$hour); my $sw; use constant BUFLEN => 50_0000 ; my $user = ""; my $password = ""; my $buf; my $channel; my $command; my $read; #get ip’s #open file open(FILE, "c:/scripts/ips2.txt") or die("Unable to open file"); # read file into an array my @data = ; # print output to file open OUTPUT, '+>', "EMC-$datestring.txt" or die $!; # create / open the out.txt for STDOUT redirection open ERROR, '+>', "err-$datestring.txt" or die $!; # create / open the err.txt for errors redirection STDOUT->fdopen( \*OUTPUT, 'w' ) or die $!; # redirecting the STDOUT to file STDERR->fdopen( \*ERROR, 'w' ) or die $!; # redirecting the errors to file foreach $sw (@data) { my $ssh = Net::SSH2->new(); if(!$ssh->connect($sw)){ print("Connection Failed\n"); exit(1); } if(!$ssh->auth_password($user,$password)){ print("Authentication Failed"); exit(1); } print "#####################################################################################\n"; print "Status report of EMC VNX with IP:$sw \n"; print "#####################################################################################\n"; # Printing Hardware print "Health Check \n"; { $buf =""; my $channel = $ssh->channel(); my $command = $channel->exec("/nas/bin/nas_checkup"); my $read = $channel->read($buf, BUFLEN ); warn 'More than', BUFLEN, 'characters in listing' if $read >= BUFLEN; print "$buf \n"; } print "#####################################################################################\n"; print "END of Report \n"; print "#####################################################################################\n"; }