Unlike our regular shell agent, our PHP Server Monitoring Agent cannot automatically detect your server’s network interface name, so this name is set to empty by default.

This setting being empty means that the agent will track the network usage data from all available network interfaces.

However, if you wish to set just one specific network interface to be monitored, the guide below will show you how to view the available network interfaces on your server and how to modify our PHP agent to have the set the interface name.

Step 1: Finding the available network interface names on your server.

  • (a) Create a publicly accessible php file somewhere on your website. Let’s call it “detect_interfaces.php”, and say you put it in the root folder of your website (in the ‘public_html’ folder).
  • (b) Copy/paste the following code into this newly created php file:
    <?php
    // This code will output all the available network interface names on the server
    // Place this file in the public_html folder of your website, and access it via a web browser
    $lines = file('/proc/net/dev');
    echo "Available interfaces:<br>";
    for ($i=2;$i<count($lines);$i++) {
    	$line = explode(':', $lines[$i]);
    	$name = trim($line[0]);
    	if($name !== 'lo') {
    		echo $name."<br>";
    	}
    }
    ?>
    
  • (c) Access the php file from your web browser:

    As you can see from the example screenshot above, there are two interface names on the server, and neither of them is called ‘eth0’, so you’ll have to manually edit the PHP agent file and modify the network interface name accordingly.

Step 2: Modify the PHP Agent file to have the correct network interface name.

  • (a) Locate the PHP Agent file on your server. If you’ve followed our PHP Server Monitor Agent Install Guide, then this file should be located in your home folder (not public_html) in the ‘hetrixtools’ directory:
  • (b) Edit the agent file and modify the network interface name:

Replace eth0 with the actual interface name that you have found at Step 1 Paragraph (c), and then save the agent file. Important: If you’ve found more than one interface name at Step 1 Paragraph (c), try either one of them at first. Considering there’s no way to know right away which one of the network interfaces the public traffic is routed through, it will have to be a trial and error method. Use one network interface name, wait for the data to come in, and if the traffic shown is very low (or non existent), then that interface name is most likely not the one you’re looking for, so use the other interface name which you have found.