Ad Widget

Collapse

Parsing MAC address field in Windows 10

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cronsloth
    Junior Member
    • Oct 2017
    • 2

    #1

    Parsing MAC address field in Windows 10

    I have searched a lot and not found anything, and am driving myself crazy trying to do something that seems so simple. I am admittedly really bad with Java Regex, so that is my first issue...but moving on...

    I am trying to get the active MAC address to populate within Zabbix 3.4.0
    I'm running Windows 10 Pro so the Zabbix Agent key:

    system.hw.macaddr[<interface>,<format>]

    doesn't work. I have worked out to do this so far, but it gives me a string with 2 fields.

    system.run[getmac /s {IPADDRESS} /nh]

    This will give an output like this to Zabbix:

    34-FF-FF-00-00-00 \Device\Tcpip_{0316FFFF-D435-4354-3986-7DEFD6AB1400}

    all I want is the MAC address and not the \Device\....etc. info. In linux this is a .5 second 'awk' or 'cut' or 'grep' or 50 other tools. But I can't seem to work out how to do this.. This is needed for about 10 other items I have had to custom make. So the info would carry to other headaches of mine. If there is a better way to do this I'm all ears.
  • kaspars.mednis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2017
    • 349

    #2
    If you are using Zabbix 3.4, you can leave it as it is and preprocess the item on Zabbix Server side

    Configure item - > second tab is named preprocessing in 3.4

    Preprocessing step = Regular Expression
    Pattern = (\S\S-\S\S-\S\S-\S\S-\S\S-\S\S)
    Output = \1

    P.S.
    I'm not a big guru of regexp, someone can write this shorter and better, but at least this works

    Regards,
    Kaspars

    Comment

    • Semiadmin
      Senior Member
      • Oct 2014
      • 1625

      #3
      Hi, cronsloth.
      You may easy achive this by wmi.get, item prototype key for LLD:
      wmi.get[root\cimv2,Select MACAddress from Win32_NetworkAdapter where Name="{#IFNAME}"]

      Comment

      Working...