Hi, I want my code to execute the unix free command in order to analyze the memory state, and issue a warning if the cached memory increases. I don`t know what I did wrong, but this is what I got for now:
#! /usr/bin/perl use warnings; use strict; # return codes $ok = 0; $warning = 1; $critical = 2; open(my $memory, "free") or die "Error: $!"; # running unix command "free" $regex = "^((?!total).)*$"; while (my $line = $vgs){ if ($line =~ m/$regex/){ chomp $line; my @array = split /\s+/, $line; if ($array[6] >= "867580"){ print "$warning\n"; }elsif ($array[6] >= "689967"){ print "$critical\n"; }else{ print "$ok\n"; } } }