Upravy HotSaNICu v novejsich distribucich GNU/Linux

<small>Z PVwiki</small>

Zprovoznění HotSaNIC na iGW Italská

HotSaNIC je staršího data a potřebuje drobné úpravy zdrojových kódů, aby fungoval na současných distribucích GNU/Linux s novější verzí rrd.

irq:

--- HotSaNIC/modules/system/diagrams.pl 2003-11-20 11:09:44.000000000 +0100
+++ HotSaNIC/modules/system/diagrams.pl.new     2008-03-07 14:27:20.000000000 +0100
@@ -757,7 +757,7 @@
             "LINE1:irqxall#ff0000:",
             "LINE1:irqiall#00ff00:",
             "LINE1:irqaall#000000:",
-            "COMMENT:Averages (min/max):\\n",
+            "COMMENT:Averages (min/max)\\:\\n",
             "LINE2:irqa00#a00000:00".$ITEMS[0],
             "GPRINT:irqa00:MIN:%5.1lf%s/\\g",
             "GPRINT:irqa00:MAX:%5.1lf%s",

ping:

--- HotSaNIC/modules/ping/diagrams.pl   2003-10-16 12:25:38.000000000 +0200
+++ HotSaNIC/modules/ping/diagrams.pl.new       2008-03-07 13:58:52.000000000 +0100
@@ -82,16 +82,16 @@
             "LINE1:max#c00000:max",
             "GPRINT:max:MIN:  (min\\:%6.2lf%s /\\g",
             "GPRINT:max:AVERAGE: avg\\:%6.2lf%s /\\g",
-            "GPRINT:max:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+            "GPRINT:max:MAX: max\\:%6.2lf%s $LEGEND)\\n",
             "AREA:min#ffffff:",
             "LINE1:avg#000000:avg",
             "GPRINT:avg:MIN:  (min\\:%6.2lf%s /\\g",
             "GPRINT:avg:AVERAGE: avg\\:%6.2lf%s /\\g",
-            "GPRINT:avg:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+            "GPRINT:avg:MAX: max\\:%6.2lf%s $LEGEND)\\n",
             "LINE1:min#00c000:min",
             "GPRINT:min:MIN:  (min\\:%6.2lf%s /\\g",
             "GPRINT:min:AVERAGE: avg\\:%6.2lf%s /\\g",
-            "GPRINT:min:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+            "GPRINT:min:MAX: max\\:%6.2lf%s $LEGEND)\\n",
             "AREA:wrong#ffffa0:unreachable",
             "HRULE:0#000000";
           }
@@ -115,17 +115,17 @@
               "LINE1:maxx#c00000:max",
               "GPRINT:maxi:MIN:  (min\\:%6.2lf%s /\\g",
               "GPRINT:maxa:AVERAGE: avg\\:%6.2lf%s /\\g",
-              "GPRINT:maxx:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+              "GPRINT:maxx:MAX: max\\:%6.2lf%s $LEGEND)\\n",
               "LINE1:avga#000000:avg",
               "GPRINT:avgi:MIN:  (min\\:%6.2lf%s /\\g",
               "GPRINT:avga:AVERAGE: avg\\:%6.2lf%s /\\g",
-              "GPRINT:avgx:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+              "GPRINT:avgx:MAX: max\\:%6.2lf%s $LEGEND)\\n",
               "LINE1:mini#00c000:min",
               "GPRINT:mini:MIN:  (min\\:%6.2lf%s /\\g",
               "GPRINT:mina:AVERAGE: avg\\:%6.2lf%s /\\g",
-              "GPRINT:minx:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+              "GPRINT:minx:MAX: max\\:%6.2lf%s $LEGEND)\\n",
               "AREA:wrong#ffffa0:unreachable",
-              "HRULE:0#000000";
+             "HRULE:0#000000";
             }
           else {
             ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b","1000", "-v",$LEGEND,
@@ -144,17 +144,17 @@
               "AREA:maxx#ffc0c0:max",
               "GPRINT:maxi:MIN:  (min\\:%6.2lf%s /\\g",
               "GPRINT:maxa:AVERAGE: avg\\:%6.2lf%s /\\g",
-              "GPRINT:maxx:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+              "GPRINT:maxx:MAX: max\\:%6.2lf%s $LEGEND)\\n",
               "AREA:maxi#ffffff:",
               "AREA:avgx#c0c0ff:avg",
               "GPRINT:avgi:MIN:  (min\\:%6.2lf%s /\\g",
               "GPRINT:avga:AVERAGE: avg\\:%6.2lf%s /\\g",
-              "GPRINT:avgx:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+              "GPRINT:avgx:MAX: max\\:%6.2lf%s $LEGEND)\\n",
               "AREA:avgi#ffffff:",
               "AREA:minx#c0ffc0:min",
               "GPRINT:mini:MIN:  (min\\:%6.2lf%s /\\g",
               "GPRINT:mina:AVERAGE: avg\\:%6.2lf%s /\\g",
-              "GPRINT:minx:MAX: max\\:%6.2lf%s $LEGEND)\\n:",
+              "GPRINT:minx:MAX: max\\:%6.2lf%s $LEGEND)\\n",
               "AREA:mini#ffffff:",
               "LINE1:maxa#c00000:",
               "LINE1:mina#00c000:",

Zprovoznění modulu diskio na jádru 2.6

  • Autor: Badla | 27 červen 2008 14:48

Úprava HotSaNICu, aby na linuxovém jádru 2.6 fungoval modul diskio (přenosy dat na HDDs).

Podkladem a inspiračním zdrojem bylo "povídání" na stránce http://personal.jirik.net/projects.php

diff -Naur ./platform/common.pm ./platform.new/common.pm
--- ./platform/common.pm   2004-02-27 10:23:49.000000000 +0100
+++ ./platform.new/common.pm   2007-10-13 21:09:51.000000000 +0200
@@ -9,8 +9,12 @@
 sub configure {
   foreach (@_) {
     ($var,$value)=HotSaNICparser::parse_line($_);
-    if ($var eq "KERNEL") { $MODARGS{KERNEL}=$value; last; }
+    if ($var eq "KERNEL") { $MODARGS{KERNEL}=$value; }
+    if ($var eq "DEV") {
+      my ($dev,$name)=split(/,/,$value);
+      $MODARGS{"DEV:$dev"}=$value;
     }
+  }
   if ( (! defined $MODARGS{KERNEL}) || ($MODARGS{KERNEL} eq "") ) {
     use POSIX "uname";
     my ($sysname, $nodename, $release, $version, $machine ) = uname;
diff -Naur ./platform/linux.pm ./platform.new/linux.pm
--- ./platform/linux.pm   2004-02-29 16:29:36.000000000 +0100
+++ ./platform.new/linux.pm   2007-10-13 21:09:51.000000000 +0200
@@ -48,8 +48,48 @@
       $num++;
       }
     }
+######################################################################
+#ls ./
+# KERNEL 2.6 CODE
+#
+  elsif ($args{KERNEL} eq "2.6") {
+
+    #  diskstats: major minor  name  rio    rmerge rsect    ruse    wio    wmerge   wsect     wuse     running use     aveq
+    #                3    64   hdb   524233 57272  91269016 6239457 233008 24726677 199678904 73630251 0       6331127 79891245
+    #                3    64   hdb   524298 57274  91284864 6239742 233012 24726679 199678952 73630252 0       6331403 79891531
+
+    my %DEVS=();
+   
+    foreach (keys(%args)) {
+      if (index($_,"DEV:") >= 0 ) {
+        (undef,$dev)=split /:/;
+   $DEVS{$dev}="0";
+      }
+    }   
+
+    open FILE,"/proc/diskstats";
+    while ($entry = <FILE>) {
+      $entry =~ s/^\s*//; # strip leading whitespaces
+      my @values = split(/\s+/,$entry);
+#      my ($major,$minor,undef,$racc,undef,$rsect,undef,$wacc,undef,$wsect,undef,undef,undef,undef)=split(/\s+/,$entry);
+#      $device=$major."_".$minor;
+      $device = $values[0]."_".$values[1];
+      if (defined $DEVS{$device}) {
+        if( scalar( @values ) < 10 ){
+#      store_values($args{MODNAME},$device,$racc,$wacc,$rsect,$wsect,512);
+          store_values($args{MODNAME},$device,$values[3],$values[5],$values[4],$values[6],512);
+   } else {
+          store_values($args{MODNAME},$device,$values[3],$values[7],$values[5],$values[9],512);
+        } 
+      }
+    }
+    close FILE;
+    }
+
   }
 
+
+
 sub store_values {
  my ($MODNAME,$drive,$racc,$wacc,$rblk,$wblk,$blksize)=@_;

v souboru /var/HotSaNIC/modules/diskio/settings změnit proměnnou:

KERNEL="2.6"

a do proměnných DEV uvádět disky v tomto formátu:

DEV=8_0,sda

kde 8_0 je dán typem disku... hodnotu vyčtete podle prvních dvou sloupců v seznamu /proc/diskstats


CPU (vykresluje skutecne zatizeni procesoru):

--- /var/HotSaNIC/modules/system/platform/linux.pm
+++ /var/HotSaNIC/modules/system/platform/linux.pm.new
@@ -60,7 +60,7 @@
-            ($cpu, $cpu1, $cpu2, $cpu3, $cpu4)=split;
+            ($cpu, $cpu1, $cpu2, $cpu3, $cpu4, $cpu5, $cpu6, $cpu7, $cpu8)=split;
@@ -65,7 +65,7 @@
-            $cpu5{$cpu}=0;
+            $cpu5{$cpu}=($cpu5+$cpu6+$cpu7+$cpu8);
Osobní nástroje