Is there any way by which the flat files can be read from the ASL files? I need to read the data realtime from the flat file and need to do the processing based on the contents.
I remember that a driver can be written for the same however I am not recollecting the complete procedure.
please give use more information. To read from a file in an ASL script, you can use sm_adapter (--file or --tail depending of your need), but maybe you want to do this in an existing ASL script (discovery or so ...) ?
--Fred
== Monitor your Smarts environment using APG ReportPack for Smarts health == Frederic Meunier Solutions Watch4Net Inc APG & Smarts InCharge integration http://www.watch4net.com
How can we read a file from an ASL file, other than using --file option.
Because, to use the --file option, the asl file has to run as follows
sm_adapter --file=
But consider a scenario, that I need to handle a trap which uses an ASL file to process it. This ASL has to read another flat file to fetch some data to process the trap. Could you please advice how can we call or how can we fetch the data from another flat file from the ASL file?
Unfortunately, this is not a scenario supported in Smarts. If you have to use file contents in trap processing, you need to load the file contents into the memory first so that you can access it while processing the traps. EMC suggests (used to?) using GA_StringDictionary class to store this type of data.
This is also true if you want to process data from any external source such as a database, etc. If loading the data into GA_StringDictionary workaround is not an option, you're left with developing an external adapter using perl/java API.
Regards, Berkay Mollamustafaoglu http://www.ifountain.com Ph: +1 (571) 766-6292 mberkay on yahoo, google and skype
I second Berkay. He is right. And in general, and IMHO, it is better to have a kind of a cache (GA_...) to process traps and not having to parse a file each time a trap does enter (what if a trap storm ...). The GA_StringDictionnary is still available for update anytime.
But could you please advice, how this asl files are fetching the details from the conf files?
For eg: ic-topomanager.asl file in AM Domain is fetching details from other conf files, discovery-init.asl file is fetchign details from other external files. But being honest, I didnt understand how they work as I dont have much experience in writing ASL codes.
The GA_StringDictionary is a simple hash table (key value pair) and not really suitable for wildcard searches by itself. That said, the "keys" attribute is a list of the keys. You could check each key using a glob pattern or "stringify" the set of keys and glob against that to see if the key exists. The latter would be quicker, but probably won't help you get the *specific* key that matches without going through the list.
Simplistically (and probably not great performance) it would look like this:
Well, I just thought I could also supply an example of how to read a file without using the GA_StringDictionnary class. I have used similar scripts more than once with my applications, although I commonly use it to read files located in remote SMARTS domains (if that is you case, please contact me for another example).
Below, you can find an example of file reading and parsing using two ASL scripts. The first one "Test.asl" calls the "FileReader.asl" script to get the contents of the file "test.csv" and parse its results.
These posts have really helped but I still have an issue reading in data if anyone is able to assist.
The last post by Isabelle works for me but as mentioned is not the best solution for larger datasets in SMARTS, the use of GA_StringDictionary and the example by Arun has the following errors when executed like this:-
[December 3, 2015 3:42:24 PM GMT +628ms] t@2107602720 adapter ASL-E-ERROR_RULE_INIT-While initializing rule set ASL-ERROR_FILE_PARSE-While parsing rules in file '/apps/InCharge/SAM/smarts/local/rules/icoi-trapd/main_script.asl' ASL-ERROR_YACC_ERROR-Parsing error: 'syntax error at line 29, next token is '''
line 29 in the main script is the last line [stop();], my code is a cut & paste of Arun's example, the readfile.asl I am suing is also a cut & paste and just 2 lines long, i.e.
FredericMeunier_0588be
143 Posts
2175
1
Posted December 29th, 2009 11:00
Hi Gopal,
please give use more information. To read from a file in an ASL script, you can use sm_adapter (--file or --tail depending of your need), but maybe you want to do this in an existing ASL script (discovery or so ...) ?
--Fred
== Monitor your Smarts environment using APG ReportPack for Smarts health ==
Frederic Meunier
Solutions Watch4Net Inc
APG & Smarts InCharge integration
http://www.watch4net.com