see to get new router data recorded via SNMP
[php-utility-classes.git] / include / classes / rrdstat.php-class
index f0cf864676846f107baaafac01b9e70aa43563b5..deb8cdaef81250a998a00f18cbc6c1391c5854b0 100644 (file)
@@ -366,8 +366,13 @@ class rrdstat {
             $evalcode = 'function { return trim('.substr($ds['update'], 4).')); }';
           }
           elseif (substr($ds['update'], 0, 8) == 'snmp-if:') {
-            $snmphost = 'localhost'; $snmpcomm = 'public';
-            list($nix, $ifname, $valtype) = explode(':', $ds['update'], 3);
+            if (substr_count($ds['update'], ':') >= 4) {
+              list($nix, $snmphost, $snmpcomm, $ifname, $valtype) = explode(':', $ds['update'], 5);
+            }
+            else {
+              $snmphost = 'localhost'; $snmpcomm = 'public';
+              list($nix, $ifname, $valtype) = explode(':', $ds['update'], 3);
+            }
             $iflist = explode("\n", `snmpwalk -v2c -c $snmpcomm $snmphost interfaces.ifTable.ifEntry.ifDescr`);
             $ifnr = null;
             foreach ($iflist as $ifdesc) {
@@ -966,14 +971,15 @@ class rrdstat {
     if (isset($pconf['stats_url_add'])) { $sURL_add = $pconf['stats_url_add']; }
     else { $sURL_add = '&sub=%s'; }
 
-    $num_rows = is_numeric($pconf['num_rows'])?$pconf['num_rows']:2;
-    $num_cols = ceil(count($stats)/$num_rows);
+    $default_num_cols = $GLOBALS['ua']->isMobile()?1:2;
+    $num_cols = is_numeric($pconf['num_rows'])?$pconf['num_rows']:$default_num_cols;
+    $num_rows = ceil(count($stats)/$num_cols);
 
     $out .= '<table class="overview">'."\n";
-    for ($col = 0; $col < $num_cols; $col++) {
+    for ($row = 0; $row < $num_rows; $row++) {
       $out .= '<tr>'."\n";
-      for ($row = 0; $row < $num_rows; $row++) {
-        $idx = $col * $num_rows + $row;
+      for ($col = 0; $col < $num_cols; $col++) {
+        $idx = $row * $num_cols + $col;
         $out .= '<td>'."\n";
         if ($idx < count($stats)) {
           @list($sname, $s_psub) = explode('|', $stats[$idx]['name'], 2);