#!/usr/bin/perl my $RESULT="OK"; use strict; use warnings; my $STATE_OK=0; my $STATE_WARNING=1; my $STATE_CRITICAL=2; my $STATE_UNKNOWN=3; my %error_code = ( SysBatteryFailure => 'System Battery Failure', PowerRedundencyFailure => 'Power Redundency Failure', FltTolPowerSupplyFailed => 'Fault Tolerant Power Supply Failure', ); my $SysBatteryFailure=`echo \"Battery Failure\" | grep Failure`; my $PowerRedundencyFailure=`echo \"Power Redundency Failure\" | grep trash`; my $FltTolPowerSupplyFailed=`echo \"Power Supply Failure\" | grep trash`; my @STATUS = ($SysBatteryFailure, $PowerRedundencyFailure, $FltTolPowerSupplyFailed); my @ILO_ERRORS = (); foreach my $element (@STATUS) { chomp $element; if ($element) { # The element variable is accurate here print "$element\n"; # the following line fails. I want to push the hash # into the array. Any idea why it fails? push (@ILO_ERRORS, $element); } } if (@ILO_ERRORS) { print "SNMP CRITICAL - ", @ILO_ERRORS; exit $STATE_CRITICAL; } else { print "SNMP OK - $STATE_OK"; exit $STATE_OK; }