Community discussions

MikroTik App
 
cabijuan
just joined
Topic Author
Posts: 14
Joined: Mon Mar 12, 2018 12:49 pm

The dude devices without a map

Fri Feb 10, 2023 6:19 pm

Hello, when I add a device from winbox, in doubt it appears without a map and I can't put the map anywhere. Can somebody help me? With this, you could enter many elements to be monitored at once through the terminal. Thank you.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3253
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: The dude devices without a map

Fri Feb 10, 2023 6:27 pm

Yeah, quite annoying, but not sure that's possible. Even more annoying you can't change the device's assigned map from the Dude side either – so the device is stuck on the map it used when created even if you do this in the Dude app.

But it should still put it in some map AFAIK when you use RouterOS CLI, you just can't control which one. Perhaps that logic has changed... I use the discovery in Dude so each map is a subnet (or partial/multiple subnets), so the Dude's discovery creates the devices - then the devices are somewhat usable in RouterOS CLI.
 
cabijuan
just joined
Topic Author
Posts: 14
Joined: Mon Mar 12, 2018 12:49 pm

Re: The dude devices without a map

Sun Feb 12, 2023 10:21 pm

I still can't find a way to add a CLI created device to a map
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3253
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: The dude devices without a map

Sun Feb 12, 2023 11:11 pm

I'm sorry, I misspoke. I knew the CLI doesn't let your set the attributes, but winbox does. But I thought it did assign a default map when you added from CLI/winbox, but I was wrong.

But yeah the map isn't editable ANYWHERE – CLI or Winbox or even the Dude client. It frozen, along with any captured data in the map. The only workaround I've to make it automatic is to have the Dude use discovery on a map, to and let it add the devices. Then you at least use winbox (but not CLI) to edit the devices.
 
User avatar
bpwl
Forum Guru
Forum Guru
Posts: 2984
Joined: Mon Apr 08, 2019 1:16 am

Re: The dude devices without a map

Mon Feb 13, 2023 2:13 am

I still can't find a way to add a CLI created device to a map
Could this be due to the SQLite3 database structure used by DUDE?
The MAP is probably not an attribute to the device. (A device can be on many MAPs, and then the mapped devices seem to be independent items for DUDE)

Can we open a downloaded copy of that SQLIte3 database? (SQLite Viewer, like https://sqliteviewer.flowsoft7.com/ ???????????????????? )
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3253
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: The dude devices without a map

Mon Feb 13, 2023 3:22 am

There was someone on the forum who had some python to parse it. But it stored in some highly optimized schema, so it's not some "UPDATE" operation.

See: viewtopic.php?f=8&t=145928

For example, the "export python" kinda shows what WAG are C++ structs serialized into the database.
import sqlite3, re, binascii
conn = sqlite3.connect('/home/ulypka/dude/dude.db')
maps=dict()
devices=dict()
net=dict()
def inttohex(a):
    h=hex(int(a))[2:].zfill(8)
    rh="".join(reversed([h[i:i+2] for i in range(0, len(h), 2)]))
    return(rh)
def addrhettarr(s):
    ips=list()
    for index in range(len(s)/8):
        #print index
        hip=s[:8]
        s=s[8:]
        bytes = ["".join(x) for x in zip(*[iter(hip)]*2)]
        bytes = [int(x, 16) for x in bytes]
        ips.append(".".join(str(x) for x in bytes))
    return(ips)
def hextoint(a):
    rh="".join(reversed([a[i:i+2] for i in range(0, len(a), 2)]))
    return(int(rh, 16))
for row in conn.execute("select id, HEX(obj) from objs"):
    rowmap=re.search('4e6574776f726b204d617020456c656d656e741000FE21..(.+)$',row[1],re.IGNORECASE)
    if rowmap:
        mname=rowmap.group(1)
        #print row[0], binascii.unhexlify(mname)
        #mname=rowmap.group(1)
        maps[row[0]]={'name':binascii.unhexlify(mname),'hex':inttohex(row[0])}
    if re.search("4D320100FF8801000F000000.+4C1F1008.+",row[1]):#Hosts
        #print 'original',row[0],row[1]
        hexname=re.search ('^4D320100FF8801000F000000.+1000FE21..(.+)$', row[1])
        name=binascii.unhexlify(hexname.group(1))
        #4D320100FF8801000F000000.+401F1088(ip count 2 bites)
        countip=re.search ('^4D320100FF8801000F000000.+401F1088(....).+$',row[1])
        #print countip.group(1)
        hexip=re.search ('^4D320100FF8801000F000000.+401F1088....(.{'+str(8*int(hextoint(countip.group(1))))+'}).+$',row[1])# .... is 2 vite for IP's
        #print hexip.group(1)
        ips=addrhettarr(hexip.group(1))
        #print row[1]
        #4D320100FF8801000F000000571F1088(01-EXIST/0-NOT)00AF726304
        pid=re.search ('^4D320100FF8801000F000000571F10880100(.{8}).+$',row[1])
        if pid:
            pid=pid.group(1)
            #print pid
            #print hextoint(pid)
        else:
            pid='0'
        devices[row[0]]={'name':name,'ips':ips,'pid':hextoint(pid)}
    NE="4D320100FF8801004A000000"
    if re.search(NE+".+",row[1]):#NetworkMapElement
        Hdata=row[1][len(NE):]
        Hdata2=re.search('(.+)D85D1031',Hdata)
        Tdata=Hdata2.group(1)
        #print 'original',Hdata2.group(1)
        net[row[0]]={}
        for m in re.finditer('....((100(0|1|8|9))|FE08)', Hdata2.group(1)):
            curind=m.group(0)
            if curind[-1]=='0' or curind[-1]=='1':#0 bite
                val='0'
            elif curind[-1]=='8':#4 bite
                val=Tdata[8:][:8]
                Tdata=Tdata[8:]
            elif curind[-1]=='9':#1 bite
                val=Tdata[8:][:2]
                Tdata=Tdata[2:]
            else:
                print 'allarm'
                quit()
            Tdata=Tdata[8:]
            #print 'id',row[0],'hexid',curind,'valueHEX',val, 'NormalVal',hextoint(val)
            net[row[0]][curind[:7]]={'val':val,'bit':curind[-1]}
#LINKS
#da5d1009#64#probebli type#db5d1008#b5726304#linkFrom#dc5d1008#e5929904#linkTo#dd5d1008#e8929904#linkID#df5d1009#04#linkWidth#0100fe08#ea929904#ItemID#
#c05d1008#abaf3a04#MapID#c25d100901c35d100900c45d1008ffffffff#c55d1009#4b#X#c65d1009#28#Y#c75d1009
#print row[1]
#LEN 1000 - 0 bite 1008 - 4 bites  1009 1 bites (len) 1031 maybe payload? FE08-itemid  4 bites
#HOST
#c05d1008#abaf3a04#mapID#c25d1009#00#c35d1009#00#c45d1008#5c375a06#itemID#c55d1008#f2080000#X#c65d1009#e9#Y#c75d1009#00#d85d1031#3c0b00000000000000
LIDlinkFrom='DB5D100'
LIDlinkTo='DC5D100'
LIDlinkID='DB5D100'
LIDItemID='0100FE0'
LIDMapID='C05D100'
LIDX='C55D100'
LIDY='C75D100'
HIDmapID='C05D100'
HIDitemID='C45D100'
HIDX='C55D100'
HIDY='C65D100'
#print devices
for index in net:
    if net[index][HIDitemID]['val']=='FFFFFFFF':#Link type
        linkID[index]={'linkFrom':hextoint(net[index][LIDlinkFrom]['val']),
                        'linkTo':hextoint(net[index][LIDlinkTo]['val']),
                        'MapID':hextoint(net[index][LIDMapID]['val']),
                        }
    else:#host
        h=hextoint(net[index][HIDitemID]['val'])
        if h in devices:
            devices[h]['itemX']=hextoint(net[index][HIDX]['val'])
            devices[h]['itemY']=hextoint(net[index][HIDY]['val'])
            devices[h]['itemID']=hextoint(net[index][HIDitemID]['val'])
            devices[h]['MapID']=hextoint(net[index][HIDmapID]['val'])
            devices[h]['LinkID']=index

 
cabijuan
just joined
Topic Author
Posts: 14
Joined: Mon Mar 12, 2018 12:49 pm

Re: The dude devices without a map

Mon Feb 13, 2023 11:12 am

I've tried everything and it doesn't work. Until you create a map with no name, the dude doesn't let it, but it does in winbox. Let's see if those devices went to that map, but they don't.
 
User avatar
bpwl
Forum Guru
Forum Guru
Posts: 2984
Joined: Mon Apr 08, 2019 1:16 am

Re: The dude devices without a map

Mon Feb 13, 2023 2:14 pm

What is in the WinBox -> Dude -> Network Maps -> Network Maps Elements? (Network Map column info)

I suppose that the Map is part of the key for the device in the database.
Adding a device to a Map (DUDE GUI) , in multiple Maps, gives multiple devices in the WinBox_DUDE_Devices_TAB. I seems the devices are identified by the concatenation of Map and IP address.
That IP address can be repeated in all Maps, and creates separate instances of that device for DUDE.
The default Map is "Local".
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3253
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: The dude devices without a map

Mon Feb 13, 2023 2:38 pm

The default Map is "Local".
You know I renamed "Local" at some point... Winbox/CLI may expect specifically "Local" to use a default map, dunno...

The Winbox's Dude's "Network Map Elements" tab does show all the items on maps. But add/remove aren't allowed in CLI or Winbox. And map name is read-only field in winbox on existing ones.

Who is online

Users browsing this forum: norepto and 8 guests