Das funktioniert bei mir:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
my $ipconf='/etc/lighttpd/server_ip.conf';
my $site='http://%s/ldirector.html';
open(my $fh, '<', $ipconf) or die($!);
my $ip=<$fh>;
$ip=~s/^.+"([^"]+?)".+$/$1/s;
close($fh);
unless(get(sprintf($site,$ip)))
{print 1; exit;}
my $uptime=`uptime`;
(my $load)=$uptime=~/load average:\s+([\d.]+)/;
$load*=100;
if($load>400)
{print 0; exit;}
print 100-int($load/4);
exit;