I have made a script that returns me an array with several lines like:
DATA:VALUE:VALUE_MAX
I need to fill a table with those value like:
NAME | Status
--------------------------
DATA | OK/minor/warning...
.... | .........
.... | .........
with VALUE and VALUE_MAX I calculate the percent which gives me the status.
here is my code for print the table:
my @i = my_status();
print <<END;
<div class="container">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Status</th>
</tr>
</thead>
<tbody>
END
my $inc = 0;
while (@i) {
my @temp = split /:/, @i[$inc];
my $name = $temp[0];
my $percent = ($temp[1] * $temp[2] / 100);
my $status = undef;
if ($percent <= 24 ) {
print "<tr class='info'>";
$status = "Critical !";
}
elsif ($percent <= 49 ) {
print "<tr class='danger'>";
$status = "Danger !";
}
elsif ($percent <= 74 ) {
print "<tr class='warning'>";
$status = "Warning";
}
elsif ($percent <= 99 ) {
print "<tr class='active'>";
$status = "Minor";
}
elsif ($percent == 100 ) {
print "<tr class='success'>";
$status = "OK";
}
print "<td>$name</td>";
print "<td>$status</td>";
print "</tr>";
$inc++;
}
print <<END;
</tbody>
</table>
</div>
END
My script "my_status" is a bit long to execute, it's full of server request...
but the thing is, on the HTML page, everything is a mess, I get wrong value, and an endless loop who print only "Critical !" in status columns
What is wrong with my script?
info?