towczaruk
6 Indium

Re: ASL script question

Ok.

It's because in some device you don't have this SystemPackagedIn

so it create null object

you should put if statement

some think like this

maybe in this case you can get serial number from other place(not from Chassis)

START {

} do {

foreach devName (getInstances("Switch")) {
devObj = object(devName);
dev_test = devObj->SystemPackagedIn;
if (!dev_test->isNull()){
print(devObj->Name.",".dev_test);
print();
} else {
print(devObj->Name);
}
}
}

and I don't know which IP addres you want to get?

Properties of Router::10.10.16.99:
                             AccessMode = ICMPSNMP
                           AggregatedBy = { }
                             Aggregates = { }
                AprioriProbability_Down = 0
                          BridgeAddress =
                  CIM_CreationClassName = Router
                        CIM_Description = Cisco Internetwork Operating System Software \X0D\X0AIOS (tm) RSP Software
(RSP-JSV-M), Version 12.0(7)T,  RELEASE SOFTWARE (fc2)\X0D\X0ACopyright (c) 1986-1999 by cisco Systems, Inc.\X0D\X
0ACompiled Mon 06-Dec-99 19:40 by phanguye
                               CIM_Name = 10.10.16.99
                               CausedBy = { }
                                 Causes = { }
                          Certification = CERTIFIED
                             ComposedOf = { Interface::IF-10.10.16.99/9 Fan::FAN-10.10.16.99/5 Interface::IF-10.10.1
6.99/5 Interface::IF-10.10.16.99/10 Fan::FAN-10.10.16.99/3 Interface::IF-10.10.16.99/7 Interface::IF-10.10.16.99/1
TemperatureSensor::TEMP-10.10.16.99/3 Fan::FAN-10.10.16.99/6 VoltageSensor::VOLT-10.10.16.99/1 Fan::FAN-10.10.16.99
/4 TemperatureSensor::TEMP-10.10.16.99/1 Fan::FAN-10.10.16.99/2 Interface::IF-10.10.16.99/8 Interface::IF-10.10.16.
99/6 Memory::MEM-10.10.16.99/1 Card::CARD-10.10.16.99/4 Interface::IF-10.10.16.99/11 Interface::IF-10.10.16.99/4 Ca
rd::CARD-10.10.16.99/2 Memory::MEM-10.10.16.99/5 VoltageSensor::VOLT-10.10.16.99/3 VoltageSensor::VOLT-10.10.16.99/
5 Interface::IF-10.10.16.99/2 Card::CARD-10.10.16.99/1 Processor::PSR-10.10.16.99/1 VoltageSensor::VOLT-10.10.16.99
/4 Fan::FAN-10.10.16.99/1 TemperatureSensor::TEMP-10.10.16.99/2 VoltageSensor::VOLT-10.10.16.99/2 Card::CARD-10.10.
16.99/3 Interface::IF-10.10.16.99/3 }
                          ComposedOfVRs = { }
                           ConfiguredBy = { Configuration::CFG-Polling Groups/Routers Configuration::CFG-System Reso
urce Groups/Host Configuration::CFG-System VLAN Tag Groups/Other Systems Configuration::CFG-System IP Tag Groups/IP
Tag Filter-1 Configuration::CFG-Device Access Configurations/CLI Access Group }
                           ConnectedVia = { IPNetwork::IPNET-10.1.64.116 NetworkConnection::LINK-IF-10.10.16.99/5<->
IF-N_Aparri/6 IPNetwork::IPNET-10.10.224.12 IPNetwork::IPNET-10.10.224.16 IPNetwork::IPNET-10.10.224.36 IPNetwork::
IPNET-10.10.224.20 IPNetwork::IPNET-10.10.224.24 IPNetwork::IPNET-10.10.224.8 IPNetwork::IPNET-10.10.224.4 IPNetwor
k::IPNET-10.10.16.0 Cable::LINK-IF-10.10.16.99/1<->PORT-10.10.16.1/1.23 NetworkConnection::LINK-IF-10.10.16.99/7<->
IF-R_Echague/2 }
                      CreationClassName = Router
                            Description = Cisco Internetwork Operating System Software \X0D\X0AIOS (tm) RSP Software
(RSP-JSV-M), Version 12.0(7)T,  RELEASE SOFTWARE (fc2)\X0D\X0ACopyright (c) 1986-1999 by cisco Systems, Inc.\X0D\X
0ACompiled Mon 06-Dec-99 19:40 by phanguye
                         DesignatedRoot =
                     DesignatedRootPort = 0
                      DiscoveredFirstAt = April 19, 2011 11:00:45 PM GMT+08:00
                       DiscoveredLastAt = May 2, 2011 6:29:58 PM GMT+08:00
              DiscoveredLastAtToSeconds = 1304332197
                     DiscoveryErrorInfo = No response from Ping
                          DiscoveryTime = 0 00:00:02
                       DisplayClassName = Router
                            DisplayName = 10.10.16.99
                                 Domain =
                         HasIPAddresses = TRUE
                       HasIPv6Addresses = FALSE
                      HostsAccessPoints = { IP::IP-10.1.64.118 IP::IP-10.10.224.13 IP::IP-10.10.224.17 IP::IP-10.10.
224.37 IP::IP-10.10.224.21 IP::IP-10.10.224.25 IP::IP-10.10.224.9 IP::IP-10.10.224.5 MAC::MAC-00-60-3E-63-A0-20 MAC
::MAC-00-60-3E-63-A0-21 IP::IP-10.10.16.99 }
                          HostsServices = { SNMPAgent::SNMPAgent-10.10.16.99 }
                     IPInstrumentations = { }
                   IPv6Instrumentations = { }
                             ImpactedBy = { }
                                Impacts = { }
                         InstrumentedBy = { }
                          IsAddressable = TRUE
                  IsDiscoveryInProgress = FALSE
                  IsEveryIPUnresponsive = TRUE
                IsEveryIPv6Unresponsive = TRUE
            IsEveryNeighborUnresponsive = FALSE
             IsEveryServiceUnresponsive = TRUE
                              IsManaged = TRUE
                          IsMightBeDown = FALSE
                                IsProxy = FALSE
                                 IsSeed = TRUE
              IsUnmanagedOrUnresponsive = TRUE
     IsUnmanagedOrUnresponsive_internal = TRUE
                         IsUnresponsive = FALSE
                IsUnresponsive_internal = FALSE
                                   KEYS = string:CIM_CreationClassName,string:CIM_Name
                            LayeredOver = { }
                ListOfHostsAccessPoints = { IP::IP-10.1.64.118 IP::IP-10.10.224.13 IP::IP-10.10.224.17 IP::IP-10.10.
224.37 IP::IP-10.10.224.21 IP::IP-10.10.224.25 IP::IP-10.10.224.9 IP::IP-10.10.224.5 MAC::MAC-00-60-3E-63-A0-20 MAC
::MAC-00-60-3E-63-A0-21 IP::IP-10.10.16.99 }
                               Location = Cabanatuan 2/F
                               MemberOf = { Partition::Partition-0/PLDT-IS-OPSUPP-AM-PM-V8 }
                                  Model = 7505
                      MonitoringEnabled = TRUE
                                   Name = 10.10.16.99
                             NameFormat = UNSPECIFIED
                     NeighboringSystems = { TerminalServer::10.10.16.153 Host::WSN-EDRCBD-02 Router::N_Cabanatuan Sw
itch::10.10.16.4 Switch::10.10.16.16 Switch::10.10.16.15 Host::NPI1092F8 Router::R_Echague Router::N_Aparri Host::N
PI1350FF Host::10.10.19.180 Host::10.10.16.5 Router::IPBB-Cabanatuan Switch::10.10.16.2 Switch::10.10.16.3 Host::NP
IF30CC2 Switch::10.10.16.1 }
                          Notifications = { }
                            NumberOfIPs = 9
                          NumberOfIPv6s = 0
                     NumberOfInterfaces = 11
                NumberOfNetworkAdapters = 11
                          NumberOfPorts = 0
                              OSVersion =
                                 PartOf = { }
                    PrimaryOwnerContact =
                       PrimaryOwnerName =
                          ReadCommunity = He890adrFR
                      ReconfiguredAfter = May 2, 2011 6:29:58 PM GMT+08:00
                       RemoveComponents = TRUE
                            SNMPAddress = 10.10.16.99
                            ServiceName =
                      SettingsAppliedBy = { IPTag_Setting::SET-CFG-System IP Tag Groups/IP Tag Filter-1/IPTag_Settin
g CLI_AccessSetting::SET-CFG-Device Access Configurations/CLI Access Group/CLI_AccessSetting NetworkAdapter_Perform
ancePolling_Setting::SET-CFG-Polling Groups/Routers/NetworkAdapter_PerformancePolling_Setting System_EnvironmentPol
ling_Setting::SET-CFG-Polling Groups/Routers/System_EnvironmentPolling_Setting GarbageCollection_Setting::SET-CFG-P
olling Groups/Routers/GarbageCollection_Setting Connectivity_Polling_Setting::SET-CFG-Polling Groups/Routers/Connec
tivity_Polling_Setting Processor_Performance_Setting::SET-CFG-System Resource Groups/Host/Processor_Performance_Set
ting FileSystem_Performance_Setting::SET-CFG-System Resource Groups/Host/FileSystem_Performance_Setting Processor_P
erformancePolling_Setting::SET-CFG-Polling Groups/Routers/Processor_PerformancePolling_Setting System_Environment_S
etting::SET-CFG-System Resource Groups/Host/System_Environment_Setting Default_Route_Polling_Setting::SET-CFG-Polli
ng Groups/Routers/Default_Route_Polling_Setting }
                 ShortDiscoveredFirstAt =
                  ShortDiscoveredLastAt =
                     ShortDiscoveryTime =
                          SourceAddress = 0.0.0.0
                           SupportsSNMP = TRUE
                             SystemName = 10.10.16.99
                         SystemObjectID = .1.3.6.1.4.1.9.1.48
                       SystemPackagedIn = Chassis::CHASSIS-10.10.16.99
                                   Type = ROUTER
                             Underlying = { }
                UseBridgingRelationship = TRUE
                                 Vendor = CISCO
               VirtualHostsAccessPoints = { }
                               indexVal =

Regards

Tomasz

0 Kudos
mikesolec
6 Indium

Re: ASL script question

Thanks, How to put the null in this script? sorry im not a progammer..but they need the information to put in the CMDB thru CSV, what we need is tha main IP address of the router , also can it be done only in one script for Router and Switch? thanks

START {
.. eol
} do {


print("Device Name,Device Type,SNMPAddress,Vendor,Model,Quan IPs,Quan Net Adapters,SerialNumber");

foreach devName (getInstances("Router")) {
devObj = object(devName);
dev_test = object(devObj->SystemPackagedIn);


print(devObj->Name.",".devObj->CreationClassName.",".devObj->SNMPAddress.",".devObj->Vendor.",".devObj->Model.",".devObj->NumberOfIPs.",".devObj->NumberOfNetworkAdapters.",".dev_test->SerialNumber);

}
}

0 Kudos
mikesolec
6 Indium

Re: ASL script question

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

0 Kudos
towczaruk
6 Indium

Re: ASL script question

you can get devices from

UnitaryComputerSystem

and check with if statement Routers and Switches

Regards

Tomasz

0 Kudos
mikesolec
6 Indium

Re: ASL script question

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

}
}
}

0 Kudos
towczaruk
6 Indium

Re: ASL script question

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

}

0 Kudos
mikesolec
6 Indium

Re: ASL script question

Thank you very much Tomasz! Kudos to you.

cheers,

Mike C

0 Kudos
mikesolec
6 Indium

Re: ASL script question

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

0 Kudos
towczaruk
6 Indium

Re: ASL script question

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

0 Kudos
mikesolec
6 Indium

Re: ASL script question

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

0 Kudos