]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/scripts/makegraphs
Graphen ueberarbeitet
[people/pmueller/ipfire-2.x.git] / src / scripts / makegraphs
index 8343b33df97c82db1503133639f9a8398b06f2fb..ed3bbeac250ba317041dc5bf4209c1c4b92e059a 100644 (file)
@@ -38,6 +38,8 @@ my %mbmon_settings = ();
 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
@@ -115,10 +117,11 @@ sub gettraffic {
 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",
@@ -127,15 +130,23 @@ sub updatecpudata {
                 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;
 
@@ -365,8 +376,9 @@ sub updatelq {
         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);
@@ -396,7 +408,7 @@ sub updatehdddata
   $temp = 0;
   my $hdd_output = '';
   my $smart_output = '';
-
+  
   if ( -e "$path_smartctl" )
   {
     system("$path_smartctl -iHA /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
@@ -405,7 +417,7 @@ sub updatehdddata
   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
@@ -442,12 +454,11 @@ sub updatehdddata
   {
     $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;
 }
@@ -538,6 +549,10 @@ updatecpudata();
 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){
@@ -545,6 +560,7 @@ my $disk = $_;
 chomp $disk;
 print "Working on disk ".$disk.".\n";
 updatediskdata($disk);
+updatehdddata($disk);
 }
 
 ###
@@ -558,16 +574,9 @@ updatefwhitsdata();
 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