SNMP enhancements #718
This commit is contained in:
@@ -12,7 +12,7 @@ NetAlertX comes with a plugin system to feed events from third-party scripts int
|
|||||||
|
|
||||||
### 🎥 Watch the video:
|
### 🎥 Watch the video:
|
||||||
|
|
||||||
[](https://youtu.be/bjA7wIK_jXY)
|
[](https://youtu.be/cdbxlwiWhv8)
|
||||||
|
|
||||||
### 📸 Screenshots
|
### 📸 Screenshots
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,22 @@ def decodeBase64(inputParamBase64):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------
|
||||||
|
def normalize_mac(mac):
|
||||||
|
# Split the MAC address by colon (:) or hyphen (-) and convert each part to uppercase
|
||||||
|
parts = mac.upper().split(':')
|
||||||
|
|
||||||
|
# If the MAC address is split by hyphen instead of colon
|
||||||
|
if len(parts) == 1:
|
||||||
|
parts = mac.upper().split('-')
|
||||||
|
|
||||||
|
# Normalize each part to have exactly two hexadecimal digits
|
||||||
|
normalized_parts = [part.zfill(2) for part in parts]
|
||||||
|
|
||||||
|
# Join the parts with colon (:)
|
||||||
|
normalized_mac = ':'.join(normalized_parts)
|
||||||
|
|
||||||
|
return normalized_mac
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
class Plugin_Object:
|
class Plugin_Object:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import sys
|
|||||||
INSTALL_PATH="/app"
|
INSTALL_PATH="/app"
|
||||||
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
|
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
|
||||||
|
|
||||||
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty
|
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty, normalize_mac
|
||||||
from logger import mylog
|
from logger import mylog
|
||||||
from helper import timeNowTZ
|
from helper import timeNowTZ
|
||||||
from const import logPath, applicationPath
|
from const import logPath, applicationPath
|
||||||
@@ -91,7 +91,7 @@ def main():
|
|||||||
if len(parts) == 2:
|
if len(parts) == 2:
|
||||||
|
|
||||||
ipAddress = parts[0].split('[')[-1][:-1]
|
ipAddress = parts[0].split('[')[-1][:-1]
|
||||||
macAddress = parts[1]
|
macAddress = normalize_mac(parts[1])
|
||||||
|
|
||||||
mylog('verbose', [f'[SNMPDSC] IP: {ipAddress} MAC: {macAddress}'])
|
mylog('verbose', [f'[SNMPDSC] IP: {ipAddress} MAC: {macAddress}'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user