Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Catching and Handling Exceptions (SNMP timeout) in NXSL instance discovery

Catching and Handling Exceptions (SNMP timeout) in NXSL instance discovery

Scheduled Pinned Locked Moved Support
4 Posts 2 Posters 23.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B
    B
    blazarov
    wrote on last edited by
    #1

    Hi,
    I have developped and been using an NXSL script for interface instance discovery using SNMP for over an year now.
    Although it is working fine it keeps on throwing alarms for script execution errors on the server node. I am pretty sure that the cause for those errors in 99% of the cases is just SNMP timeout. I have many of the monitored nodes with slow and unreliable connection so this is expected and more or less inevitable.

    So now i am looking for a way to enhance my script in a such way that it catches and handles such problems and just quietly abort until the next execution. I have looked int the documents and in the forum, but couldnt find a solution.
    Ideas anyone?

    Here is my instance discovery script:

    snmp = CreateSNMPTransport($node);
    ifName = SNMPGetValue(snmp, ".1.3.6.1.2.1.2.2.1.2." . $1);
    ifName .= " ";
    ifName .= SNMPGetValue(snmp, ".1.3.6.1.2.1.31.1.1.1.18." . $1);
    if (ifName ~= "Loopback.*") {
    	return %(false, $1, ifName);
    } else {
    	return %(true, $1, ifName);
    }
    

    Screenshot of the alarms is attached.

    Thanks in advance!


    netxms script errors.PNG

    1 Reply Last reply
    0
    • V
      V
      Victor Kirhenshtein
      wrote on last edited by
      #2

      Hi,

      just add appropriate error checking:

      snmp = CreateSNMPTransport($node);
      if (snmp == null)
         return false; // node does not support SNMP or transport cannot be created
      ifName = SNMPGetValue(snmp, ".1.3.6.1.2.1.2.2.1.2." . $1);
      if (ifName == null)
         return false; // cannot read from node
      ifXName = SNMPGetValue(snmp, ".1.3.6.1.2.1.31.1.1.1.18." . $1);
      if (ifXName != null)
      {
         ifName .= " " . ifXName;
      }
      if (ifName ~= "Loopback.*") {
      	return %(false, $1, ifName);
      } else {
      	return %(true, $1, ifName);
      }
      

      Best regards,
      Victor

      1 Reply Last reply
      0
      • B
        B
        blazarov
        wrote on last edited by
        #3

        Thanks Victor,
        I understand the logic.

        My understanding now is when the instance discovery filtering script returns False that particular instance is skipped or removed if already available. Is that true?
        If yes, does that mean that if there's a single SNMP error (eg Timeout) in a regular Instance discovery and the script returns False for that particular instance it will be deleted from the node DCI table? As it happens now if i really delete the interface from the router?

        This will be problematic, because now NetXMS immediately deletes a DCI when it detects its absense during instance discovery resulting in permanent history data loss, which is not acceptable for the bussiness. This is a feature that i have already requested in "FEature Requests" - to have the option to leave DCI's present (for example in UNSUPPORTED state) after they dissapear from instance discovery.

        I was thinking of somehow "breaking" the script in order to avoid any changes instead of returing False which will eventually result in deleting DCIs with their history data. Am i on the right track?

        1 Reply Last reply
        0
        • V
          V
          Victor Kirhenshtein
          wrote on last edited by
          #4

          Hi,

          yes, if script returns false instance will be deleted. Currently there is no way to stop instance discovery by aborting filter script.

          There is feature request for adding "grace period" for instances being deleted: https://dev.raden.solutions/issues/976. I think implementing it should solve your problem.

          Best regards,
          Victor

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          Powered by NodeBB Contributors
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups