use Encode 'from_to';
my %tr=();
+system("chmod 777 /srv/web/ipfire/html/graphs");
+
# Force language back to English (ugly hack!)
# Modified to only force if we are unable to convert charset
# from utf-8
sub updatecpudata {
if ( ! -e "$rrdlog/cpu.rrd") {
RRDs::create ("$rrdlog/cpu.rrd", "--step=300",
- "DS:user:GAUGE:600:0:100",
- "DS:system:GAUGE:600:0:100",
- "DS:idle:GAUGE:600:0:100",
- "DS:iowait:GAUGE:600:0:100",
+ "DS:user:COUNTER:600:0:500000000",
+ "DS:system:COUNTER:600:0:500000000",
+ "DS:idle:COUNTER:600:0:500000000",
+ "DS:iowait:COUNTER:600:0:500000000",
+ "DS:irq:COUNTER:600:0:500000000",
"RRA:AVERAGE:0.5:1:576",
"RRA:AVERAGE:0.5:6:672",
"RRA:AVERAGE:0.5:24:732",
print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
}
- my ($cpu, $user, $nice, $system, $idle, $trash, $iowait);
+ my ($cpu, $user, $nice, $system, $idle, $iowait, $irq, $softirq);
- my $Zeilen = `/usr/bin/iostat -c | tail -2 | head -1`;
- ($trash, $user, $nice, $system, $iowait, $trash, $idle) = split(/\s+/,$Zeilen);
+ open STAT, "/proc/stat";
+ while(<STAT>) {
+ chomp;
+ /^cpu\s/ or next;
+ ($cpu, $user, $nice, $system, $idle, $iowait, $irq, $softirq) = split /\s+/;
+ last;
+ }
+ close STAT;
$user += $nice;
+ $irq += $softirq;
+
RRDs::update ("$rrdlog/cpu.rrd",
- "-t", "user:system:idle:iowait",
- "N:$user:$system:$idle:$iowait");
+ "-t", "user:system:idle:iowait:irq",
+ "N:$user:$system:$idle:$iowait:$irq");
$ERROR = RRDs::error;
print "Error in RRD::update for cpu: $ERROR\n" if $ERROR;
my $roundtrip=0;
my $test=0;
# LQ_GATEWAY is the ip of your isp's public ip facing you
- my $LQ_GATEWAY=`netstat -rn | grep ^0.0.0.0 | awk '{print \$2}'`;
- my $NUMPINGS=10;
+ my $LQ_GATEWAY=`cat /var/ipfire/red/remote-ipaddress`;
+ chomp($LQ_GATEWAY);
+ my $NUMPINGS=5;
my $pingoutput = `ping -c $NUMPINGS -q $LQ_GATEWAY`;
chomp;
my @temp = split (/\/|\%|\s/, $pingoutput);
$temp = 0;
my $hdd_output = '';
my $smart_output = '';
-
+
if ( -e "$path_smartctl" )
{
system("$path_smartctl -iHA /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
if ( -e "$path_hddtemp" )
{
$hdd_output = `$path_hddtemp -qn /dev/$disk`;
-
+
# I know 4 response possible responses:
#
# /dev/harddisk: harddisk type: S.M.A.R.T. not available
{
$temp = 0;
}
+
-# print "hdd $hdd_output \n";
-# print "temp $temp \n";
+ print "Temperature for ".$disk."->".$temp."<-\n";
RRDs::update ("$rrdlog/hddtemp-$disk.rrd", "-t", "temperature", "N:$temp");
-
$ERROR = RRDs::error;
print "Error in RRD::update for hdd-$disk: $ERROR\n" if $ERROR;
}
updateloaddata();
updatememdata();
+###
+### HDD graphs
+###
+
my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
print "\nFound following amount of disks:".@disks."\n";
foreach (@disks){
chomp $disk;
print "Working on disk ".$disk.".\n";
updatediskdata($disk);
+updatehdddata($disk);
}
###
updatelq();
###
-### HDDTEMP-Graphs for /dev/harddisk
+### Mbmon Data
###
-
-my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
-print "\nFound following amount of disks for hddtemp:".@disks."\n";
-foreach (@disks){
-my $disk = $_;
-chomp $disk;
-updatehdddata ($disk);
-}
+updatembmondata();
###
### Network Graphs