NetXMS Support Forum

English Support => General Support => Topic started by: gkaudewitz on October 11, 2012, 05:29:15 PM

Title: using DCI attributes within transformation script
Post by: gkaudewitz on October 11, 2012, 05:29:15 PM
Hello together,

is there a way to use attributes of the current DCI within a transformationscript?

For example getting the name-attribute and building out of this an oid with an value that was requested in an other DCI.

Best regards

Georg
Title: Re: using DCI attributes within transformation script
Post by: SKYnv on October 11, 2012, 06:18:00 PM
$1 - current value (last polled)
if you want use another dci in curent dci see this http://wiki.netxms.org/wiki/NXSL_Function_Reference#Data_Collection
Title: Re: using DCI attributes within transformation script
Post by: gkaudewitz on October 12, 2012, 12:00:37 PM
Sorry but I hove to clarify the question. I want to do the following with the Transformatinscript of the DCI

I have an DCI with parameter:
.1.3.6.1.2.1.31.1.1.1.10.10201
from that parameter/name I want to build the parameter
.1.3.6.1.2.1.2.2.1.5.10201
to find the corresponding DCI by GetDCIValueByName that has requested the interface speed.
With this information I want to calculate the percentage value for the usage of the interface within the transformormationscript.
Title: Re: using DCI attributes within transformation script
Post by: SKYnv on October 12, 2012, 12:25:52 PM
mmm?

sub main()
{
  if ($node->isSNMP)
  {
   transport = CreateSNMPTransport($node);
    if (transport == null)
    {
    return -1;
    }
   
    ifspeed = SNMPGetValue(transport, ".1.3.6.1.2.1.2.2.1.5.10201"); // get if speed
   
    if (ifspeed != null)
    {
        //you can use "case/switch" if have y have many params
        if (ifspeed == "blablabla") //change blabla bla string. see mib, i don't know how it on cisco
        {
           return (($1*8)/(1 << 20)); //transform bytes to megabites
        }
        else
        {
           return $1; //return default value 
        }
    }
  }
}
Title: Re: using DCI attributes within transformation script
Post by: gkaudewitz on October 12, 2012, 02:01:01 PM
Not really what I want to do.
Within transformationscript some pseudocode now
sub main()
{
  pos = rindex(trim($dci->name),".");
  len = length(trim($dci->name)) - pos;
  port = right($dci->name,len);
  snmpoid = ".1.3.6.1.2.1.2.2.1.5.".port;
  speed = GetDCIValueByName($node,snmpoid);
  result = (($1*8)*100)/speed;
  return result;
}

the meaning of $dci in this example would be the same as with $node refering to the current DCI.
Title: Re: using DCI attributes within transformation script
Post by: SKYnv on October 12, 2012, 04:54:06 PM
Quote from: gkaudewitz on October 12, 2012, 02:01:01 PM
Not really what I want to do.
Within transformationscript some pseudocode now
sub main()
{
  pos = rindex(trim($dci->name),".");
  len = length(trim($dci->name)) - pos;
  port = right($dci->name,len);
  snmpoid = ".1.3.6.1.2.1.2.2.1.5.".port;
  speed = GetDCIValueByName($node,snmpoid);
  result = (($1*8)*100)/speed;
  return result;
}

the meaning of $dci in this example would be the same as with $node refering to the current DCI.

$dci object added in 1.2.4 dev version (http://svn.netxms.org/public/netxms/trunk/ChangeLog)
how get snmp y see in my script.
i'm recomend write script in script library and using functions with "use" operator.
Title: Re: using DCI attributes within transformation script
Post by: gkaudewitz on October 15, 2012, 05:09:29 PM
Now we have same understanding of my problem.
Thanks for the information concerning $dci.
This will simplify the tasks concerning calculation of values for me. Because I don't want generating an extra snmprequest each time the octet-value is requested.

Thanks for the help!
Title: Re: using DCI attributes within transformation script
Post by: SKYnv on October 15, 2012, 07:05:04 PM
Quote from: gkaudewitz on October 15, 2012, 05:09:29 PM
Now we have same understanding of my problem.
Thanks for the information concerning $dci.
This will simplify the tasks concerning calculation of values for me. Because I don't want generating an extra snmprequest each time the octet-value is requested.

Thanks for the help!

if portspeed is constant you can write array with each port information in the script.
Title: Re: using DCI attributes within transformation script
Post by: gkaudewitz on December 13, 2012, 06:42:26 PM
Is the $dci object added in final version of 1.2.4?
Title: Re: using DCI attributes within transformation script
Post by: Victor Kirhenshtein on December 13, 2012, 07:13:34 PM
Yes, it is available in 1.2.4.

Best regards,
Victor
Title: Re: using DCI attributes within transformation script
Post by: SKYnv on December 13, 2012, 10:46:24 PM
Quote from: gkaudewitz on December 13, 2012, 06:42:26 PM
Is the $dci object added in final version of 1.2.4?

and in 1.2.4 added multipliers for charts.

and y need only transform bytes to bites