Help: Count Specific Value in DCI Table Column and Graph it

Started by radw, April 28, 2016, 11:52:23 PM

Previous topic - Next topic

radw

Hello NetXMS Support Community

I just start to work with scripts, but I cannot achieve yet the way to count the times that some value appears in a  DCI Table column: Here is the idea that I have but I cannot translate to NetXMS code:

1) From a DCI Table column, get the times that "x" value appears in that column.
2) Store the value and graph it.


Thanks.

radw

Hello NetXMS Team


In the past days I was able to write this script for counting the times a value is present in a DCI Table Column. Here are the steps Im following:

1) I arrived to this function declared in the CUBE_FUNCTIONS_1 script (I'm planning reusing this function many times):

sub CALL_ACTIVE_COUNT(CALL_ACTIVE_TABLE,CALL_ACTIVE_PEER_ID,CALL_TYPE_ID)
{
   COUNT=0;
   
   for(i = 0; i < CALL_ACTIVE_TABLE->rowCount; i++)
   {
      if (CALL_ACTIVE_TABLE->get(i,CALL_ACTIVE_TABLE->getColumnIndex(CALL_ACTIVE_PEER_ID))==CALL_TYPE_ID)
      {
         COUNT=COUNT+1;
      }   
            
   }
   
   return COUNT;
}


2) Now, in the DCI Table configuration, I used this function to count the times that value '5' is find in the selected column and return me that count:




3) Here, this is value I need to graph , but I dont know how use that value in a graph, even reading all the documentation many times.


Sorry if my posts are not completely understood at first sight, that because Im tired to trying myself the configurations many times,  reading the documentation, the forum, the videos, and not find in the moment what Im looking for, and I need that some tool (like NetXMS) could report me the SNMP metrics as fast as possible. I changed the title again to help you read my issue.


Regards.



Andreas@rc

Instead of using your script within the transformation section, why not create a DCI, which executes your script?

This way, you can use the default method for history and graphing from NetXMS.

radw

Quote from: Andreas@rc on May 02, 2016, 10:58:51 AM
Instead of using your script within the transformation section, why not create a DCI, which executes your script?

This way, you can use the default method for history and graphing from NetXMS.

Thanks for your answer. And yes, I did it yesterday and it worked.

I created first this script with the function count, so I can reuse it:




sub CALL_ACTIVE_COUNT(CALL_ACTIVE_TABLE,CALL_ACTIVE_PEER_ID,CALL_TYPE_ID)
{
COUNT=0;

for(i = 0; i < CALL_ACTIVE_TABLE->rowCount; i++)
{
if (CALL_ACTIVE_TABLE->get(i,CALL_ACTIVE_TABLE->getColumnIndex(CALL_ACTIVE_PEER_ID))==CALL_TYPE_ID)
{
COUNT=COUNT+1;
}

}

return COUNT;
}




Then I created this script as source for the DCI Configuration of my node, and thats is how I could obtain performance graphs:




use CUBE_CALL_ACTIVE_COUNT;

sub main()
{
  LOCAL_ACTIVE_CALLS=CALL_ACTIVE_COUNT(GetDCIValue($node,FindDCIByDescription($node, "CALL-ACTIVE-TABLE-1")),"CALL-ACTIVE-PEER-ID",5);

   return LOCAL_ACTIVE_CALLS;
}