The goto is ugly and very probably not at all necessary. I'll assume a sub cleanup() for the moment. For some reason, you chose to only test if $metastat exists, and then you don't use it in ExecCmd. I'll assume you have a good reason for that.
The exercise is to spot the differences yourself.
use strict; # first.
use NetIQ::Nqext;
my $sev_fail = 10;
my $metastat = "/usr/sbin/metastat";
my $resmsg = "";
-e $metastat or cleanup;
# Assuming 0 also indicates failure:
NetIQ::Nqext::ExecCmd("metastat|grep State:|grep -v Okay") or cleanup;
my $results = NetIQ::Nqext::ExecCmd("metastat");
# Where does $do_event come from and why isn't it just a simple boolea
+n?
if ($do_event eq "y") {
NetIQ::Nqext::CreateEvent(
$severity,
"Disksuite Disk(s) Need Attention",
$Akpid, # capital A?
$resmsg,
0, # description of the parameter (one word will suff
+ice)
$results,
"", # description
0, # description
0 # description
);
}
If you do not have a sub cleanup(), you can still avoid using the ugly goto LABEL by putting this code in a bare block (which is a loop that runs one time).
use strict; # first.
use NetIQ::Nqext;
my $sev_fail = 10;
my $metastat = "/usr/sbin/metastat";
my $resmsg = "";
{
-e $metastat or last;
# Assuming 0 also indicates failure:
NetIQ::Nqext::ExecCmd("metastat|grep State:|grep -v Okay") or last
+;
my $results = NetIQ::Nqext::ExecCmd("metastat");
if ($do_event eq "y") {
NetIQ::Nqext::CreateEvent(
...
);
}
}
|