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. Transformation Script execution error - Error 17

Transformation Script execution error - Error 17

Scheduled Pinned Locked Moved Support
4 Posts 3 Posters 25.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.
  • K
    K
    krazi
    wrote on last edited by
    #1

    Hello,
    I'm experiencing this error after implementing MTBF (Mean Time Between Failures) and MTTR (Mean Time To Repair) Calculation

    This is related to the "Node availability (percentage)" DCI only (other DCIs are OK):
    See attached Capture1.PNG

    Here's the error msg:
    See attached Capture3.PNG

    Here's the line of code being referred to:
    See attached Capture2.PNG

    Here's the full script:

    // This script calculates MTTR, MTBF and perAvailability parameters and stores them in custom attributes
    // Initialize some custom attributes the first time.
    // Undefined attributes are created by SetCustomAttribute function automatically
    CurrentStatus = GetDCIValue($node, FindDCIByName($node, "Status"));
    PreviousState = GetCustomAttribute($node, "PreviousState");
    if (PreviousState == null)
    { // In the first time, previous state is null
    	SetCustomAttribute($node, "PreviousState", CurrentStatus);
    	SetCustomAttribute($node, "TimeStamp", time());
    	SetCustomAttribute($node, "NumFailures", 0);
    	SetCustomAttribute($node, "TotalUptime", 0);
    	SetCustomAttribute($node, "TotalDowntime", 0);
    	return 100;
    }
    
    // From here the 2nd and subsequent times
    NumFailures = GetCustomAttribute($node, "NumFailures");
    LastTime = time() - GetCustomAttribute($node, "TimeStamp");
    
    // Status is up
    if (CurrentStatus == 0)
    {
    	if (PreviousState != CurrentStatus)
    	{   // just changed to up
    		// update mttr
    		TotalDowntime = GetCustomAttribute($node, "TotalDowntime") + LastTime;
    		mttr = TotalDowntime / ((NumFailures == 0) ? 1 : NumFailures) / 3600;   // to prevent division by ze
    		SetCustomAttribute($node, "TotalDowntime", TotalDowntime);
    		SetCustomAttribute($node, "mttr", mttr);
    	}
    	else
    	{      // still up
    		// update mtbf
    		TotalUptime = GetCustomAttribute($node, "TotalUptime") + LastTime;
    		mtbf = TotalUptime / ((NumFailures == 0) ? 1 : NumFailures) / 3600;   // to prevent division by zero
    		SetCustomAttribute($node, "TotalUptime", TotalUptime);
    		SetCustomAttribute($node, "mtbf", mtbf);
    	}
    }
    
    // Status is down
    if (CurrentStatus == 4)
    {
    	if (PreviousState != CurrentStatus)
    	{   // just changed to down
    		// update mtbf
    		NumFailures++;
    		TotalUptime = GetCustomAttribute($node, "TotalUptime") + LastTime;
    		mtbf = TotalUptime / NumFailures / 3600;
    		SetCustomAttribute($node, "NumFailures", NumFailures);
    		SetCustomAttribute($node, "TotalUptime", TotalUptime);
    		SetCustomAttribute($node, "mtbf", mtbf);
    	}
    	else
    	{   // still down
    		// update mttr
    		TotalDowntime = GetCustomAttribute($node, "TotalDowntime") + LastTime;
    		mttr = TotalDowntime / NumFailures / 3600;
    		SetCustomAttribute($node, "TotalDowntime", TotalDowntime);
    		SetCustomAttribute($node, "mttr", mttr);
    	}
    }
    
    if (CurrentStatus == 0 || CurrentStatus == 4)
    {
    	// Save previous state and timestamp
    	SetCustomAttribute($node, "PreviousState", CurrentStatus);
    	SetCustomAttribute($node, "TimeStamp", time());
    
    	// perAvailability section
    	TotalUptime = GetCustomAttribute($node, "TotalUptime");
    	TotalDowntime = GetCustomAttribute($node, "TotalDowntime");
    	perAvailability = TotalUptime / (TotalUptime + TotalDowntime) * 100;
    	SetCustomAttribute($node, "perAvailability", perAvailability);
    
    	return perAvailability;
    }
    

    Appreciate any help.
    Thanks


    Capture1.PNG

    Capture2.PNG

    Capture3.PNG

    1 Reply Last reply
    0
    • K
      K
      krazi
      wrote on last edited by
      #2

      I have added additional info to my original post as FYI.

      1 Reply Last reply
      0
      • T
        T
        Tursiops
        wrote on last edited by
        #3

        Does a DCI called "Status" exist on the node?
        I know this used to be an internal DCI that was added for any node automatically, but it isn't in newer versions.

        You may have to create a script DCI providing the result of $node->status for what you are trying to achieve.
        See https://wiki.netxms.org/wiki/NXSL:NetObj for possible values.

        1 Reply Last reply
        0
        • S
          S
          sodalist
          wrote on last edited by
          #4

          Hello,

          You can solve issue by:

          1. unbind template with SLA DCI from node
          2. delete SLA custom attributes from node
          3. on node create DCI described Status collecting Status parameter from origin Internal
          4. apply template with SLA DCI to node

          or:

          1. manually populate SLA custom attributes with values
          2. on node create DCI described Status collecting Status parameter from origin Internal

          Br, A

          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