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. Script DCI

Script DCI

Scheduled Pinned Locked Moved Support
6 Posts 3 Posters 39.4k 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.
  • M
    M
    MarcusH
    wrote on last edited by
    #1

    Hi,

    Is there any way to in a script that runs as DCI identify which DCI that started the script?
    I am trying to make one script for multiple DCI

    1 Reply Last reply
    0
    • M
      M
      MarcusH
      wrote on last edited by
      #2

      Changed approach, one DCI that runs script and script then push return to different push DCI

      1 Reply Last reply
      0
      • D
        D
        Dawid Kellerman
        wrote on last edited by
        #3

        Hi Marcus
        if it is possible can share the final working script as an example unless you cant remove sensitive info as an example it would be much appreciated for example purposes.
        Regards Dawid

        1 Reply Last reply
        0
        • F
          F
          Filipp Sudanov
          wrote on last edited by
          #4

          Starting from 4.1.283 there is $dci variable that contains corresponding DCI object.

          1 Reply Last reply
          0
          • M
            M
            MarcusH
            wrote on last edited by
            #5

            $dci works

            Here exemple on what i have done.

            CheckDownStatus(container objectid) loops all nodes in the container and gets latest value from DCI named Down, if any node has been down over 80 seconds it returns 80 else 0.

            All below is run on same node named PushNode, this node is trusted on all nodes since i have trusted nodes active.

            This version is run by a script DCI and pushes down value to a DCI with origin Push on PushNode

            sub CheckDownStatus(obj)
            {
              	foreach(o : obj->children) {
              		if(!o->isInMaintenanceMode)
            	  	{
            	    	downsince = GetDCIRawValue(o, FindDCIByName(o, "Down"));
            	    	if(downsince > 80)
            	    	{
            	    		return 80;
            	   	}
               	}
              	}
              	return 0;
            }
            
            // AP Zone 1
            PushDCIData($node, 3115, CheckDownStatus(FindObject("9347", $node)));
            // AP Zone 2
            PushDCIData($node, 3117, CheckDownStatus(FindObject("12216", $node)));
            

            This version returns value to the same DCI that runs it, and as stated above only works from version 4.1.283

            sub CheckDownStatus(obj)
            {
              	foreach(o : obj->children) {
              		if(!o->isInMaintenanceMode)
            	  	{
            	    	downsince = GetDCIRawValue(o, FindDCIByName(o, "Down"));
            	    	if(downsince > 80)
            	    	{
            	    		return 80;
            	   	}
               	}
              	}
              	return 0;
            }
            
            test = $dci->id;
            
            // AP Zone 1
            if(test = "3115"){ return CheckDownStatus(FindObject("9347", $node));}
            // AP Zone 2
            if(test = "3117"){ return CheckDownStatus(FindObject("12216", $node));}
            

            My reason for these is that now i have one DCI that i can monitor if any node goes down in that group. I also like having things in scripts gives me more freedom, in some cases we call action on agents like the agent that is on the PC that runs the grafana screens has an action for text2speech and that is speaking some alarms with values that needs immediate action.

            1 Reply Last reply
            0
            • D
              D
              Dawid Kellerman
              wrote on last edited by
              #6

              Thank you for a helpful write up, Marcus
              Regards Dawid

              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