Problem with DCI transform script

Started by dkoppenhagen, January 05, 2017, 10:48:34 AM

Previous topic - Next topic

dkoppenhagen

Hey guys,

I have a problem trying to transform a value which has been calculated from a script.
The script calculates the average CPU load over multiple CPUs.

It returns a float value (e.g. 41.34444444) which is the CPU load in percentage.
For displaying the data I want to transform this value so that it is displayed as "41.34444444 %".

Unfortunately the transformation doen't seem to work properly so in the object overview and in the view of last values I just see "41.34444444" (without "%").

Do you know what I configured wrong?

Thanks in advance.

Best regards,
  Danny


Marco Incalcaterra

Quote from: dkoppenhagen on January 05, 2017, 10:48:34 AM
Hey guys,

I have a problem trying to transform a value which has been calculated from a script.
The script calculates the average CPU load over multiple CPUs.

It returns a float value (e.g. 41.34444444) which is the CPU load in percentage.
For displaying the data I want to transform this value so that it is displayed as "41.34444444 %".

Unfortunately the transformation doen't seem to work properly so in the object overview and in the view of last values I just see "41.34444444" (without "%").

Do you know what I configured wrong?

Thanks in advance.

Best regards,
  Danny

What is shown depends on the type of the DCI, so "41.34444444 %" is no more a floating point value, so you have to set it as a string and in your transformation script you have to do something like this:

string($1)." %"

in this case $1 is the value collected, change with the result of your calculation.

Regards,
Marco

dkoppenhagen

Hi Marco thanks for your answer.

I tried this. But it's the same result. So the "Data Type" in configuration section "General" is the type of the final values which is returned after my transformation script runs on collected data? Or is this the type if the raw data which comes from my script?

Another thing is that I need a float value for displaying the values in performance tab.

I thought it's like the following:
1.) The script runs and returns value.
2.) The returned values typse is selected in "Data Type".
3.) The value is processed in performance tab.
4.) Transformation script runs over the last value.
5.) The transformed value is shown in overview and "last values" secion.

So the main problem is: I need a float for performance tab and a string for object overview.

So probably I have to leave it as it is and I change just the value description from "CPU" to "CPU (%)".

Bets regards,
Danny

Marco Incalcaterra

Quote from: dkoppenhagen on January 06, 2017, 11:54:27 AM
I tried this. But it's the same result. So the "Data Type" in configuration section "General" is the type of the final values which is returned after my transformation script
runs on collected data? Or is this the type if the raw data which comes from my script?

As per my knowledge it is the type of the final value.

Quote from: dkoppenhagen on January 06, 2017, 11:54:27 AM
So the main problem is: I need a float for performance tab and a string for object overview.

So probably I have to leave it as it is and I change just the value description from "CPU" to "CPU (%)".

Since you need the same result with different data type, I suggest to leave it as float and change the description (you won't be able to show in performance graph if it is a string). Another solution is to duplicate the DCI and keep one as string and the other as float, the DCI of type string can be shown in overview and the float in the performance tab, but honestly if you have many nodes in my opinion is a waste of resources.

Regards,
Marco