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

Some interface aliases do not appear correctly #5554

Closed
Linegod opened this issue Nov 6, 2023 · 23 comments
Closed

Some interface aliases do not appear correctly #5554

Linegod opened this issue Nov 6, 2023 · 23 comments
Labels
bug Undesired behaviour confirmed Bug is confirm by dev team resolved A fixed issue
Milestone

Comments

@Linegod
Copy link
Member

Linegod commented Nov 6, 2023

Describe the bug

Network device interface description with equal sign (=) in ifAlias does not show Alias

To Reproduce

Steps to reproduce the behavior:

  1. Configure a device interface with a description that contains =
    ie:
    interface TenGigE0/0/0/1
    description Job Id# = 55555 (Circuit #555555555555)
    service-policy ...
    ....
  2. Scan the interfaces on the device
  3. Alias will not populate
  4. Remove Job Id# =
    ie:
    interface TenGigE0/0/0/1
    description 55555 (Circuit #555555555555)
    service-policy....
  5. Rescan, and Alias appears as expected

Expected behavior

Alias should be populated with Job Id# = 55555 (Circuit #555555555555)

Additional context

Cacti version 1.2.21

@Linegod Linegod added bug Undesired behaviour unverified Some days we don't have a clue labels Nov 6, 2023
@TheWitness TheWitness added this to the 1.2.26 milestone Nov 6, 2023
@TheWitness TheWitness added confirmed Bug is confirm by dev team and removed unverified Some days we don't have a clue labels Nov 6, 2023
TheWitness added a commit that referenced this issue Nov 6, 2023
TheWitness added a commit that referenced this issue Nov 6, 2023
@TheWitness TheWitness added the resolved A fixed issue label Nov 6, 2023
@TheWitness
Copy link
Member

@Linegod, should be fixed now. Please test.

@Linegod
Copy link
Member Author

Linegod commented Nov 6, 2023

Applied changes - made no difference.

Same results.

@TheWitness
Copy link
Member

@Linegod, are you using php-snmp? What version of PHP?

@TheWitness
Copy link
Member

TheWitness commented Nov 7, 2023

I tested on ifDescr and it seems to work perfectly. Are there other special characters in the output. I'm using:

  • PHP 8.2.12
  • NetSNMP 5.7.2
  • php-snmp is also included

Testing without php-snmp now...

@TheWitness
Copy link
Member

Same outcome with or without php-snmp @Linegod

@Linegod
Copy link
Member Author

Linegod commented Nov 7, 2023

php 5.4.16 in production

I'll spin up a new instance tomorrow using the full develop branch to validate, then one on php 7.4.33

@TheWitness
Copy link
Member

Wow, pretty old stuff. 1.2.26 will be a solid release too. I'm using remi PHP 8.2 repos for just about everything these days. PHP 7 is already beyond EOL too.

@Linegod
Copy link
Member Author

Linegod commented Nov 7, 2023

Pulled dev branch, using php-8.0.30, without php-snmp

Still doesn't work

snmpset -v2c -cxxxxxxxxxx localhost IF-MIB::ifAlias.2 s 'Job Id# = 15 (that thing)'

Click to show Data Query output for field 'ifName'
Total: 0.110000, Delta: 0.000000, Located input field 'ifName' [walk]
Total: 0.120000, Delta: 0.010000, Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.1'
Found item [ifName='lo'] index: 1 [from value]
Found item [ifName='ens192'] index: 2 [from value]
Click to show Data Query output for field 'ifAlias'
Total: 0.120000, Delta: 0.000000, Located input field 'ifAlias' [walk]
Total: 0.140000, Delta: 0.020000, Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.18'
Found item [ifAlias=''] index: 1 [from value]

snmpset -v2c -cxxxxxxxx localhost IF-MIB::ifAlias.2 s 'Job Id# 15 (that thing)'

Click to show Data Query output for field 'ifName'
Total: 0.110000, Delta: 0.000000, Located input field 'ifName' [walk]
Total: 0.120000, Delta: 0.010000, Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.1'
Found item [ifName='lo'] index: 1 [from value]
Found item [ifName='ens192'] index: 2 [from value]
Click to show Data Query output for field 'ifAlias'
Total: 0.120000, Delta: 0.000000, Located input field 'ifAlias' [walk]
Total: 0.140000, Delta: 0.010000, Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.18'
Found item [ifAlias=''] index: 1 [from value]
Found item [ifAlias='Job Id# 15 (that thing)'] index: 2 [from value]

@Linegod
Copy link
Member Author

Linegod commented Nov 7, 2023

If I escape it:

snmpset -v2c -cxxxxxxx localhost IF-MIB::ifAlias.2 s 'Job Id# = 15 (that thing)'

Total: 0.120000, Delta: 0.000000, Located input field 'ifAlias' [walk]
Total: 0.130000, Delta: 0.010000, Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.18'
Found item [ifAlias=''] index: 1 [from value]
Found item [ifAlias='Job Id# = 15 (that thing)'] index: 2 [from value]

Then it returns - but in production 'Job Id# =' is set by the automation system, and there doesn't appear to be a way to adjust it.

@TheWitness
Copy link
Member

Okay, at least I have more to go on now. Away at conference till Friday.

@TheWitness
Copy link
Member

TheWitness commented Nov 16, 2023

@Linegod, can you post the output of the unescaped raw SNMPGET output? Use these options:

snmpget -O fntevU -c community -V2c hostname oid

@TheWitness
Copy link
Member

Also:

snmpwalk -O QnU -c community -v2c hostname oidbase

@Linegod
Copy link
Member Author

Linegod commented Nov 20, 2023

snmpget -O fntevU -v2c -cxxxxxxxxx localhost .1.3.6.1.2.1.31.1.1.1.18.2
STRING: Job Id# = 15 (that thing)

snmpwalk -O QnU -v2c -cxxxxxxx localhost .1.3.6.1.2.1.31.1.1.1.18
.1.3.6.1.2.1.31.1.1.1.18.1 =
.1.3.6.1.2.1.31.1.1.1.18.2 = Job Id# = 15 (that thing)

@TheWitness
Copy link
Member

Okay, I've written the following test script. If you can run it, that would be good.

<?php

include('./include/cli_check.php');
include_once('./lib/snmp.php');

$host      = '192.168.11.1'; // MicroTik Router
$community = 'public'; // lol
$version   = '2'; // yup, still popular
$oid       = '.1.3.6.1.2.1.2.2.1.2'; // ifDescr

$output = cacti_snmp_walk(
        $host,
        $community,
        $oid,
        $version
);

print_r($output);

On my system with the funky ifDescription, I'm getting this...

[root@vmhost5 cacti]# php -q test.php
Array
(
    [0] => Array
        (
            [oid] => .1.3.6.1.2.1.2.2.1.2.1
            [value] => wlan1
        )

    [1] => Array
        (
            [oid] => .1.3.6.1.2.1.2.2.1.2.2
            [value] => wlan2
        )

    [2] => Array
        (
            [oid] => .1.3.6.1.2.1.2.2.1.2.3 = Job Id#
            [value] => Job Id# = 15 (that thing)
        )
<snip>

@Linegod
Copy link
Member Author

Linegod commented Nov 21, 2023

[root@lab scripts]# php -q test.php 
Array
(
    [0] => Array
        (
            [oid] => .1.3.6.1.2.1.2.2.1.2.1
            [value] => lo
        )

    [1] => Array
        (
            [oid] => .1.3.6.1.2.1.2.2.1.2.2
            [value] => ens192
        )

)

It doesn't output the interface description even if I change it.

I may have to test against another host.

@Linegod
Copy link
Member Author

Linegod commented Nov 21, 2023

Wait, I adjusted for for the ifAlias - the 'description' setting on an alias appears in ifAlias, not ifDescr

[root@slt-readm-001 scripts]# php -q test.php 
Array
(
    [0] => Array
        (
            [oid] => .1.3.6.1.2.1.31.1.1.1.18.1
            [value] => 
        )

    [1] => Array
        (
            [oid] => .1.3.6.1.2.1.31.1.1.1.18.2 = Job Id#
            [value] => Job Id# = 15 (that thing)
        )

)

So the weird part of the output is:

[oid] => .1.3.6.1.2.1.31.1.1.1.18.2 = Job Id#

The oid is being mucked up.

If I remove the equal sign:

Array
(
    [0] => Array
        (
            [oid] => .1.3.6.1.2.1.31.1.1.1.18.1
            [value] => lo
        )

    [1] => Array
        (
            [oid] => .1.3.6.1.2.1.31.1.1.1.18.2
            [value] => Job Id# 15 (that thing)
        )

)

There is no longer the extra ' = Job Id#' in the oid array

@TheWitness
Copy link
Member

Okay, so far so good. I'll keep digging.

@TheWitness
Copy link
Member

Can you confirm that the ifAlias in the interface.xml file matches this?

        <ifAlias>
            <name>Alias (IF-MIB)</name>
            <method>walk</method>
            <output_format>ascii</output_format>
            <source>value</source>
            <direction>input</direction>
            <oid>.1.3.6.1.2.1.31.1.1.1.18</oid>
        </ifAlias>

@TheWitness
Copy link
Member

Here is a light modification @Linegod

<?php

include('./include/cli_check.php');
include_once('./lib/snmp.php');
include_once('./lib/data_query.php');

$host      = '192.168.11.1'; // MicroTik Router
$community = 'public'; // lol
$version   = '2'; // yup, still popular
$oid       = '.1.3.6.1.2.1.2.2.1.2'; // ifDescr

$output = cacti_snmp_walk(
        $host,
        $community,
        $oid,
        $version,
        '',
        '',
        '',
        '',
        '',
        '',
        161,
        200,
        1,
        20,
        SNMP_POLLER,
        '',
        SNMP_STRING_OUTPUT_ASCII
);

$output = array_rekey($output, 'oid', 'value');

print_r($output);

@xmacan
Copy link
Member

xmacan commented Nov 22, 2023

data_query.php line 1262, here we lost data:
if (!preg_match($index_regex, $oid)) {
continue;
}

TheWitness added a commit that referenced this issue Nov 22, 2023
This is tricky, and still breaks down if the second line has an equal sign.  For example:

.1.3.2.4 = Some Text\n
Some More Text = Stuff\n
This is a real long line.
.1.3.2.5 = Some numeric value

So, it's not perfect.
TheWitness added a commit that referenced this issue Nov 22, 2023
This is tricky, and still breaks down if the second line has an equal sign.  For example:

.1.3.2.4 = Some Text\n
Some More Text = Stuff\n
This is a real long line.
.1.3.2.5 = Some numeric value

So, it's not perfect.
@Linegod
Copy link
Member Author

Linegod commented Nov 22, 2023

@TheWitness - That works

Before and after from updated test.php:

Before

# php -q test.php 
Array
(
    [.1.3.6.1.2.1.31.1.1.1.18.1] => lo
    [.1.3.6.1.2.1.31.1.1.1.18.2 = Job Id#] => Job Id# = 15 (that thing)
)

After

# php -q test.php 
Array
(
    [.1.3.6.1.2.1.31.1.1.1.18.1] => lo
    [.1.3.6.1.2.1.31.1.1.1.18.2] => Job Id# = 15 (that thing)
)

Output of Cacti Verbose:

Click to show Data Query output for field 'ifDescr'
Total: 0.080000, Delta: 0.000000, Located input field 'ifDescr' [walk]
Total: 0.100000, Delta: 0.010000, Executing SNMP walk for data @ '.1.3.6.1.2.1.2.2.1.2'
Found item [ifDescr='lo'] index: 1 [from value]
Found item [ifDescr='ens192'] index: 2 [from value]

Click to show Data Query output for field 'ifAlias'
Total: 0.110000, Delta: 0.000000, Located input field 'ifAlias' [walk]
Total: 0.130000, Delta: 0.010000, Executing SNMP walk for data @ '.1.3.6.1.2.1.31.1.1.1.18'
Found item [ifAlias='lo'] index: 1 [from value]
Found item [ifAlias='Job Id# = 15 (that thing)'] index: 2 [from value]

@TheWitness
Copy link
Member

@Linegod, close if you are satisfied.

@Linegod
Copy link
Member Author

Linegod commented Nov 22, 2023

Closing as completed

@Linegod Linegod closed this as completed Nov 22, 2023
@netniV netniV changed the title Interface description with equal sign (=) in ifAlias does not show Alias Some interface aliases do not appear correctly Dec 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour confirmed Bug is confirm by dev team resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

3 participants