mtr not showing #19

Closed
opened 2023-04-27 10:29:35 +08:00 by robetus · 13 comments
robetus commented 2023-04-27 10:29:35 +08:00 (Migrated from github.com)

Traceroute and ping work normally and I've done an mtr command in the terminal but there is no output in the looking glass, all I get is:
Host Loss% Snt Last Avg Best Wrst StDev
Any ideas on what I can check for?

Traceroute and ping work normally and I've done an mtr command in the terminal but there is no output in the looking glass, all I get is: `Host Loss% Snt Last Avg Best Wrst StDev` Any ideas on what I can check for?
dqos commented 2023-04-29 02:53:45 +08:00 (Migrated from github.com)

Please follow the instructions exactly like described and it will work. SELinux is notoriously known to break things, might check that out as well.

Please follow the instructions *exactly* like described and it will work. SELinux is notoriously known to break things, might check that out as well.
robetus commented 2023-04-29 06:29:38 +08:00 (Migrated from github.com)

I'm on Ubuntu 22.04, php 8.1 fpm (tried 8.0 also) made sure the two mtr sym links were there and they are. Selinux is not enabled in any way. All the necessary packages have been installed. No errors given or shown, everything working but mtr. I don't know what it could be, nothing shows in the logs either. When I set this though:

// Enable the latency check feature;
const LG_CHECK_LATENCY = true;

I get a 500 error, does that need to be set to true for mtr to work?

Wanted to add that all the required php extensions have been installed and verified as well. If you want to check out the LG: https://glass.servrs.com/

I'm on Ubuntu 22.04, php 8.1 fpm (tried 8.0 also) made sure the two mtr sym links were there and they are. Selinux is not enabled in any way. All the necessary packages have been installed. No errors given or shown, everything working but mtr. I don't know what it could be, nothing shows in the logs either. When I set this though: ``` // Enable the latency check feature; const LG_CHECK_LATENCY = true; ``` I get a 500 error, does that need to be set to true for mtr to work? Wanted to add that all the required php extensions have been installed and verified as well. If you want to check out the LG: https://glass.servrs.com/
dqos commented 2023-04-29 23:36:24 +08:00 (Migrated from github.com)

Are you using our Dockerfile? Or perhaps Nginx?

The latency feature is optional and not working for you it seems, you can see in PHP logs why.

Are you using our Dockerfile? Or perhaps Nginx? The latency feature is optional and not working for you it seems, you can see in PHP logs why.
robetus commented 2023-04-30 08:58:04 +08:00 (Migrated from github.com)

I'm using apache2 php FPM 8.1.

Here is the error for the latency issue:
Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, null given in /var/www/clients/client/web/web/LookingGlass.php:435 Stack trace: #0 /var/www/clients/client/web/web/LookingGlass.php(435): explode() #1 /var/www/clients/client/web/web/LookingGlass.php(414): Hybula\LookingGlass::getLatencyFromSs() #2 /var/www/clients/client/web/web/index.php(87): Hybula\LookingGlass::getLatency() #3 {main} thrown in /var/www/clients/client/web/web/LookingGlass.php on line 435

Do I need to add specific apache2 configurations to get mtr to work. I did some searching but couldn't find anything specific for apache.

I'm using apache2 php FPM 8.1. Here is the error for the latency issue: `Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, null given in /var/www/clients/client/web/web/LookingGlass.php:435 Stack trace: #0 /var/www/clients/client/web/web/LookingGlass.php(435): explode() #1 /var/www/clients/client/web/web/LookingGlass.php(414): Hybula\LookingGlass::getLatencyFromSs() #2 /var/www/clients/client/web/web/index.php(87): Hybula\LookingGlass::getLatency() #3 {main} thrown in /var/www/clients/client/web/web/LookingGlass.php on line 435` Do I need to add specific apache2 configurations to get mtr to work. I did some searching but couldn't find anything specific for apache.
dqos commented 2023-05-01 01:00:19 +08:00 (Migrated from github.com)

I am not sure why it's not working for you. It should be working out of the box for RHEL based distros. Else use Docker deployment.

The latency feature is in beta, I will see if we can fix this.

I am not sure why it's not working for you. It should be working out of the box for RHEL based distros. Else use Docker deployment. The latency feature is in beta, I will see if we can fix this.
robetus commented 2023-05-01 18:30:29 +08:00 (Migrated from github.com)

I reinstalled it on an Almalinux 9 VM and now it works perfectly. Thank you for your assistance and repo, I appreciate it.

I reinstalled it on an Almalinux 9 VM and now it works perfectly. Thank you for your assistance and repo, I appreciate it.
dqos commented 2023-05-02 00:08:54 +08:00 (Migrated from github.com)

Does the latency feature work now on Alma?

Does the latency feature work now on Alma?
robetus commented 2023-05-02 06:38:46 +08:00 (Migrated from github.com)

I did enable latency and it is working I see it next to "Your IP", thanks again.

I did enable latency and it is working I see it next to "Your IP", thanks again.
meatlayer commented 2023-06-23 23:01:21 +08:00 (Migrated from github.com)

If the latency time is not displayed

For debian/ubuntu, this error is solved by replacing the string:

9909035c50/LookingGlass.php (L431)

replace to:

$lines = shell_exec('/usr/bin/ss -Hti state established');

If the latency time is not displayed For debian/ubuntu, this error is solved by replacing the string: https://github.com/hybula/lookingglass/blob/9909035c5066458ed1a8f10c7aacbbfeb006e8e7/LookingGlass.php#L431 replace to: `$lines = shell_exec('/usr/bin/ss -Hti state established');`
robetus commented 2023-07-04 05:16:38 +08:00 (Migrated from github.com)

If the latency time is not displayed

For debian/ubuntu, this error is solved by replacing the string:

9909035c50/LookingGlass.php (L431)

replace to:

$lines = shell_exec('/usr/bin/ss -Hti state established');

Thank you for that!

> If the latency time is not displayed > > For debian/ubuntu, this error is solved by replacing the string: > > https://github.com/hybula/lookingglass/blob/9909035c5066458ed1a8f10c7aacbbfeb006e8e7/LookingGlass.php#L431 > > replace to: > > `$lines = shell_exec('/usr/bin/ss -Hti state established');` Thank you for that!
meatlayer commented 2023-07-04 05:26:49 +08:00 (Migrated from github.com)

By the way, I noticed that latency time is displayed only for ipv4. If you need it to be displayed for ipv4+ipv6, you can modify the getLatencyFromSs function in the file LookingGlass.php

    private static function getLatencyFromSs(string $ip): array
    {
        $lines = shell_exec('/usr/bin/ss -Hti state established');
        $ss = [];
        $i = 0;
        $j = 0;
        foreach (explode(PHP_EOL, $lines) as $line) {
            if ($i > 1) {
                $i = 0;
                $j++;
            }
            if ($line !== '') {
                @$ss[$j] .= $line;
                $i++;
            }
        }
        $output = [];
        foreach ($ss as $socket) 
		{
            $socket = preg_replace('!\s+!', ' ', $socket);
            $explodedsocket = explode(' ', $socket);
            $temp = [];

            if (strpos($explodedsocket[3], ']') !== false) {
                // IPv6 address
                preg_match('/\[(.*?)\]/', $explodedsocket[2], $temp);
                $sock['local'] = $temp[1];
                preg_match('/\[(.*?)\]/', $explodedsocket[3], $temp);
                $sock['remote'] = $temp[1];
            } else {
                // IPv4 address
                preg_match('/(\d+\.\d+\.\d+\.\d+)(:\d+)?/', $explodedsocket[2], $temp);
                $sock['local'] = $temp[1];
                preg_match('/(\d+\.\d+\.\d+\.\d+)(:\d+)?/', $explodedsocket[3], $temp);
                $sock['remote'] = $temp[1];


            }

            preg_match('/segs_out:(\d+)/', $socket, $temp);
            $sock['segs_out'] = $temp[1];
            preg_match('/segs_in:(\d+)/', $socket, $temp);
            $sock['segs_in'] = $temp[1];
            preg_match_all('/rtt:(\d+\.\d+)\/(\d+\.\d+)/', $socket, $temp);
            $sock['latency'] = $temp[1][0];
            $sock['jitter'] = $temp[2][0];
            preg_match_all('/retrans:\d+\/(\d+)/', $socket, $temp);
            $sock['retransmissions'] = (isset($temp[1][0]) ? $temp[1][0] : 0);
            if ($sock['remote'] == $ip || $sock['local'] == $ip) {
                $output[] = $sock;
				}
			}
        return $output;
		}
	}
By the way, I noticed that latency time is displayed only for ipv4. If you need it to be displayed for ipv4+ipv6, you can modify the getLatencyFromSs function in the file LookingGlass.php ``` private static function getLatencyFromSs(string $ip): array { $lines = shell_exec('/usr/bin/ss -Hti state established'); $ss = []; $i = 0; $j = 0; foreach (explode(PHP_EOL, $lines) as $line) { if ($i > 1) { $i = 0; $j++; } if ($line !== '') { @$ss[$j] .= $line; $i++; } } $output = []; foreach ($ss as $socket) { $socket = preg_replace('!\s+!', ' ', $socket); $explodedsocket = explode(' ', $socket); $temp = []; if (strpos($explodedsocket[3], ']') !== false) { // IPv6 address preg_match('/\[(.*?)\]/', $explodedsocket[2], $temp); $sock['local'] = $temp[1]; preg_match('/\[(.*?)\]/', $explodedsocket[3], $temp); $sock['remote'] = $temp[1]; } else { // IPv4 address preg_match('/(\d+\.\d+\.\d+\.\d+)(:\d+)?/', $explodedsocket[2], $temp); $sock['local'] = $temp[1]; preg_match('/(\d+\.\d+\.\d+\.\d+)(:\d+)?/', $explodedsocket[3], $temp); $sock['remote'] = $temp[1]; } preg_match('/segs_out:(\d+)/', $socket, $temp); $sock['segs_out'] = $temp[1]; preg_match('/segs_in:(\d+)/', $socket, $temp); $sock['segs_in'] = $temp[1]; preg_match_all('/rtt:(\d+\.\d+)\/(\d+\.\d+)/', $socket, $temp); $sock['latency'] = $temp[1][0]; $sock['jitter'] = $temp[2][0]; preg_match_all('/retrans:\d+\/(\d+)/', $socket, $temp); $sock['retransmissions'] = (isset($temp[1][0]) ? $temp[1][0] : 0); if ($sock['remote'] == $ip || $sock['local'] == $ip) { $output[] = $sock; } } return $output; } } ```
robetus commented 2023-07-04 05:27:48 +08:00 (Migrated from github.com)

Can you do a pull request for this? I'm sure it will be added and would be really nice.

Can you do a pull request for this? I'm sure it will be added and would be really nice.
meatlayer commented 2023-07-04 05:37:18 +08:00 (Migrated from github.com)

Can you do a pull request for this? I'm sure it will be added and would be really nice.

Sorry, but I haven't tested the code in other OS, such as RHELs (Centos/AlmaLinux/Rocky and etc). And since the output of the information display mainly depends on the ss utility, depending on the OS, there is a chance that code will not work there. Therefore, I don't see the point in sending a Pull Request.

I also noticed that MTR/Traceroute will only work correctly in an Nginx+Apache environment, because Chunked headers are used to display information in real time. If you use Nginx+php-fpm, the information from MTR/Traceroute may not be displayed correctly.

> Can you do a pull request for this? I'm sure it will be added and would be really nice. Sorry, but I haven't tested the code in other OS, such as RHELs (Centos/AlmaLinux/Rocky and etc). And since the output of the information display mainly depends on the ss utility, depending on the OS, there is a chance that code will not work there. Therefore, I don't see the point in sending a Pull Request. I also noticed that MTR/Traceroute will only work correctly in an Nginx+Apache environment, because Chunked headers are used to display information in real time. If you use Nginx+php-fpm, the information from MTR/Traceroute may not be displayed correctly.
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: malhuda/lookingglass#19
No description provided.