snmp query VALUE/REGEXP issue help required

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
annapatil
Posts: 35
Joined: Wed Oct 13, 2010 3:22 am

snmp query VALUE/REGEXP issue help required

Post by annapatil »

Hi All,

I am polling LDP sessions details through below snmp data query, want to capture IP Address from VALUE/REGEXP (direction is kept input for testing purpose)


OID/REGEXP giving below output for LdpLocalIP and LdpRemoteIP

10.117.224.21.0.0.4294901761.10.117.226.15

required first 4 octates ( 10.117.224.21 ) as LdpLocalIP and last 4 octates as LdpRemoteIP (10.117.226.15)


Code: Select all

<query>
        <name>Huawei MPLS LDP Sessions</name>
        <oid_index>.1.3.6.1.2.1.10.166.4.1.3.3.1.1</oid_index>
        <oid_index_parse>OID/REGEXP:.*\.([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$</oid_index_parse>
        <fields>
                <StateLastChange>
                        <name>LastChange</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.2.1.10.166.4.1.3.3.1.1</oid>
                </StateLastChange>
                <LdpSessionRole>
                        <name>SessionRole</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.2.1.10.166.4.1.3.3.1.3</oid>
                </LdpSessionRole>
                <LdpLocalIP>
                       <name>SessionLocal</name>
                       <method>walk</method>
                       <source>OID/REGEXP:.1.3.6.1.2.1.10.166.4.1.3.3.1.3.(.*)\.0.0$</source>
                       <!--<source>VALUE/REGEXP:^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}</source> -->
                       <source>VALUE/REGEXP:^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})</source>
                       <!--<source>VALUE/REGEXP:^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})*$</source> -->
                       <!--<source>OID/REGEXP:^\.?1\.3\.6\.1\.2\.1\.4\.20\.1\.2\.([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*</source> -->
                       <direction>input</direction>
                       <oid>.1.3.6.1.2.1.10.166.4.1.3.3.1.3</oid>
                </LdpLocalIP>
                <LdpRemoteIP>
                       <name>SessionRemote</name>
                       <method>walk</method>
                       <source>OID/REGEXP:.1.3.6.1.2.1.10.166.4.1.3.3.1.3.(.*)\.0.0$</source>
                       <source>VALUE/REGEXP:([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$</source>
                       <direction>input</direction>
                       <oid>.1.3.6.1.2.1.10.166.4.1.3.3.1.3</oid>
                </LdpRemoteIP>
                <LdpSessionState>
                        <name>SessionState</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.2.1.10.166.4.1.3.3.1.2</oid>
                </LdpSessionState>
        </fields>
</query>

Verbose query output is not as per expectation
Total: 0.270000, Delta: 0.000000, Located input field 'LdpLocalIP' [walk]
Total: 0.330000, Delta: 0.050000, Executing SNMP walk for data @ '.1.3.6.1.2.1.10.166.4.1.3.3.1.3'
Found item [LdpLocalIP='3 (3)'] index: 0.151.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 224.22.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 226.15.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 0.152.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 0.113.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 0.153.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 1.103.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 0.154.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 0.160.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 1.84.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 0.161.0.0 [from regexp value parse]
Found item [LdpLocalIP='2 (2)'] index: 224.13.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 0.114.0.0 [from regexp value parse]
Found item [LdpLocalIP='3 (3)'] index: 0.88.0.0 [from regexp value parse]
and for LdpRemoteIP
Total: 0.330000, Delta: 0.000000, Located input field 'LdpRemoteIP' [walk]
Total: 0.380000, Delta: 0.050000, Executing SNMP walk for data @ '.1.3.6.1.2.1.10.166.4.1.3.3.1.3'
Found item [LdpRemoteIP='3 (3)'] index: 0.151.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 224.22.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 226.15.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 0.152.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 0.113.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 0.153.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 1.103.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 0.154.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 0.160.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 1.84.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 0.161.0.0 [from regexp value parse]
Found item [LdpRemoteIP='2 (2)'] index: 224.13.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 0.114.0.0 [from regexp value parse]
Found item [LdpRemoteIP='3 (3)'] index: 0.88.0.0 [from regexp value parse]

Cacti: 1.2.11
Redhat: 7
PHP: 7
rvk
Posts: 10
Joined: Mon Feb 24, 2020 11:48 am

Re: snmp query VALUE/REGEXP issue help required

Post by rvk »

This is not gonna help you much, but i had trouble creating a regex for my xml too, but i just kept trying until it worked. I started with something very simple and incrementally tweaked it to get what i was looking for. I have a post in this forum too, take a look at that, maybe it will help you.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests