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. Automatic Rule for process name in SNMP table

Automatic Rule for process name in SNMP table

Scheduled Pinned Locked Moved Support
3 Posts 2 Posters 27.6k 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.
  • D
    D
    dkoppenhagen
    wrote on last edited by
    #1

    Hey guys,

    I am using the following rule automatic rule to add a template if a specific SNMP values has been found:

    transport = CreateSNMPTransport($node);
    if (transport == null) {
        return false;
    }
    
    value = SNMPGetValue(transport, ".1.3.6.1.2.1.25.4.1.0");
    if (value == null) {
        return false;
    }
    else {
        return true;
    }
    

    This works so far pretty well.

    But now I have some device where I want to check if specific processes are running on it.
    I want to check via SNMP thecomplete hrSWRunTable (.1.3.6.1.2.1.25.4.2) if there is a process with a specific name (hrSWRunName has the OID .1.3.6.1.2.1.25.4.2.1.2).

    So maybe I have to get all values form the tabel and then iterate over the entries and compare them. But I don't know how.

    Do you have an idea how I should adjust my rule to find out if the process is running?
    Maybe there is a better solution?

    Btw: I am using NetXMS Version 2.0.7.

    Thanks in advance guys.

    Best regards,
    Danny

    1 Reply Last reply
    0
    • D
      D
      dkoppenhagen
      wrote on last edited by
      #2

      Okay- I just solved my own problem.
      In case somebody wants to do something similar (or maybe for the docs) here is how I solved this:

      process = "My-Running-SW-In-The-hrSWRunTable.exe"; // defines process name for lookup
      
      // Create SNMP transport for node
      transport = CreateSNMPTransport($node);
      if (transport == null) {
        return false;
      }
      
      // walk over running software processes
      // .iso.org.dod.internet.mgmt.mib-2.host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunName
      vars = SNMPWalk(transport, ".1.3.6.1.2.1.25.4.2.1.2");
      if (vars == null) {
        return false;
      }
      
      found_process = false; // set flag initially to false
      
      // find process, set flag and break loop if process found
      foreach (v: vars) {
        if(v->value == process) {
          trace(1, "SNMP WALK; Search for process: ".process."; Found: ".v->name."=".v->value);
          found_process = true;
          break;
        }
      }
      
      if (found_process == true) {
        return true; // process has been found
      } else {
        return false; // process has not been found
      }
      

      Best regards,
      Danny

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

        Just one comment: code block

        if (found_process == true) {
          return true; // process has been found
        } else {
          return false; // process has not been found
        }
        

        could be replaced with simple

        return found_process;
        

        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