in reply to getuptime script

I think your problem is in parsing the output of your "fcping 50:06:0E:80:03:27:AA:11" command. You are currently assigning the multi-line output of the command to a scalar variable, $temp. It may make things clearer to assign the output to an array, then loop over the lines of output looking for your special string using a regex instead of split:
my @fcping_lines = `fcping $port`; for (@fcping_lines) { if (/\s+ and \s+ (.*?) \s+/x) { my $unsucces = $1; if ($unsucces eq "0") { print "Network Issue\n"; } else { print "Check HBA Status\n"; } } }

Make sure to use strict; use warnings and declare all you variables with my.

It may also be useful to check the success of your fcping commands, by checking the $? special variable.

Replies are listed 'Best First'.
Re^2: getuptime script
by deepupower123 (Initiate) on Oct 30, 2008 at 18:13 UTC
    toolic, Thanks for your reply. How do I find the uptime % ? I get the current uptime in days ($days), I need to calculate the %uptime (number of days the host is up / Total no. of days the script is run * 100). I'm not sure how to get these values. Could you please help?