Start a Conversation

Unsolved

This post is more than 5 years old

S

1263

June 4th, 2009 05:00

ASL filter question

Hi,

I am pulling out the Description via ASL and want to only print data using comma's as the FS.

How do a go about doing this, I have tried substring but it is not working as expects, I am looking for an awk type print statement

example:

awk -F"," {print $1" "$2}'

ASL code I am using:

START {
}
do {
// get list of all nodes
//
nodes = getInstances("ICIM_UnitaryComputerSystem");
//
// go through list of nodes
//
foreach node ( nodes ) {
or = object(node);
de = or->DiscoveryErrorInfo?IGNORE;
model = or->Model?IGNORE;
desc = or->Description?IGNORE;
newdesc = substring(desc,33,43);
if ( glob( 'SWFE-E-ELOOP-Agent*', de) ) {
print(node." ".model." ".newdesc);
}
}
//
stop();
//
}


Kind Regards
J

20 Posts

June 4th, 2009 06:00

Hi,

RAW Data:

test.uk.com 2801 Cisco IOS Software, 2800 Software (C2800NM-IPBASEK9-M), Version 12.4(8c), RELEASE SOFTWARE (fc3)\X0D\X0ATechnical Support: http://www.cisco.com/techsupport\X0D\X0ACopyright (c) 1986-2006 by Cisco Systems, Inc.\X0D\X0ACompiled Mon 11-Dec-06 22:06 by prod_rel_team

Required format:

test.uk.com 2801 Version 12.4(8c)


So I want to split the 3 data field using comma's so I only print out the version of IOS.

Kind Regards
J

June 4th, 2009 06:00

Hi,

can you be a little more specific, I'm not sure to understand what you want to achieve. Give us a sample of an entry and how you want to process it.

Thanks,

--Fred

2 Intern

 • 

138 Posts

June 4th, 2009 07:00

Hi,
START {
}
do {
// get list of all nodes
//
nodes = getInstances("ICIM_UnitaryComputerSystem");
//
// go through list of nodes
//
foreach node ( nodes ) {
or = object(node);
de = or->DiscoveryErrorInfo?IGNORE;
model = or->Model?IGNORE;
desc = or->Description?IGNORE;

//newdesc = substring(desc,33,43);
xDescr = CONC(desc );
if ( glob( 'SWFE-E-ELOOP-Agent*', de) ) {
print(node." ".model." ".xDescr );
}
}
//
stop();
//
}
CONC(data) {
input = data;
delimiter = ",";
one:word Cisco .. fs .. fs two:word fs eol
}
do {
newDescr = one.two;
return newDescr;
}



Sorry, but have no time for test it.

20 Posts

June 4th, 2009 07:00

Hi,

Would that work for the ASL code I used above, I am not using an input file , I am querying the topology and then want to format the data.

Kind Regards
J

2 Intern

 • 

138 Posts

June 4th, 2009 07:00

Hi,
START {
}
do {
// get list of all nodes
//
nodes = getInstances("ICIM_UnitaryComputerSystem");
//
// go through list of nodes
//
foreach node ( nodes ) {
or = object(node);
de = or->DiscoveryErrorInfo?IGNORE;
model = or->Model?IGNORE;
desc = or->Description?IGNORE;

//newdesc = substring(desc,33,43);
xDescr = CONC(desc );
if ( glob( 'SWFE-E-ELOOP-Agent*', de) ) {
print(node." ".model." ".xDescr );
}
}
//
stop();
//
}
CONC(data) {
input = data;
delimiter = ",";
one:word Cisco .. fs .. fs two:word fs .. eol
}
do {
newDescr = one.two;
return newDescr;
}



Sorry, but have no time for test it.

2 Intern

 • 

138 Posts

June 4th, 2009 07:00

use rule

CONC(data) {
input = data;
delimiter = ",";
one:word Cisco .. fs .. fs two:word fs eol
}
do {
newDescr = one.two;
return newDescr;
}

Not tested

30 Posts

June 5th, 2009 06:00

If you wnat to get out the version you can use the following function. It does only work for CISCO devices. ;-)

GET_VERSION(descr) {
local outList = list();
input = descr;
do{}
rep( aInfo:{rep(notany(","))?} ","
do {
outList += aInfo;
}
)
}do{
return outList[2];
}


Regards,
Christian

20 Posts

June 8th, 2009 02:00

Hi Christian,

How do you call this function as I have tried that code and have searched the ASL scripting guide and cannot find an example of how to call that function on a list of devices.

Kind Regards
J

13 Posts

June 16th, 2011 23:00

Hi Guys,

I   need help on the syslog adapter my hook script,  i am putting this   entries and im getting a syntax error, got it from the thread

https://community.emc.com/message/550910

My   goal is also to get the severity of the Cisco syslogs that extracts   betwwen the "-" in any order. DO you have a sample hook script and   syslog mgr asl that i can look at? thanks

*May  1 22:12:13.243: %SEC-6-IPACCESSLOGP:

LEVELS {
     input=MESSAGE;
     pre:rep(notany("-")) "-"
     levels:integer ..eol
} do {
     return levels;
}

And for setting the severity:

CUSTOM_RULE {
    unusedPrefix:rep(notany(":")) ":"           /* consume chars up to : */
    msgDescription:rep(word) eol
} do {
     sysloglevel = LEVELS();
       if (sysloglevel == "1") {
              SEVERITY = "1";
       } else if (sysloglevel == "2") {
             SEVERITY = "1";
       } else if (sysloglevel == "3") {
             SEVERITY = "2";
       } else if (sysloglevel == "4") {
             SEVERITY = "3";
       } else if (sysloglevel == "5") {
             SEVERITY = "5";
       } else if (sysloglevel == "6") {
             SEVERITY = "5";
       } else if (sysloglevel == "7") {
             SEVERITY = "5";
       }
     if (debug) { print(time().ASLNAME."Executing CUSTOM_RULE");}
}

No Events found!

Top