• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    bandwidth.php misses NFS_ETH_MONITOR

    Scheduled Pinned Locked Moved Solved
    Bug Reports
    3
    5
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sebastian Roth Moderator
      last edited by Sebastian Roth

      As we see in what moses posted (https://forums.fogproject.org/topic/6856/replication-has-stopped-after-ugprade) there seams to be an issue with the interface detection in that script. Testing this on my system I find that NFS_ETH_MONITOR on line 7 in bandwidth.php cannot have the correct value as this whole PHP script is not called from within the FOG framework but as URL (like an external call) from dashboardpage.class.php (line 91).

      So the whole line simply defaults to ‘eth0’ in most cases because ‘NFS_ETH_MONITOR’ is not defined and ‘dev’ is not sent as request parameter either:

      $dev = trim(($_REQUEST['dev'] ? basename(htmlentities($_REQUEST['dev'],ENT_QUOTES,'utf-8')) : (defined('NFS_ETH_MONITOR') ? NFS_ETH_MONITOR : 'eth0')));
      

      As already suggested to Tom I’d vote for a complete rewrite of this PHP file to get rid of executing external tools as well… Proposal coming soon!

      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

      1 Reply Last reply Reply Quote 1
      • S
        Sebastian Roth Moderator
        last edited by

        <?php
        function getInterface() {
            $dev = trim($_REQUEST['dev'] ? basename(htmlentities($_REQUEST['dev'],ENT_QUOTES,'utf-8')) : 'eth0');
            $sys_interfaces = array_diff(scandir('/sys/class/net'), array('..', '.'));
            $interfaces = array();
            foreach ($sys_interfaces as $iface) {
                if (trim(file_get_contents(sprintf('/sys/class/net/%s/operstate', $iface))) === 'up') {
                    array_push($interfaces, $iface);
                }
            }
            $interface = preg_grep("#$dev#",(array)$interfaces);
            $dev = @array_shift($interface);
            if (!empty($dev)) {
                $rx = trim(file_get_contents(sprintf('/sys/class/net/%s/statistics/rx_bytes', $dev)));
                $tx = trim(file_get_contents(sprintf('/sys/class/net/%s/statistics/tx_bytes', $dev)));
                return array('dev' => $dev,'rx' => $rx,'tx' => $tx);
            }
            else {
                return array('dev' => 'unknown', 'rx' => '0', 'tx' => '0');
            }
        }
        header('Content-Type: text/event-stream');
        echo json_encode(getInterface());
        exit;
        

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        Tom ElliottT 1 Reply Last reply Reply Quote 1
        • Wayne WorkmanW
          Wayne Workman
          last edited by Wayne Workman

          /sys/class/net WOW I wish I knew about that directory a long time ago! It appears to be valid for both Ubuntu 15 and Fedora 23 as well!

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
          Daily Clean Installation Results:
          https://fogtesting.fogproject.us/
          FOG Reporting:
          https://fog-external-reporting-results.fogproject.us/

          1 Reply Last reply Reply Quote 0
          • S
            Sebastian Roth Moderator
            last edited by

            @Wayne-Workman said:

            It appears to be valid for both Ubuntu 15 and Fedora 23 as well!

            Absolutely!! You can find it within FOS as well… All the systems that use the linux kernel really!

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            1 Reply Last reply Reply Quote 0
            • Tom ElliottT
              Tom Elliott @Sebastian Roth
              last edited by

              @Sebastian-Roth Pushed as suggested.

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

              Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

              Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              156

              Online

              12.0k

              Users

              17.3k

              Topics

              155.2k

              Posts
              Copyright © 2012-2024 FOG Project