Unsolved
This post is more than 5 years old
20 Posts
0
8565
ASL script question
Hi,
I would like to make multiple queries for data using ASL and was wondering how I do this ASL.
Example:
I would like to extract all routers and then all cards associtaed with each of the routers.
Thanks in advance
James
I would like to make multiple queries for data using ASL and was wondering how I do this ASL.
Example:
I would like to extract all routers and then all cards associtaed with each of the routers.
Thanks in advance
James
mikesolec
13 Posts
0
May 11th, 2011 07:00
Also this one, when i lookup for switches, it only worked for two devices and got the error, so it won't continue extracting the switch devices
C:\InCharge8\SAM\smarts\bin>sm_adapter -s PLDT-IS-OPSUPP-AM-PM-V8 SmartsInventor
yReport-Detailed.asl
Server PLDT-IS-OPSUPP-AM-PM-V8 User: admin
admin's Password: XXXXXXXX
Device Name,Device Type,SNMPAddress,Vendor,Model,Quan IPs,Quan Net Adapters,Seri
alNumber
S-RCB_4F_Cisco2960_ISNet-06,Switch,10.2.240.20,CISCO,2960G-24TC,1,25,Serial#:FOC
1311Z4AW
S-MGO_10F_Cisco2960_ISNet-05,Switch,10.3.16.5,CISCO,2960G-24TC,1,25,Serial#:FOC1
311Z4JG
[12-May-2011 12:10:36 AM+821ms AUS Eastern Standard Time] t@2420 main
ASL-W-ERROR_RULE_SOURCE-While executing rule set
'C:\InCharge8\SAM\smarts\bin\SmartsInventoryReport-Detailed.asl'
ASL-ERROR_ACTION-While executing action at:
ASL-CALL_STACK_RULE- RuleName: START, Line: 15
ASL-ERROR_GET-While attempting to get property 'SerialNumber' of object '::'
SVIF-EREMOTE-MR-E-CLASS_NOT_FOUND-Class of given name '' not found; in file
"t:/DMT-9.0.0.X/1304/smarts/repos/mr/dyn_acc.c" at line 1632
.
mikesolec
13 Posts
0
May 17th, 2011 02:00
Im getting syntax error somewhere else..need help. thanks
START {
.. eol
} do {
//print("Device Name,SerialNumber,Model,IP Address,Location,Owner");
foreach devName (getInstances("UnitaryComputerSystem")) {
routerObj = object(router);
switchObj = object(switch);
if (!routerObj->isNull()) {
if (!switchObj->isNull()) {
devObj = object(devName);
dev_test = object(devObj->SystemPackagedIn);
if (!dev_test->isNull()){
print(devObj->DisplayName."|".dev_test->SerialNumber."|".devObj->Model."|".devObj->SNMPAddress."|".devObj->Location."|".devObj->PrimaryOwnerName);
}
}
}
towczaruk
12 Posts
0
May 17th, 2011 02:00
you can get devices from
UnitaryComputerSystem
and check with if statement Routers and Switches
Regards
Tomasz
towczaruk
12 Posts
0
May 17th, 2011 02:00
it's wrong
simply you can use twice foreach for routers and switches
sometching like this, you have to check it
foreach devName (getInstances("Router")) {
devObj = object(devName);
dev_test = object(devObj->SystemPackagedIn);
if (!dev_test->isNull()){
print(devObj->DisplayName."|".dev_test->SerialNumber."|".devObj->Model."|".devObj->SNMPAddress."|".devObj->Location."|".devObj->PrimaryOwnerName);
}
}
}
foreach devName (getInstances("Switch")) {
devObj = object(devName);
dev_test = object(devObj->SystemPackagedIn);
if (!dev_test->isNull()){
print(devObj->DisplayName."|".dev_test->SerialNumber."|".devObj->Model."|".devObj->SNMPAddress."|".devObj->Location."|".devObj->PrimaryOwnerName);
}
mikesolec
13 Posts
0
May 17th, 2011 02:00
Hi Tomasz,
thanks i got it working now. however, i am running two scripts one for router and one for switch. Can i just integrate it in one script and one output CSV file?
Dunno how.
regards,
MikeC
mikesolec
13 Posts
0
May 17th, 2011 03:00
Thank you very much Tomasz! Kudos to you.
cheers,
Mike C
towczaruk
12 Posts
0
July 11th, 2011 01:00
Hi.
I think for this report you can use perl scripts, perl has the same functionality as ASL.
You can specyfy specyfy your own file with serial numbers for some devices.
and router hasn't serial number you can only check
if (someObj->isNull()){
print("abcdef");
serialnumber="abcdef";
}
or
if (someObj == ""){
print("abcdef");
serialnumber="abcdef";
}
But I think that in perl it's more simple to create some reports.
Regards
Tomasz
mikesolec
13 Posts
0
July 11th, 2011 01:00
Hi Tomasz,
I am currently getting some serial numbers but not all, what if i want to manually print from the extracts the serial numbers that are empty
for example, if router a has no serial number, print abcdef for the output of the CSV file.
thanks
Mike C
Hemulll
138 Posts
0
July 12th, 2011 23:00
Hello Mike,
U can use asl hook file. for example "rules/ics/dxa-sample-hook.asl"
1) U should to reserv some of Userdefined fields
2) in Hook file insert syslocation of device ti Userdefined field
3) Activate Hook script in Global Manager Administration Console
4) Add userdefined field to notification log
Example of hook file.
Note: code not tested
Enjoy
Message was edited by: Hemulll
mikesolec
13 Posts
0
July 12th, 2011 23:00
Thanks Tomasz,
Any idea how to customize the column field in the notification log console? I want to add the syslocation and Sysowner in the field.
Where can i do that in SAM?
thanks
Mike C
mikesolec
13 Posts
0
July 13th, 2011 00:00
Thanks Hemull,.
However, I am getting syntax error at line 12 next token is ". Any idea where the syntax error is? Sorry am a newbie at ASL.
thanks again
Mike C
HHE1
13 Posts
0
May 15th, 2014 10:00
I'm sorry to stretch this further, but if a thread on this already exists I did not want to recreate a double/new one if it is related...
My idea was to print all devicenames, with their SNMPaddress. As today there are a lot of VSSC (virtual devices) in my repos, I'm confonted with virtual instances. Those specific virtual instances get the SNMPAddress value as they are layered over physical instances.
So I'm facing also ASL-ERROR_GET but cannot test it on an IsNull-value:
ASL-ERROR_GET-While attempting to get property 'SNMPAddress' of object 'MR_Object::VSSC-cicswbeaas001
SVIF-EREMOTE-Remote error occurred. See exception chain for detail.
MR-NON_SINGLETON_SET-Set operation produced a set which is not a singleton
Tried matching:
foreach d ( getInstances("UnitaryComputerSystem") ) {
dev=object(d);
test=object(dev->SNMPAddress);
matcher=" ";
if (test!=matcher){
print(dev->SystemName.",".dev->SNMPAddress);
}
}
Without success. Am also not a pro in asl... ;-)
PaulORourke
170 Posts
0
May 28th, 2014 08:00
Hi HHE,
How about the following code, does this work correctly for you?
foreach d ( getInstances("UnitaryComputerSystem") ) {
dev=object(d);
if (glob("*unknown*",dev->SNMPAddress)) {
stop();
}
print(dev->SystemName.",".dev->SNMPAddress.",".dev->Description);
}
Kind Regards,
Paul O'Rourke
HHE1
13 Posts
0
June 12th, 2014 07:00
Hello Paul,
Have been checking this based on your reaction, but still getting " ASL-ERROR_GET-While attempting to get property 'SNMPAddress' of object 'MR_Object::VSSC-cicswbeaas001/1'"
" ASL-CALL_STACK_RULE- RuleName: START, Line: 8" which is the closing bracket after stop();
The skip or ignore of the SNMPAddress field still doesn't work. This value is to me difficult to handle.
PaulORourke
170 Posts
0
June 26th, 2014 01:00
Sorry for the delay HHE.
Please find solution below.
I have tested this in my lab and it appears to be working correctly (skipping VSSC instances):
START {
.. eol
}
do{
foreach d ( getInstances("UnitaryComputerSystem") ) {
dev=object(d);
if (glob("*VSSC-*",dev->Name)) {
print("Skipped: ".dev->Name);
}
else {
print("Matched: ".dev->SystemName.",".dev->SNMPAddress.",".dev->Description);
}
}
}