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. snmp

snmp

Scheduled Pinned Locked Moved Support
4 Posts 2 Posters 33.0k 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.
  • J
    J
    jamesof
    wrote on last edited by
    #1

    i have this is in config->scripting library
    script name : test

    sub main()
    {
      return ret = SNMPSet("2c", .1.3.6.1.2.1.25.1.6.0, 10);
    if (!ret)
    {
        trace(1,"SNMPSet failed");
        return -1;
    }

    }

    and when trying to execute it from console it says
    error : script test not found .
    what should i do?
    and is it enough for snmp set? isn't it necessary to install net-snmp?

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

      Your script has syntax error, and so it not compiles. Because of that you got "script not found" message (not very meaningful in this case, I agree). Besides that, it has other errors. First of all, you have to create SNMP transport object for node you want to query, and then use it in SNMPGet function. Below is an example of script which can be run from server's debug console to get SNMP object ID from node passed as parameter:

      if ($1 == null)
      {
         println "Please specify node name as parameter";
         return 3;
      }
      
      transport = CreateSNMPTransport(FindObject($1));    // Create SNMP transport for node
      if (transport == null)
      {
          println "Failed to create SNMP transport, exit";
          return 1;
      }
      
      value = SNMPGetValue(transport, ".1.3.6.1.2.1.1.1.0");
      if (value == null)
      {
          println "Failed to issue SNMP GET request";
          return 2;
      }
      else
      {
          println "System description: " . value;
          return 0;
      }
      

      Example of running this script on my test server attached.

      Best regards,
      Victor


      test_script.png

      1 Reply Last reply
      0
      • J
        J
        jamesof
        wrote on last edited by
        #3

        thanks
        but i want to set an object such as  .1.3.6.1.2.1.25.1.5.0
        is this wrong?

        if ($1 == null)
        {
          println "Please specify node name as parameter";
          return 3;
        }
        println $1;
        transport = CreateSNMPTransport(FindObject($1));   
        if (transport == null)
        {
            println "Failed to create SNMP transport, exit";
            return 1;
        }

        ret = SNMPSet(transport, ".1.3.6.1.2.1.25.1.5.0", 4);
        if (!ret)
        {
            println "failed";
            trace(1,"SNMPSet failed");
            return -1;
        }

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

          Hi!

          Script looks correct. But are you sure that .1.3.6.1.2.1.25.1.5.0 is writeable, and that community string set in NetXMS allows read/write access?

          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