centreon-plugins icon indicating copy to clipboard operation
centreon-plugins copied to clipboard

[network::cisco::standard::snmp::plugin] - new mode VTP (VLAN Trunking Port)

Open joschi99 opened this issue 3 years ago • 8 comments

Could you create a new mode to monitor in Cisco switches VTP state? The SNMP mib for VTP is defined in CISCO-VTP-MIB, if you need we can also provide a SNMP walk, further informations about VTP are available here:

  • https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst2960/software/release/12-2_40_se/configuration/guide/scg/swvtp.pdf
  • https://www.cisco.com/c/en/us/support/docs/ip/simple-network-management-protocol-snmp/41003-catalystVLANinfo.html
  1. 1.3.6.1.4.1.9.9.46.1.3.1.1.1 (vtpVlanIndex)

  2. 1.3.6.1.4.1.9.9.46.1.3.1.1.2 (vtpVlanState)

  3. 1.3.6.1.4.1.9.9.46.1.3.1.1.3 (vtpVlanType)

  4. 1.3.6.1.4.1.9.9.46.1.3.1.1.4 (vtpVlanName)

  5. 1.3.6.1.4.1.9.9.46.1.3.1.1.5 (vtpVlanMtu)

  6. 1.3.6.1.4.1.9.9.46.1.3.1.1.6 (vtpVlanDot10Said)

  7. 1.3.6.1.4.1.9.9.46.1.3.1.1.7 (vtpVlanRingNumber)

  8. 1.3.6.1.4.1.9.9.46.1.3.1.1.8 (vtpVlanBridgeNumber)

  9. 1.3.6.1.4.1.9.9.46.1.3.1.1.9 (vtpVlanStpType)

  10. 1.3.6.1.4.1.9.9.46.1.3.1.1.10 (vtpVlanParentVlan)

  11. 1.3.6.1.4.1.9.9.46.1.3.1.1.11 (vtpVlanTranslationalVlan1)

  12. 1.3.6.1.4.1.9.9.46.1.3.1.1.12 (vtpVlanTranslationalVlan2)

  13. 1.3.6.1.4.1.9.9.46.1.3.1.1.13 (vtpVlanBridgeType)

  14. 1.3.6.1.4.1.9.9.46.1.3.1.1.14 (vtpVlanAreHopCount)

  15. 1.3.6.1.4.1.9.9.46.1.3.1.1.15 (vtpVlanSteHopCount)

  16. 1.3.6.1.4.1.9.9.46.1.3.1.1.16 (vtpVlanIsCRFBackup)

  17. 1.3.6.1.4.1.9.9.46.1.3.1.1.17 (vtpVlanTypeExt)

  18. 1.3.6.1.4.1.9.9.46.1.3.1.1.18 (vtpVlanIfIndex)

VLAN State: 1.3.6.1.4.1.9.9.46.1.3.1.1.2

1 = Operational, 2 = Suspended, 3 = mtuTooBigForDevice, 4 = mtuTooBigForTrunk

VLAN Type: 1.3.6.1.4.1.9.9.46.1.3.1.1.3

1 = Ethernet, 2 = FDDI, 3= TokenRing, 4 = FDDI, 5 = rtNet, 6 = Depreciated

joschi99 avatar Sep 15 '21 15:09 joschi99

Could you provide a snmpwalk ?

garnier-quentin avatar Sep 17 '21 12:09 garnier-quentin

Could you test with following mode:

$ centreon_plugins.pl --plugin=apps::protocols::snmp::plugin --mode=collection --hostname=IP  --config=ciscovtp.config --verbose

The config:

{
    "constants": {
        "critical": "1"
    },
    "mapping": {
        "vtpState": {
            "1": "operational",
            "2": "suspended",
            "3": "mtuTooBigForDevice",
            "4": "mtuTooBigForTrunk"
        },
        "vtpType": {
            "1": "ethernet",
            "2": "fddi",
            "3": "tokenRing",
            "4": "fddiNet",
            "5": "trNet",
            "6": "deprecated"
        }
    },
    "snmp": {
        "cache": {
            "enable": false,
            "reload": 5
        },
        "tables": [
            { 
                "name": "vtpVlans", 
                "oid": ".1.3.6.1.4.1.9.9.46.1.3.1.1",
                "used_instance": "\\.(\\d+\\.\\d+)$",
                "entries": [
                    { "name": "state", "oid": ".1.3.6.1.4.1.9.9.46.1.3.1.1.2", "map": "vtpState" },
                    { "name": "type", "oid": ".1.3.6.1.4.1.9.9.46.1.3.1.1.3", "map": "vtpType" },
                    { "name": "name", "oid": ".1.3.6.1.4.1.9.9.46.1.3.1.1.4" }
                ]
            }
        ]
    },
    "selection": [
         {
            "name": "operational",
            "functions": [
                { "type": "count", "src": "%(snmp.tables.vtpVlans)", "filter": "%(src.state) eq %(name)", "save": "%(numVlan)" }
            ],
            "perfdatas": [
                { "nlabel": "vlan.%(name).count", "value": "%(numVlan)", "min": 0 }
            ],
            "formatting": {
                "printf_msg":"number of %s vlan: %s",
                "printf_var":[
                    "%(name)",
                    "%(numVlan)"
                ],
                "display_ok": false
            }
        },
        {
            "name": "suspended",
            "functions": [
                { "type": "count", "src": "%(snmp.tables.vtpVlans)", "filter": "%(src.state) eq %(name)", "save": "%(numVlan)" }
            ],
            "perfdatas": [
                { "nlabel": "vlan.%(name).count", "value": "%(numVlan)", "min": 0 }
            ],
            "formatting": {
                "printf_msg":"number of %s vlan: %s",
                "printf_var":[
                    "%(name)",
                    "%(numVlan)"
                ],
                "display_ok": false
            }
        },
        {
            "name": "mtuTooBigForDevice",
            "functions": [
                { "type": "count", "src": "%(snmp.tables.vtpVlans)", "filter": "%(src.state) eq %(name)", "save": "%(numVlan)" }
            ],
            "perfdatas": [
                { "nlabel": "vlan.%(name).count", "value": "%(numVlan)", "min": 0 }
            ],
            "formatting": {
                "printf_msg":"number of %s vlan: %s",
                "printf_var":[
                    "%(name)",
                    "%(numVlan)"
                ],
                "display_ok": false
            }
        },
        {
            "name": "mtuTooBigForTrunk",
            "functions": [
                { "type": "count", "src": "%(snmp.tables.vtpVlans)", "filter": "%(src.state) eq %(name)", "save": "%(numVlan)" }
            ],
            "perfdatas": [
                { "nlabel": "vlan.%(name).count", "value": "%(numVlan)", "min": 0 }
            ],
            "formatting": {
                "printf_msg":"number of %s vlan: %s",
                "printf_var":[
                    "%(name)",
                    "%(numVlan)"
                ],
                "display_ok": false
            }
        }
    ],
    "selection_loop": [
        {
            "name": "vtp vlan",
            "source": "%(snmp.tables.vtpVlans)",
            "expand_table": {
                "vtpVlan": "%(snmp.tables.vtpVlans.[%(vtpVlans.instance)])"
            },
            "critical": "%(vtpVlan.state) !~ /operational/",
            "formatting": {
                "printf_msg":"vlan %s [type: %s] state is %s",
                "printf_var":[
                    "%(vtpVlan.name)",
                    "%(vtpVlan.type)",
                    "%(vtpVlan.state)"
                ]
            }
        }
    ],
    "formatting":{
        "custom_message_global": "All VLAN trunking protocol are ok",
        "separator": "-"
    }
}

garnier-quentin avatar Sep 24 '21 09:09 garnier-quentin

Hi @garnier-quentin, have done some test:

./apps-protocols-snmp.pl --plugin=apps::protocols::snmp::plugin --mode=collection --hostname=x.x.x.x --snmp-community=public --config=/tmp/ciscovtp.config --verbose
OK: All VLAN trunking protocol are ok |
vlan default [type: ethernet] state is operational
vlan Wireless [type: ethernet] state is operational
vlan Management [type: ethernet] state is operational

Seems working. Do you integrate this in the cisco plugin? It should be possible to have some option for

  • filter vlan
  • threshold-overload ???
  • warning-status, critical-status

joschi99 avatar Sep 24 '21 15:09 joschi99

Please use the last git version. Command example:

$ centreon_plugins.pl --plugin=apps::protocols::snmp::plugin --mode=collection --hostname=IP  --config=ciscovtp.config --verbose --constant='filterVlan=Dummy'  --constant='warningStatus='  --constant='criticalStatus=operational' 
{
    "constants": {
        "criticalStatus": "mtuTooBigForDevice|mtuTooBigForTrunk"
    },
    "mapping": {
        "vtpState": {
            "1": "operational",
            "2": "suspended",
            "3": "mtuTooBigForDevice",
            "4": "mtuTooBigForTrunk"
        },
        "vtpType": {
            "1": "ethernet",
            "2": "fddi",
            "3": "tokenRing",
            "4": "fddiNet",
            "5": "trNet",
            "6": "deprecated"
        }
    },
    "snmp": {
        "cache": {
            "enable": false,
            "reload": 5
        },
        "tables": [
            { 
                "name": "vtpVlans", 
                "oid": ".1.3.6.1.4.1.9.9.46.1.3.1.1",
                "used_instance": "\\.(\\d+\\.\\d+)$",
                "entries": [
                    { "name": "state", "oid": ".1.3.6.1.4.1.9.9.46.1.3.1.1.2", "map": "vtpState" },
                    { "name": "type", "oid": ".1.3.6.1.4.1.9.9.46.1.3.1.1.3", "map": "vtpType" },
                    { "name": "name", "oid": ".1.3.6.1.4.1.9.9.46.1.3.1.1.4" }
                ]
            }
        ]
    },
    "selection": [
         {
            "name": "operational",
            "functions": [
                { "type": "count", "src": "%(snmp.tables.vtpVlans)", "filter": "%(src.state) eq %(name)", "save": "%(numVlan)" }
            ],
            "perfdatas": [
                { "nlabel": "vlan.%(name).count", "value": "%(numVlan)", "min": 0 }
            ],
            "formatting": {
                "printf_msg":"number of %s vlan: %s",
                "printf_var":[
                    "%(name)",
                    "%(numVlan)"
                ],
                "display_ok": false
            }
        },
        {
            "name": "suspended",
            "functions": [
                { "type": "count", "src": "%(snmp.tables.vtpVlans)", "filter": "%(src.state) eq %(name)", "save": "%(numVlan)" }
            ],
            "perfdatas": [
                { "nlabel": "vlan.%(name).count", "value": "%(numVlan)", "min": 0 }
            ],
            "formatting": {
                "printf_msg":"number of %s vlan: %s",
                "printf_var":[
                    "%(name)",
                    "%(numVlan)"
                ],
                "display_ok": false
            }
        },
        {
            "name": "mtuTooBigForDevice",
            "functions": [
                { "type": "count", "src": "%(snmp.tables.vtpVlans)", "filter": "%(src.state) eq %(name)", "save": "%(numVlan)" }
            ],
            "perfdatas": [
                { "nlabel": "vlan.%(name).count", "value": "%(numVlan)", "min": 0 }
            ],
            "formatting": {
                "printf_msg":"number of %s vlan: %s",
                "printf_var":[
                    "%(name)",
                    "%(numVlan)"
                ],
                "display_ok": false
            }
        },
        {
            "name": "mtuTooBigForTrunk",
            "functions": [
                { "type": "count", "src": "%(snmp.tables.vtpVlans)", "filter": "%(src.state) eq %(name)", "save": "%(numVlan)" }
            ],
            "perfdatas": [
                { "nlabel": "vlan.%(name).count", "value": "%(numVlan)", "min": 0 }
            ],
            "formatting": {
                "printf_msg":"number of %s vlan: %s",
                "printf_var":[
                    "%(name)",
                    "%(numVlan)"
                ],
                "display_ok": false
            }
        }
    ],
    "selection_loop": [
        {
            "name": "vtp vlan",
            "source": "%(snmp.tables.vtpVlans)",
            "expand_table": {
                "vtpVlan": "%(snmp.tables.vtpVlans.[%(vtpVlans.instance)])"
            },
            "filter": "!defined(%(constants.filterVlan)) or %(constants.filterVlan) eq '' or %(vtpVlan.name) =~ /%(constants.filterVlan)/",
            "warning": "defined(%(constants.warningStatus)) and %(constants.warningStatus) ne '' and %(vtpVlan.state) =~ /%(constants.warningStatus)/",
            "critical": "defined(%(constants.criticalStatus)) and %(constants.criticalStatus) ne '' and %(vtpVlan.state) =~ /%(constants.criticalStatus)/",
            "formatting": {
                "printf_msg":"vlan %s [type: %s] state is %s",
                "printf_var":[
                    "%(vtpVlan.name)",
                    "%(vtpVlan.type)",
                    "%(vtpVlan.state)"
                ]
            }
        }
    ],
    "formatting":{
        "custom_message_global": "All VLAN trunking protocol are ok",
        "separator": "-"
    }
}

garnier-quentin avatar Sep 27 '21 12:09 garnier-quentin

Hi @garnier-quentin, works like a charm :-)

Do you plan to integrate this into the cisco standard plugin?

joschi99 avatar Oct 04 '21 14:10 joschi99

With that json, you have a quick way to integrate. Maybe we could do in a mode with Perl (because it's quite the same number of lines).

garnier-quentin avatar Oct 04 '21 14:10 garnier-quentin

For a quick integration it's perfect

joschi99 avatar Oct 06 '21 20:10 joschi99

Hi @garnier-quentin, monitoring VTP with this extension should work. Could you add this feature as a new mode in the plugin?

joschi99 avatar Sep 09 '22 04:09 joschi99