event-action-python-aos-r8
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| event-action-python-aos-r8 [2020/09/09 07:26] – angelegt benny | event-action-python-aos-r8 [2024/06/09 10:29] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
|---|---|---|---|
| Zeile 10: | Zeile 10: | ||
| / | / | ||
| </ | </ | ||
| - | In diesem Verzeichnis liegen bereits zwei Skripte **default_broker_vso.py** und **iec_config.py**. | + | In diesem Verzeichnis liegen bereits zwei Skripte **default_broker_vso.py** und **iec_config.py**, diese sollte man nicht ändern/ |
| ==== Welche Python Skripte werden bei welchen Traps ausgeführt? | ==== Welche Python Skripte werden bei welchen Traps ausgeführt? | ||
| Zeile 23: | Zeile 23: | ||
| </ | </ | ||
| - | ==== Ein einfaches Beispiel als Codegerüst: chassis_trap.py | + | ==== Tipp: " |
| - | In diesem Beispiel nehmen | + | Zumindest während der Entwicklung empfehlen |
| < | < | ||
| Switch-> snmp-trap absorption disable | Switch-> snmp-trap absorption disable | ||
| + | Switch-> show snmp-trap config | ||
| + | Absorption service : disabled | ||
| + | Traps to WebView : enabled | ||
| + | |||
| + | id trap name family | ||
| + | --+------------------------------------+---------------+------------+------------- | ||
| + | 0 coldStart | ||
| + | 1 warmStart | ||
| + | 2 linkDown | ||
| + | 3 linkUp | ||
| + | 4 authenticationFailure | ||
| + | 5 entConfigChange | ||
| + | 6 policyEventNotification | ||
| + | 7 chassisTrapsStr | ||
| + | 8 chassisTrapsAlert | ||
| + | 9 chassisTrapsStateChange | ||
| + | 10 chassisTrapsMacOverlap | ||
| + | 11 vrrpTrapNewMaster | ||
| + | 12 vrrpTrapAuthFailure | ||
| + | 13 healthMonModuleTrap | ||
| + | 14 healthMonPortTrap | ||
| + | 15 healthMonCmmTrap | ||
| + | 16 bgpEstablished | ||
| + | 17 bgpBackwardTransition | ||
| + | 18 esmDrvTrapDropsLink | ||
| + | 19 portViolationTrap | ||
| + | 20 dvmrpNeighborLoss | ||
| + | 21 dvmrpNeighborNotPruning | ||
| + | 22 risingAlarm | ||
| + | 23 fallingAlarm | ||
| + | 24 stpNewRoot | ||
| + | 25 stpRootPortChange | ||
| + | 26 mirrorConfigError | ||
| + | 27 mirrorUnlikeNi | ||
| + | 28 slbTrapOperStatus | ||
| + | 29 sessionAuthenticationTrap | ||
| + | 30 trapAbsorptionTrap | ||
| + | 31 alaDoSTrap | ||
| + | 32 ospfNbrStateChange | ||
| + | 33 ospfVirtNbrStateChange | ||
| + | 34 lnkaggAggUp | ||
| + | 35 lnkaggAggDown | ||
| + | 36 lnkaggPortJoin | ||
| + | 37 lnkaggPortLeave | ||
| + | 38 lnkaggPortRemove | ||
| + | 39 monitorFileWritten | ||
| + | 40 alaVrrp3TrapProtoError | ||
| + | 41 alaVrrp3TrapNewMaster | ||
| + | 42 chassisTrapsPossibleDuplicateMac | ||
| + | 43 lldpRemTablesChange | ||
| + | 44 pimNeighborLoss | ||
| + | 45 pimInvalidRegister | ||
| + | 46 pimInvalidJoinPrune | ||
| + | 47 pimRPMappingChange | ||
| + | 48 pimInterfaceElection | ||
| + | 49 pimBsrElectedBSRLostElection | ||
| + | 50 pimBsrCandidateBSRWinElection | ||
| + | 51 lpsViolationTrap | ||
| + | 52 lpsPortUpAfterLearningWindowExpiredT bridge | ||
| + | 53 lpsLearnTrap | ||
| + | 54 gvrpVlanLimitReachedEvent | ||
| + | 55 alaNetSecPortTrapAnomaly | ||
| + | 56 alaNetSecPortTrapQuarantine | ||
| + | 57 ifMauJabberTrap | ||
| + | 58 udldStateChange | ||
| + | 59 ndpMaxLimitReached | ||
| + | 60 ripRouteMaxLimitReached | ||
| + | 61 ripngRouteMaxLimitReached | ||
| + | 62 alaErpRingStateChanged | ||
| + | 63 alaErpRingMultipleRpl | ||
| + | 64 alaErpRingRemoved | ||
| + | 65 ntpMaxAssociation | ||
| + | 66 ddmTemperatureThresholdViolated | ||
| + | 67 ddmVoltageThresholdViolated | ||
| + | 68 ddmCurrentThresholdViolated | ||
| + | 69 ddmTxPowerThresholdViolated | ||
| + | 70 ddmRxPowerThresholdViolated | ||
| + | 71 webMgtServerErrorTrap | ||
| + | 72 multiChassisIpcVlanUp | ||
| + | 73 multiChassisIpcVlanDown | ||
| + | 74 multiChassisMisconfigurationFailure | ||
| + | 75 multiChassisHelloIntervalConsisFailu mcm 15 seconds | ||
| + | 76 multiChassisStpModeConsisFailure | ||
| + | 77 multiChassisStpPathCostModeConsisFai mcm 15 seconds | ||
| + | 78 multiChassisVflinkStatusConsisFailur mcm 15 seconds | ||
| + | 79 multiChassisStpBlockingStatus | ||
| + | 80 multiChassisLoopDetected | ||
| + | 81 multiChassisHelloTimeout | ||
| + | 82 multiChassisVflinkDown | ||
| + | 83 multiChassisVFLMemberJoinFailure | ||
| + | 84 alaDHLVlanMoveTrap | ||
| + | 85 alaDhcpClientAddressAddTrap | ||
| + | 86 alaDhcpClientAddressExpiryTrap | ||
| + | 87 alaDhcpClientAddressModifyTrap | ||
| + | 88 vRtrIsisDatabaseOverload | ||
| + | 89 vRtrIsisManualAddressDrops | ||
| + | 90 vRtrIsisCorruptedLSPDetected | ||
| + | 91 vRtrIsisMaxSeqExceedAttempt | ||
| + | 92 vRtrIsisIDLenMismatch | ||
| + | 93 vRtrIsisMaxAreaAddrsMismatch | ||
| + | 94 vRtrIsisOwnLSPPurge | ||
| + | 95 vRtrIsisSequenceNumberSkip | ||
| + | 96 vRtrIsisAutTypeFail | ||
| + | 97 vRtrIsisAuthFail | ||
| + | 98 vRtrIsisVersionSkew | ||
| + | 99 vRtrIsisAreaMismatch | ||
| + | 100 vRtrIsisRejectedAdjacency | ||
| + | 101 vRtrIsisLSPTooLargeToPropagate | ||
| + | 102 vRtrIsisOrigLSPBufSizeMismatch | ||
| + | 103 vRtrIsisProtoSuppMismatch | ||
| + | 104 vRtrIsisAdjacencyChange | ||
| + | 105 vRtrIsisCircIdExhausted | ||
| + | 106 vRtrIsisAdjRestartStatusChange | ||
| + | 107 mvrpVlanLimitReachedEvent | ||
| + | 108 alaHAVlanClusterPeerMismatch | ||
| + | 109 alaHAVlanMCPeerMismatch | ||
| + | 110 alaHAVlanDynamicMAC | ||
| + | 111 unpMcLagMacIgnored | ||
| + | 112 unpMcLagConfigInconsistency | ||
| + | 113 multiChassisGroupConsisFailure | ||
| + | 114 multiChassisTypeConsisFailure | ||
| + | 115 alaPimNonBidirHello | ||
| + | 116 dot1agCfmFaultAlarm | ||
| + | 117 alaSaaIPIterationCompleteTrap | ||
| + | 118 alaSaaEthIterationCompleteTrap | ||
| + | 119 alaSaaMacIterationCompleteTrap | ||
| + | 120 virtualChassisStatusChange | ||
| + | 121 virtualChassisRoleChange | ||
| + | 122 virtualChassisVflStatusChange | ||
| + | 123 virtualChassisVflMemberPortStatusCh vcm 15 seconds | ||
| + | 124 virtualChassisVflMemberPortJoinFail vcm 15 seconds | ||
| + | 125 lldpV2RemTablesChange | ||
| + | 126 vRtrLdpInstanceStateChange | ||
| + | 127 evbFailedCdcpTlvTrap | ||
| + | 128 evbFailedEvbTlvTrap | ||
| + | 129 evbUnknownVsiManagerTrap | ||
| + | 130 evbVdpAssocTlvTrap | ||
| + | 131 evbCdcpLldpExpiredTrap | ||
| + | 132 evbTlvExpiredTrap | ||
| + | 133 evbVdpKeepaliveExpiredTrap | ||
| + | 134 smgrServiceError | ||
| + | 135 smgrServiceHwError | ||
| + | 136 smgrSapError | ||
| + | 137 smgrSapHwError | ||
| + | 138 smgrSdpError | ||
| + | 139 smgrSdpHwError | ||
| + | 140 smgrSdpBindError | ||
| + | 141 smgrSdpBindHwError | ||
| + | 142 smgrGeneralError | ||
| + | 143 smgrStatusChange | ||
| + | 144 portViolationNotificationTrap | ||
| + | 145 multiChassisConsisFailureRecovered | ||
| + | 146 alaSaaPacketLossTrap | ||
| + | 147 alaSaaJitterThresholdYellowTrap | ||
| + | 148 alaSaaRTTThresholdYellowTrap | ||
| + | 149 alaSaaJitterThresholdRedTrap | ||
| + | 150 alaSaaRTTThresholdRedTrap | ||
| + | 151 chassisTrapsDuplicateMacCleared | ||
| + | 152 alaFipsResourceThresholdReached | ||
| + | 153 virtualChassisUpgradeComplete | ||
| + | 154 appFPSignatureMatchTrap | ||
| + | 155 virtualChassisVflSpeedTypeChange | ||
| + | 156 alaSIPSnoopingACLPreemptedBySOSCall qos 15 seconds | ||
| + | 157 alaSIPSnoopingRTCPOverThreshold | ||
| + | 158 alaSIPSnoopingRTCPPktsLost | ||
| + | 159 alaSIPSnoopingSignallingLost | ||
| + | 160 alaSIPSnoopingCallRecordsFileMoved | ||
| + | 161 alaIPv6NeighborLimitExceeded | ||
| + | 162 alaIPv6NeighborVRFLimitExceeded | ||
| + | 163 alaIPv6InterfaceNeighborLimitExceed ip 15 seconds | ||
| + | 164 alaDyingGaspTrap | ||
| + | 165 alaDhcpSrvLeaseUtilizationThreshold dhcp-server | ||
| + | 166 alaDHCPv6SrvLeaseUtilizationThresho dhcpv6-server | ||
| + | 167 smgrServiceStatusChange | ||
| + | 168 smgrSapStatusChange | ||
| + | 169 smgrSdpStatusChange | ||
| + | 170 smgrSdpBindStatusChange | ||
| + | 171 alaPethPwrSupplyConflictTrap | ||
| + | 172 alaPethPwrSupplyNotSupportedTrap | ||
| + | 173 chasTrapsBPSLessAllocSysPwr | ||
| + | 174 chasTrapsBPSStateChange | ||
| + | 175 chasTrapsNiBPSFETStateChange | ||
| + | 176 alaDhcpBindingDuplicateEntry | ||
| + | 177 alaVCSPProtectionTrap | ||
| + | 178 alaVCSPRecoveryTrap | ||
| + | 179 pethPsePortOnOffNotification | ||
| + | 180 pethMainPowerUsageOnNotification | ||
| + | 181 pethMainPowerUsageOffNotification | ||
| + | 182 chasTrapsBPSFwUpgradeAlert | ||
| + | 183 alaAppMonAppRecordFileCreated | ||
| + | 184 alaAppMonFlowRecordFileCreated | ||
| + | 185 alaDPIFlowRecordFileCreated | ||
| + | 186 alaLbdStateChangeToShutdown | ||
| + | 187 alaLbdStateChangeForClearViolationA lbd 15 seconds | ||
| + | 188 alaLbdStateChangeForAutoRecovery | ||
| + | 189 alaAutoConfigAutoFabricEnableTrap | ||
| + | 190 alaVMSnoopingVMLearntAlert | ||
| + | 191 alaVMSnoopingVMRemovedAlert | ||
| + | 192 alaVMSnoopingReservedHwResourceLimi vm-snooping | ||
| + | 193 alaDistArpItfChange | ||
| + | 194 alaDistArpNiThreshold | ||
| + | 195 smgrVxlanSdpBindStatusChange | ||
| + | 196 alaAutoFabricSTPModeChangeAlert | ||
| + | 197 alaKerberosReqTimeoutTrap | ||
| + | 198 alaKerberosInactivityTimerExpiryTra da-unp | ||
| + | 199 alaKerberosRateLimitExceed | ||
| + | 200 pethMainPowerUsageNiFailNotificatio module | ||
| + | 201 systemSwlogSizeTrap | ||
| + | 202 esmStormThresholdViolationStatus | ||
| + | 203 alaSTPLoopGuardError | ||
| + | 204 alaSTPLoopGuardRecovery | ||
| + | 205 alaLldpTrustViolation | ||
| + | 206 alaLicenseManagerDemoDayAlert | ||
| + | 207 alaAaaUserCreation | ||
| + | 208 alaAaaUserDeletion | ||
| + | 209 alaAaaUserModification | ||
| + | 210 systemSwlogFailureTraps | ||
| + | 211 pethPseMainTemperatureUpAlert | ||
| + | 212 pethPseMainTemperatureDownAlert | ||
| + | 213 systemRebootSwlogFailureTrap | ||
| + | 214 ospfv3RestartStatusChange | ||
| + | 215 ospfv3NbrRestartHelperStatusChange | ||
| + | 216 ospfv3VirtNbrRestartHelperStatusCha ospfv3 | ||
| + | 217 smgrL2greSdpBindStatusChange | ||
| + | 218 dot3OamThresholdEvent | ||
| + | 219 dot3OamNonThresholdEvent | ||
| + | 220 alaDot3OamThresholdEventClear | ||
| + | 221 alaDot3OamNonThresholdEventClear | ||
| + | 222 alaAlarmReplayAlarmInputEvent | ||
| + | 223 alaHWRoutingCapacityExceeded | ||
| + | 224 vrrpv3NewMaster | ||
| + | 225 vrrpv3ProtoError | ||
| + | 226 alaDhcpBindingTcamFail | ||
| + | 227 systemStorageLockTrap | ||
| + | 228 alaDhcpIsfDrop | ||
| + | 229 alaDaRouterAuthUserPassedAuthThresh da-unp | ||
| + | 230 alaDaRouterAuthUserMaxRetryFailed | ||
| + | 231 alaDaRouterAuthUserFailedAuthThresh da-unp | ||
| + | 232 alaDaRouterAuthConfigThresholdExcee da-unp | ||
| + | 233 alaDaRouterAuthMaxCapacityReached | ||
| + | 234 alaTestOamTxDoneTrap | ||
| + | 235 alaTestOamRxReadyTrap | ||
| + | 236 alaTestOamTestAbortTrap | ||
| + | 237 alaTestOamGroupTxDoneTrap | ||
| + | 238 alaTestOamGroupRxReadyTrap | ||
| + | 239 alaTestOamGroupAbortTrap | ||
| + | 240 alaTestOamStatsWriteDoneTrap | ||
| + | 241 alaDhcpv6IsfTcamFail | ||
| + | 242 alaHWArpCapacityExceeded | ||
| + | 243 alaHWMacCapacityExceeded | ||
| + | 244 alaDaUnpMaxUserExceeded | ||
| + | 245 alaDaUnpHWResourceExhaust | ||
| + | 246 alaDhcpVsoBrokerIpAddress | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== Ein einfaches Beispiel als Codegerüst: | ||
| + | |||
| + | In diesem Beispiel nehmen wir ein einfach per CLI zu erzeugenden SNMP Trap "debug generate trap 10" und geben den Inhalt auf der seriellen Konsole (!) aus - also nicht der SSH-Session. | ||
| + | |||
| + | < | ||
| Switch-> vi / | Switch-> vi / | ||
| Zeile 45: | Zeile 306: | ||
| </ | </ | ||
| + | ===== Fortgeschritten ===== | ||
| + | ==== Anwendungsfall: | ||
| + | Damit der OmniSwitch nach erfolgreichem "write memory flash-synchro" | ||
| + | - Ein SSH private/ | ||
| + | - Bei einer Automatisierung ist eine " | ||
| + | - Damit die Verbindung per SSH/SCP erfolgreich ist, muss das identity_file mit korrekten Zugriffsrechten hinterlegt werden | ||
| + | - Das Skript auf dem Switch hinterlegen | ||
| + | - Mit " | ||
| + | - Den Vorgang testen | ||
| + | |||
| + | === 1. SSH private/ | ||
| + | < | ||
| + | ssh-keygen -t rsa -b 2048 -C " | ||
| + | </ | ||
| + | Der resultierende id_rsa.pub-Key muss für den Benutzer in ~/ | ||
| + | |||
| + | === 2. Automatisierung von SSH-Host-Fingerprint yes/no === | ||
| + | |||
| + | Der Zusatz **-o StrictHostKeyChecking=no** sollte nur verwendet werden, wenn man mit der Konsequenz einer potentiellen MITM-Attacke leben kann. Bitte beachten dass das Skript fehlschlagen wird, wenn sich der SSH-Host-Fingerprint ändert. Das könnte man zwar auch wegkonfigurieren, | ||
| + | |||
| + | < | ||
| + | Switch-> scp -i / | ||
| + | </ | ||
| + | |||
| + | === 3. Korrekte Zugriffsrechte für ssh_private_key === | ||
| + | |||
| + | < | ||
| + | Switch-> chmod 600 / | ||
| + | </ | ||
| + | |||
| + | === 4. Skript für Export === | ||
| + | Vorausgesetzt die Tipps aus diesem Artikel wurden angewendet, kann nun mit diesem Skript die Konfiguration extern abgelegt werden. Das folgende Skript hier abspeichern: | ||
| + | |||
| + | <file python chassis_trap.py> | ||
| + | # | ||
| + | |||
| + | import sys | ||
| + | import os | ||
| + | import getopt | ||
| + | import json | ||
| + | import subprocess | ||
| + | |||
| + | # Based upon work done by Patricio Martelo and Benny Eggerstedt in 2015 | ||
| + | # Some corrections and enhancements done by Benny in 2020 | ||
| + | |||
| + | # Variables to set by customer | ||
| + | ssh_priv_key = "/ | ||
| + | config_to_backup = "/ | ||
| + | scp_target_user = " | ||
| + | scp_host = " | ||
| + | scp_path = "/ | ||
| + | |||
| + | # Get system name | ||
| + | system_name = os.uname()[1].replace(" | ||
| + | |||
| + | # Uncomment during early stage of development | ||
| + | # | ||
| + | |||
| + | # Load the data that is being sent to us | ||
| + | # -t holds the traptype | ||
| + | # -d holds the trapdata | ||
| + | try: | ||
| + | opts, args = getopt.getopt(sys.argv[1: | ||
| + | except getopt.GetoptError as err: | ||
| + | print(err) | ||
| + | print(" | ||
| + | sys.exit(2) | ||
| + | traptype = " | ||
| + | trapdata = " | ||
| + | |||
| + | # Go through the data in opts and allocate it properly | ||
| + | # traptype gets the value from -t | ||
| + | # trapdata gets the value from -d | ||
| + | for o, a in opts: | ||
| + | if o == " | ||
| + | traptype = a | ||
| + | elif o == " | ||
| + | trapdata = a | ||
| + | |||
| + | # | ||
| + | # | ||
| + | |||
| + | # | ||
| + | |||
| + | trapdetail = json.loads(trapdata) | ||
| + | |||
| + | # | ||
| + | |||
| + | if trapdetail[" | ||
| + | # This type of trap is sent when write memory flash-synchro finished | ||
| + | # | ||
| + | # When the "write memory flash-synchro" | ||
| + | if " | ||
| + | system_date = subprocess.check_output([" | ||
| + | system_time = subprocess.check_output([" | ||
| + | timestamp = system_date + " | ||
| + | os.system(" | ||
| + | print(" | ||
| + | </ | ||
| + | |||
| + | **5. Mit " | ||
| + | < | ||
| + | Switch-> event-action trap chassisTrapsAlert script / | ||
| + | </ | ||
| + | |||
| + | **6. Testen:** | ||
| + | < | ||
| + | Switch-> write memory flash-synchro | ||
| + | </ | ||
| + | |||
| + | **Ausgabe auf der Switch-Konsole: | ||
| + | < | ||
| + | {' | ||
| + | |||
| + | Wed Sep 9 18:16:07 : ChassisSupervisor MipMgr INFO message: | ||
| + | +++ Copy running to certified succeeded | ||
| + | {' | ||
| + | Please wait... | ||
| + | Executing: program / | ||
| + | Sending file modes: C0644 4312 vcboot.cfg | ||
| + | Sink: C0644 4312 vcboot.cfg | ||
| + | Process finished! | ||
| + | </ | ||
| + | ===== Fehleranalyse ===== | ||
| + | |||
| + | ==== scp lost connection ==== | ||
| + | |||
| + | Wenn die folgende Fehlermeldung auftaucht, liegt entweder ein Kommunikationsfehler vor oder das identity_file ist für zuviele Nutzer lesbar/ | ||
| + | < | ||
| + | Please wait... | ||
| + | lost connection | ||
| + | </ | ||
| + | |||
| + | **Lösung: | ||
| + | < | ||
| + | Switch-> chmod 600 / | ||
| + | </ | ||
| + | |||
| + | ==== scp known_hosts ==== | ||
| + | (Abfrage der yes/no SSH Fingerprint-Bestätigung deaktivieren.) | ||
| + | |||
| + | Der Zusatz -o StrictHostKeyChecking=no führt dazu dass man die Identität des Servers nicht bestätigen muss. Die Identität des Servers wird aber trotzdem in ~/ | ||
| + | < | ||
| + | scp -i / | ||
| + | </ | ||
event-action-python-aos-r8.1599636392.txt.gz · Zuletzt geändert: (Externe Bearbeitung)
