Start a Conversation

This post is more than 5 years old

Solved!

Go to Solution

769

May 15th, 2014 10:00

Simple ASL question... with no apparent simple answer...

We receive a trap from a system.

We want the alert raised on a system name contained in varbind3

So far so good,

Varbind3 consists of multiple lines.

The line we are looking for contains:

Client: NAMEOFCLIENT

In  ASL we try to extract the name by doing the following:

START {

  input = V3;

  dummy1:{.."Client: "}

  client:{.."\n"}

  dummy2:{..eol}

}

do {

//    print("\n\nFound client=" . client);

  ELEMENTNAME = client;

  INSTANCENAME = client;

  SYSNAMEORADDR = client;

  ELEMENTCLASSNAME = "Host";

  V7 = client;

  SYSNAMEORADDR = client;

    print("ELEMENTNAME=" . ELEMENTNAME);

    print("INSTANCENAME=" . INSTANCENAME);

    print("SYSNAMEORADDR=" . SYSNAMEORADDR);

    print("V7=" . V7);

   return;

This is where it gets messy!

Client is now NAMEOFCLIENT/n

The issue is, we are unable to figure out HOW to remove the stupid carriage return or new line symbol from the variable! And we cannot NOT include it.

ASL doesn't contain a trim function. It would be EASY for us to remove any number of leading characters, but there's no way to remove trailing characters that we can find!

HOW is that done??? SIMPLY! Without having to write 50 lines of code?

3 Posts

May 15th, 2014 12:00

Did it...

START {

  input = V3;

  dummy1:{.."Client: "}

  client:{.."\n"}

  dummy2:{..eol}

do {

VX = client;

varlist = SPLIT(VX, "\n");

foreach v (varlist) { print(v);

client = v; }

}

}

SPLIT(str, delimiter) {

        input = str;

        delim = "";

        local var;

        local vars = list();

        rep(

{

var: { .. delimiter }

do { vars += substring(var, 0, sizeof(var)-sizeof(delimiter)); }

} | {

var: rep(word | fs)

do { vars += var; }

}

)?

do { return vars; }

}

No Events found!

Top