centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 275 forks source link

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

Closed joschi99 closed 4 months ago

joschi99 commented 3 years ago

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:

  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

garnier-quentin commented 3 years ago

Could you provide a snmpwalk ?

garnier-quentin commented 3 years ago

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": "-"
    }
}
joschi99 commented 3 years ago

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

garnier-quentin commented 3 years ago

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": "-"
    }
}
joschi99 commented 3 years ago

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

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

garnier-quentin commented 3 years ago

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).

joschi99 commented 3 years ago

For a quick integration it's perfect

joschi99 commented 2 years ago

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

lucie-dubrunfaut commented 4 months ago

Hello :)

This enhancement request seems particularly old so let me close it. If the enhancement request is still current, please address it here to be take into account and vote on. Thank you for your understanding.