container autobinding stopped working 3.7

Started by normalcy, January 11, 2021, 02:46:58 AM

Previous topic - Next topic

normalcy

Has something changed with container auto-bind scripts in 3.7?

Since upgrading to 3.7 I just noticed that my containers with auto-bind scripts applied have stopped working (the nodes have been removed).

eg script:
if (
    $node->zoneUIN == 0 &&
    $node->isRouter == 1 &&
    $node->isPrinter != 1 &&
    GetCustomAttribute($node, "ignoreRouter") == null)
    {
      return true;
    }
return false;


But even a simpler version with Zone and other attribute checks removed:
if (
    $node->isRouter == 1)

    {
      return true;
    }
return false;


Will remove any bound node.

The relevant nodes have isRouter = Yes on the object details tab.

Same is happening to all atuo-bind containers (looking at isBridge, or isPrinter etc).

normalcy

I enabled debug logging on the server, manually bound a router node to the All Routers container with simplified stripped down auto-bind script from my first post and ran a configuration poll.  The autounbind event was triggered and my router removed again.

Below is debug log around the subsequent autounbind event.


root@netxms:/var/log# grep AUTOUNBIND netxmsd.1 -B40 -A20                                                                                                                                                                                                                                                           [11/4709]
2021.01.11 11:02:58.938 *D* [client.session.0   ] Sending compressed message CMD_POLLING_INFO (128 bytes)
2021.01.11 11:02:58.938 *D* [client.session.0   ] Message dump:
  ** 000000 | 00 5A 50 40 00 00 00 80 00 00 00 17 00 00 00 02 | .ZP@............
  ** 000010 | 00 00 00 88 78 DA 2D 8C B1 0A 83 40 10 44 AF 0B | [email protected]..
  ** 000020 | 08 D6 69 2C E6 03 F2 23 36 62 95 7E E3 0E 28 9C | ..i,...#6b.~..(.
  ** 000030 | BB E1 6E F1 FB 35 5E A6 79 C3 0C BC 94 D2 90 5A | ..n..5^.y......Z
  ** 000040 | 9E 7F E6 47 E3 7B 72 25 4C 76 62 11 33 0F 7C 88 | ...G.{r%Lvb.3.|.
  ** 000050 | CD 82 E5 5B 18 54 48 C5 21 79 53 8C 33 44 B5 B0 | ...[.TH.!yS.3D..
  ** 000060 | D6 17 CC 61 BC CE 70 5C 83 E7 83 BF BA 7A 8D 5B | ...a..p\.....z.[
  ** 000070 | D5 77 4D 7E 02 54 62 1F 38 00 00 00 00 00 00 00 | .wM~.Tb.8.......
  ** code=0x005A (CMD_POLLING_INFO) version=5 flags=0x0040 id=23 size=128 numFields=2
  ** 000000: [    28] INT32       23
  ** 000010: [   108] UTF8-STRING "Node name cannot be interpreted as valid IP address, no need to resolve to host name
"

2021.01.11 11:02:58.938 *D* [client.session.0   ] Sending message CMD_POLLING_INFO (96 bytes)
2021.01.11 11:02:58.938 *D* [client.session.0   ] Message dump:
  ** 000000 | 00 5A 50 00 00 00 00 60 00 00 00 17 00 00 00 02 | .ZP....`........
  ** 000010 | 00 00 00 1C 00 00 00 00 00 00 00 17 00 00 00 00 | ................
  ** 000020 | 00 00 00 6C 07 00 00 00 00 00 00 2E 55 70 64 61 | ...l........Upda
  ** 000030 | 74 69 6E 67 20 67 65 6E 65 72 61 6C 20 73 79 73 | ting general sys
  ** 000040 | 74 65 6D 20 68 61 72 64 77 61 72 65 20 69 6E 66 | tem hardware inf
  ** 000050 | 6F 72 6D 61 74 69 6F 6E 0D 0A 00 00 00 00 00 00 | ormation........
  ** code=0x005A (CMD_POLLING_INFO) version=5 flags=0x0000 id=23 size=96 numFields=2
  ** 000000: [    28] INT32       23
  ** 000010: [   108] UTF8-STRING "Updating general system hardware information
"

2021.01.11 11:02:58.939 *D* [poll.conf          ] ConfPoll(r02-brisbane.<stripped-out>.com.au): system hardware information: vendor=MikroTik product=CCR1036-12G-4S pcode=CCR1036-12G-4S version=6.46.7 serial=<stripped>
2021.01.11 11:02:58.939 *D* [poll.conf          ] Node::detectNodeType(r02-brisbane.<stripped-out>.com.au [1784]): SNMP node, driver name is MIKROTIK
2021.01.11 11:02:58.939 *D* [poll.conf          ] ConfPoll(r02-brisbane.<stripped-out>.com.au): detected node type: 1 (Physical)
2021.01.11 11:02:58.939 *D* [obj.lifecycle      ] NetObj::executeHookScript(r02-brisbane.<stripped-out>.com.au [1784]): hook script "Hook::ConfigurationPoll" is empty
2021.01.11 11:02:58.943 *D* [                   ] DataCollectionTarget::updateContainerMembership(): removing object 1784 "r02-brisbane.<stripped-out>.com.au" from container 2362 "All Routers"
2021.01.11 11:02:58.943 *D* [obj.relations      ] NetObj::deleteChild: this=All Routers [2362]; object=r02-brisbane.<stripped-out>.com.au [1784]
2021.01.11 11:02:58.943 *D* [obj.notify         ] Sending object change notification for All Routers [2362] (flags=0x00000008)
2021.01.11 11:02:58.943 *D* [obj.relations      ] NetObj::deleteParent: this=r02-brisbane.<stripped-out>.com.au [1784]; object=All Routers [2362]
2021.01.11 11:02:58.943 *D* [obj.notify         ] Sending object change notification for r02-brisbane.<stripped-out>.com.au [1784] (flags=0x00000008)
2021.01.11 11:02:58.944 *D* [obj.notify         ] Sending object change notification for All Routers [2362] (flags=0x00000000)
2021.01.11 11:02:58.944 *D* [obj.notify         ] Sending object change notification for All Routers [2362] (flags=0x00000000)
2021.01.11 11:02:58.944 *D* [obj.macro          ] NetObj::expandText(sourceObject=11199 template='Node %2 automatically unbound from container %4' alarm=0 event=13404393)
2021.01.11 11:02:58.944 *D* [event.corr         ] CorrelateEvent: event SYS_CONTAINER_AUTOUNBIND id 13404393 source netxms [11199]
2021.01.11 11:02:58.944 *D* [event.corr         ] CorrelateEvent: finished, rootId=0
2021.01.11 11:02:58.944 *D* [client.session.0   ] Sending message CMD_POLLING_INFO (120 bytes)
2021.01.11 11:02:58.944 *D* [client.session.0   ] Message dump:
  ** 000000 | 00 5A 50 00 00 00 00 78 00 00 00 17 00 00 00 02 | .ZP....x........
  ** 000010 | 00 00 00 1C 00 00 00 00 00 00 00 17 00 00 00 00 | ................
  ** 000020 | 00 00 00 6C 07 00 00 00 00 00 00 4B 46 69 6E 69 | ...l.......KFini
  ** 000030 | 73 68 65 64 20 63 6F 6E 66 69 67 75 72 61 74 69 | shed configurati
  ** 000040 | 6F 6E 20 70 6F 6C 6C 20 66 6F 72 20 6E 6F 64 65 | on poll for node
  ** 000050 | 20 72 30 32 2D 62 72 69 73 62 61 6E 65 2E 6E 61 |  r02-brisbane.na
  ** 000060 | 73 2E 6E 61 73 61 75 73 74 72 61 6C 69 61 2E 63 | s.<stripped-out>.c
  ** 000070 | 6F 6D 2E 61 75 0D 0A 00                         | om.au...
  ** code=0x005A (CMD_POLLING_INFO) version=5 flags=0x0000 id=23 size=120 numFields=2
  ** 000000: [    28] INT32       23
  ** 000010: [   108] UTF8-STRING "Finished configuration poll for node r02-brisbane.<stripped-out>.com.au
"

2021.01.11 11:02:58.944 *D* [client.session.0   ] Sending message CMD_POLLING_INFO (96 bytes)
2021.01.11 11:02:58.944 *D* [client.session.0   ] Message dump:
  ** 000000 | 00 5A 50 00 00 00 00 60 00 00 00 17 00 00 00 02 | .ZP....`........
  ** 000010 | 00 00 00 1C 00 00 00 00 00 00 00 17 00 00 00 00 | ................
  ** 000020 | 00 00 00 6C 07 00 00 00 00 00 00 2F 4E 6F 64 65 | ...l......./Node
  ** 000030 | 20 63 6F 6E 66 69 67 75 72 61 74 69 6F 6E 20 77 |  configuration w
  ** 000040 | 61 73 20 6E 6F 74 20 63 68 61 6E 67 65 64 20 61 | as not changed a
  ** 000050 | 66 74 65 72 20 70 6F 6C 6C 0D 0A 00 00 00 00 00 | fter poll.......
  ** code=0x005A (CMD_POLLING_INFO) version=5 flags=0x0000 id=23 size=96 numFields=2
  ** 000000: [    28] INT32       23
  ** 000010: [   108] UTF8-STRING "Node configuration was not changed after poll
"

2021.01.11 11:02:58.944 *D* [poll.conf          ] Finished configuration poll for node r02-brisbane.<stripped-out>.com.au (ID: 1784)
2021.01.11 11:02:58.944 *D* [event.proc         ] EVENT SYS_CONTAINER_AUTOUNBIND [65] at {0} (ID:13404393 F:0x0001 S:0 TAGS:"") FROM netxms: Node r02-brisbane.<stripped-out>.com.au automatically unbound from container All Routers
2021.01.11 11:02:58.945 *D* [client.session.0   ] Sending compressed message CMD_EVENTLOG_RECORDS (224 bytes)
2021.01.11 11:02:58.945 *D* [event.policy       ] EPP: processing event 13404393
2021.01.11 11:02:58.945 *D* [client.session.0   ] Sending message CMD_POLLING_INFO (32 bytes)
2021.01.11 11:02:58.945 *D* [client.session.0   ] Message dump:
  ** 000000 | 00 5A 50 00 00 00 00 20 00 00 00 17 00 00 00 01 | .ZP.... ........
  ** 000010 | 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 00 | ................
  ** code=0x005A (CMD_POLLING_INFO) version=5 flags=0x0000 id=23 size=32 numFields=1
  ** 000000: [    28] INT32       0

2021.01.11 11:02:58.945 *D* [client.session.0   ] Message dump:
  ** 000000 | 00 0C 50 40 00 00 00 E0 00 00 00 00 00 00 00 0F | ..P@............
  ** 000010 | 00 00 01 80 78 DA 63 60 60 58 C7 00 01 8C 50 FA | ....x.c``X....P.
  ** 000020 | 12 33 90 10 00 62 26 A8 00 C3 99 8E 97 02 08 79 | .3...b&........y
  ** 000030 | 47 06 88 3C 58 3A FE F7 E2 43 50 3E 33 44 5A 7B | G..<X:...CP>3DZ{
  ** 000040 | 3F 94 CF 02 35 87 95 1D 22 11 E5 97 9F 92 AA 50 | ?...5..."......P
  ** 000050 | 64 60 A4 9B 54 94 59 9C 94 98 97 AA 97 97 58 0C | d`..T.Y.......X.
  ** 000060 | C2 89 A5 C5 25 45 89 39 99 89 7A C9 F9 B9 7A 89 | ....%E.9..z...z.
  ** 000070 | A5 0A 89 A5 25 F9 B9 89 25 99 C9 89 39 39 95 0A | ....%...%...99..
  ** 000080 | A5 79 49 F9 A5 79 29 0A 69 45 F9 B9 0A C9 F9 79 | .yI..y).iE.....y
  ** 000090 | 25 89 99 79 A9 45 0A 8E 39 39 0A 41 F9 A5 25 A9 | %..y.E..99.A..%.

Victor Kirhenshtein

Hi,

this is caused by introduction of boolean type in NXSL. If you change

if ($node->isRouter == 1)

to

if ($node->isRouter)

it will work correctly. As those attributes are boolean by nature and all our examples use only second form we didn't expect that they are used with == operator (and == 1 was unreliable anyway because it could have happen to be any non-zero number).

Best regards,
Victor


normalcy

Thanks Victor, I guess thats a "$node->isPrinter != TRUE" for excluding printers that for some reason also get classified as routers too?

Victor Kirhenshtein

Preferably you should use


not $node->isPrinter

or

!$node->isPrinter


although your form will work too, because isPrinter will contain boolean value TRUE or FALSE, and if it is false then isPrinter != TRUE will produce expected result.

Best regards,
Victor