rex007can
1 Copper

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

Jump to solution

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?

Labels (1)
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
rex007can
1 Copper

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

Jump to solution

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; }

}

0 Kudos
1 Reply
rex007can
1 Copper

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

Jump to solution

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; }

}

0 Kudos