using DCI attributes within transformation script

Started by gkaudewitz, October 11, 2012, 05:29:15 PM

Previous topic - Next topic

gkaudewitz

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

SKYnv


gkaudewitz

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.

SKYnv

#3
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 
        }
    }
  }
}

gkaudewitz

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.

SKYnv

#5
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
how get snmp y see in my script.
i'm recomend write script in script library and using functions with "use" operator.

gkaudewitz

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!

SKYnv

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.

gkaudewitz

Is the $dci object added in final version of 1.2.4?

Victor Kirhenshtein

Yes, it is available in 1.2.4.

Best regards,
Victor

SKYnv

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