Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary warnings appear when host name is not resolved #4267

Closed
xmacan opened this issue May 17, 2021 · 4 comments
Closed

Unnecessary warnings appear when host name is not resolved #4267

xmacan opened this issue May 17, 2021 · 4 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@xmacan
Copy link
Member

xmacan commented May 17, 2021

In console -> devices -> device -> I got warning (in section SNMP Information):
Warning: SNMP::__construct(): php_network_getaddresses: getaddrinfo failed: Name does not resolve in /usr/local/share/cacti/lib/snmp.php on line 75
System SNMP error - SNMP::get(): Could not open snmp connection: Unknown host (mail.wrong-name.xz) (Invalid argument)

It is happen in the case:

  1. wrong hostname
  2. PHP SNMP enabled

Without PHP SNMP, I got correctly- Host SNMP error

I guess that the error message should be the same.

Cacti 1.2.17, FreeBSD 12.1, PHP 7.4.8

@xmacan xmacan added bug Undesired behaviour unverified Some days we don't have a clue labels May 17, 2021
@netniV
Copy link
Member

netniV commented May 17, 2021

Let me know if this works for you....

--- a/lib/snmp.php
+++ b/lib/snmp.php
@@ -72,7 +72,7 @@ function cacti_snmp_session($hostname, $community, $version, $auth_user = '', $a
        $timeout_us = (int) ($timeout_ms * 1000);

        try {
-               $session = new SNMP($version, $hostname . ':' . $port, ($version == 3 ? $auth_user : $community), $timeout_us, $retries);
+               $session = @new SNMP($version, $hostname . ':' . $port, ($version == 3 ? $auth_user : $community), $timeout_us, $retries);
        } catch (Exception $e) {
                return false;
        }

@xmacan
Copy link
Member Author

xmacan commented May 18, 2021

better, now I see only:
SNMP Information
System SNMP error - SNMP::get(): Could not open snmp connection: Unknown host (mail.wrong-name.xz) (Invalid argument)

@netniV
Copy link
Member

netniV commented May 18, 2021

Is that good enough or should we work on it more?

@xmacan
Copy link
Member Author

xmacan commented May 19, 2021

I guess that it is enough. PHP warning is gone and message Could not open snmp connection: Unknown host is sufficient

@netniV netniV changed the title PHP warning for wrong specified hostname SNMP library can display extra warning messages when host does not resolve May 19, 2021
@netniV netniV added confirmed Bug is confirm by dev team and removed unverified Some days we don't have a clue labels May 19, 2021
@netniV netniV added this to the 1.2.18 milestone May 19, 2021
@netniV netniV added the resolved A fixed issue label May 19, 2021
@netniV netniV closed this as completed May 19, 2021
@netniV netniV removed the confirmed Bug is confirm by dev team label Jun 9, 2021
@netniV netniV changed the title SNMP library can display extra warning messages when host does not resolve Unnecessary warnings appear when host name is not resolved Jul 4, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants