Transforming a value to string to use in custom error message

Started by DanG, January 17, 2012, 01:43:38 PM

Previous topic - Next topic

DanG

Current I report the current value of the DCI using the %<currentValue>
For the ServiceCheck.HTTP the value can be 0 to 3.
I would rather have a textual description instead of the numerical value. I thought of using a the transformation script but this will change the type from int to string which cannot be graphed.
Another place where I could do this is in the filtering script where CUSTOM_MESSAGE can be set.

sub main()
{
CUSTOM_MESSAGE = "";

if($1->value == 2)
{
   CUSTOM_MESSAGE = "cannot connect to server";
}
else
if($1->value == 3)
{
   CUSTOM_MESSAGE = "content of does not match";
}

  return true;
}

How do I test the "value" within the filtering script ($1->value above does not work of course) ?
Or maybe there's a better solution?

Regards,

Dan

Victor Kirhenshtein

Hi!

I would suggest calling a script from macro, like this:

1. Create script called "ServiceStateName" in script library:

state = GetEventParameter($event, "currentValue");
switch(state)
{
   case 0:
      return "OK";
   case 1:
      return "error in parameters";
   case 2:
      return "cannot connect to server";
   case 3:
      return "content of does not match";
}
return "UNKNOWN";


2. Use %[ServiceStateName] instead of %<currentValue>

Best regards,
Victor

DanG

Hi Victor,

Your solution is elegant and works like a charm. Tanks!

Kind regards,

Dan