Tranform and Condition Scripts
-
Hi Guys,
I was wondering if anyone could share a non-trivial script for the DCI transform or the condition.
Based on the formal declaration of NXSL i can only get basic expressions and function calls to work. If i define a function or use any if, switch statements the script seems to not function.I imagine that i must be doing something wrong but any help would be appreciated.
For example in the condition script i'm trying to do something like:
if ($1>5) return min($2, $3);
Another issue i've encountered is using the PDH.countervalue for data collection. This seems to work fine for some counters but not others.
I tried: '\Memory\Committed Bytes' and this seems to work just fine
but when i tried
'\PhysicalDisk(_Total)\Disk Write Bytes/sec' this always returns 0.if anyone can shed some light on this, that would great.
-mike
-
Hello!
If you write non-trivial scripts (i.e. something more than single expression like $1/1024) you should define main() function. So you script should looks like this:
sub main()
{
if ($1>5) return min($2, $3);
}btw, you should return something also in case when $1>5 is false, so final form will be
sub main()
{
if ($1>5)
return min($2, $3);
return 0; // Or any other default value
}Best regars,
Victor -
@jdlds said in Tranform and Condition Scripts:
Another issue i've encountered is using the PDH.countervalue for data collection. This seems to work fine for some counters but not others.
I tried: '\Memory\Committed Bytes' and this seems to work just fine
but when i tried
'\PhysicalDisk(_Total)\Disk Write Bytes/sec' this always returns 0.if anyone can shed some light on this, that would great.
Some counters (like physical disk counter you mention or CPU utilization counters) requires at least two samples to be taken to calculate value. Such counters should be polled in background by agent. To configure agent to do so, use Counter parameter in WinPerf section, like below:
*WinPerf
Counter = DiskWriteBytes:"\PhysicalDisk(_Total)\Disk Write Bytes/sec":60:A:INT:Average number of bytes per second written to disk for last minuteThere are several fields separated by colons (:). First is the name for new parameter (DiskWriteBytes in our example); second is counter path; third is number of samples to calculate average value - minimum is 2, and in our example it's 60 (because we need average value for last minute); fourth field is a collection class - it can be either A (collect values every second), B (collect values every 5 seconds), or C (collect values every 30 seconds); fifth field is a data type - it's only a hint for "select parameter" dialog in console and is not used by agent; and sixth field is a parameter description which will be shown in parameter selection dialog.
After you define your new counter, you can access new parameter on agent by using name specified in the first field.
Best regards,
Victor -
-
Yes, you can use extended form of PDH.CounterValue:
PDH.CounterValue("counter name",1)
If second argument is present in PDH.CounterValue and set to non-zero, then agent will get two samples with 1 second interval, and use them to calculate resulting value.
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