1 2 Previous Next 20 Replies Latest reply on Mar 6, 2017 4:53 AM by Amit Agaral

    NSH Script for Server Information

    Rob Slattery

      Hello everyone,

       

      Is there a script I can run that will collect server name, and any extended property that is set?  For example, I'd like to run a script that collects information from a server smartgroup within Servers | Workareas | rob_servers and one of the properties that are set if you were to actually click on a server like, repeater_name.

        • 1. Re: NSH Script for Server Information
          richard mcleod

          This should work for you

           

          sGroup="/path/to/smartgroup"

          propertyName="REPEATER_NAME"

           

          blcli_execute Server listServersInGroup "${sGroup}"

          blcli_storeenv sList

           

          for server in $sList

          do

          blcli_execute Server printPropertyValue "${server}" "${propertyName}"

          blcli_storeenv propValue

           

          echo "Server: ${server} has ${propertyName} set to: ${propValue}"

          done

          • 2. Re: NSH Script for Server Information
            Rob Slattery

            Thanks!!  Can I actually save this as an nsh script and create a job?

            • 3. Re: NSH Script for Server Information
              richard mcleod

              i don't see why not... if you do, your target should be an appserver

              • 4. Re: NSH Script for Server Information
                Rob Slattery

                Hmmm...  I think what I'm trying to do/say, is create an output of servers within a specific smartgroup (1,500 servers) and their properties.  Right now, I only need three of the property values but in the future, it may grow (we don't have BDSSA setup to collect everything (future project) so I can't use that as an option).  I was hoping the job could run and get exported into a .csv file or something, locally to my computer since my console is local as well.

                • 5. Re: NSH Script for Server Information
                  richard mcleod

                  sGroup="/path/to/smartgroup"

                  propertyList="PROP1,PROP2,PROP3"

                  OUT_FILE=/path/tofile.csv

                   

                  blcli_execute Server listServersInGroup "${sGroup}"

                  blcli_storeenv sList

                   

                  echo "${propertyList}" > $OUT_FILE

                   

                  for server in $sList

                  do

                       for propertyName in "${propertyList}"

                       do

                            blcli_execute Server printPropertyValue "${server}" "${propertyName}"

                            blcli_storeenv propValue

                   

                            propValues="${propValues},${propValue}"

                       done

                  echo "${server}${propValues}" >> $OUT_FILE

                  done

                   

                   

                  Also -- BDSSA can collect property values simply by using the property editor and checking the used in reports flag, next time the default etl job runs, those properties will be available in the inventory domain in cognos

                  • 6. Re: NSH Script for Server Information
                    Rob Slattery

                    I got the script to actually run when I dropped "servers" from the sGroup= line; however, the output it provides is as follows:

                     

                    Here's the output (notice for each server, it adds an extra comma):

                    IS_REPEATER,REPEATER_NAME,BAC_LOCATION
                    server1.orgunit.com,

                    server2.orgunit.com,,

                    server3.orgunit.com,,,

                    server4.orgunit.com,,,,

                     

                    I was hoping for an output like:

                    NAME,IS_REPEATER,REPEATER_NAME,BAC_LOCATION

                    server1.orgunit.com,False,,US

                    server2.orgunit.com,True,server_name,US

                    server3.orgunit.com,True,server_name,EUR

                    server1.orgunit.com,False,,,

                     

                    Here's my modified script:

                    #!/usr/nsh

                    sGroup="/WorkAreas/_rob/test"

                    propertyList="NAME,IS_REPEATER,REPEATER_NAME,BAC_LOCATION"

                    OUT_FILE=/c/rob/server_properties.csv

                    blcli_execute Server listServersInGroup "${sGroup}"

                    blcli_storeenv sList

                    echo "${propertyList}" > $OUT_FILE

                    for server in $sList

                    do

                         for propertyName in "${propertyList}"

                         do

                              blcli_execute Server printPropertyValue "${server}" "${propertyName}"

                              blcli_storeenv propValue

                              propValues="${propValues},${propValue}"

                         done

                    echo "${server}${propValues}" >> $OUT_FILE

                    done

                    fi

                    • 7. Re: NSH Script for Server Information
                      richard mcleod

                      the for loop wasn't processing the args using comma delimited. this works for me (no extra commas)

                      sGroup="/Home/rm/mygroup"

                      propertyList="IS_REPEATER,REPEATER_NAME,NETWORK_LOCATION"

                      OUT_FILE=outputtest.csv

                       

                      blcli_execute Server listServersInGroup "${sGroup}"

                      blcli_storeenv sList

                       

                      echo "${propertyList}" > $OUT_FILE

                       

                      for server in $sList

                      do

                        echo "${server}"

                           for propertyName in $(echo ${propertyList}|tr ',' ' ')

                           do

                        echo "${propertyName}"

                                blcli_execute Server printPropertyValue "${server}" "${propertyName}"

                                blcli_storeenv propValue

                       

                                propValues="${propValues},${propValue}"

                           done

                      echo "${server}${propValues}" >> $OUT_FILE

                      propValues=

                      done

                      • 8. Re: NSH Script for Server Information
                        Rob Slattery

                        Almost, for some reason, it's not liking the BAC_Location property.  If I place the BAC_LOCATION in the middle, end, or beginning, I get the "DBKey"..." value.  Everything else is exactly what I'm looking for.  I'm going to keep looking at the script to see what gives.

                        BAC_LOCATION,IS_REPEATER,REPEATER_NAME

                        server01.orgunit.com,DBKey:SPropertySetInstanceModelKeyImpl:2007521-2007521,false,repserver

                        • 9. Re: NSH Script for Server Information
                          richard mcleod

                          Thats completely weird!

                           

                          Can you run this from NSH and see what is returned?

                           

                          blcli_execute Server printPropertyValue "server01.orgunit.com" "BAC_LOCATION"

                          • 10. Re: NSH Script for Server Information
                            Bill Robinson

                            That’s because BAC_LOCATION is a property of type property class and the ‘value’ is a property instance.

                            1 of 1 people found this helpful
                            • 11. Re: NSH Script for Server Information
                              Rob Slattery

                              Hello Bill, is there any NSH script I can use that would be able to extract "type property" and the "property instatnce"?  I'm having a heck of a time trying to figure this one out.  I'm also going to post a similar question to the rest of the community.

                              • 12. Re: NSH Script for Server Information
                                Rob Slattery

                                Here's another question.  Can I use the below blcli command against a static server group to get the same information - goal is to get value of BAC_LOCATION.

                                 

                                PropertyInstance getFullyResolved

                                PropertyValue Class://SystemObject/Custom Property Classes/BAC_LOCATION

                                 

                                I got this from the BLCLI Help document; however, even though they say you need the full path to the instance, their example did not show what I listed above "Custom Property Classes" or "Built-in Property Classes", can I just drop that?

                                • 13. Re: NSH Script for Server Information
                                  Mike Jones

                                  Rob

                                   

                                  Is the BAC_LOCATION linked to a server property that you have set the instance on that server? (e.g. BAC_LOCATION in the example below)

                                   

                                  If it is then you should be able to use something like

                                   

                                  blcli_execute Server getFullyResolvedPropertyValue $NSH_RUNCMD_HOST BAC_LOCATION.PROPERTYNAME

                                  • 14. Re: NSH Script for Server Information
                                    Rob Slattery

                                    I'm not sure I understand what you're asking but I think so; however, when I click on Custom Property Classes, we've created a property called BAC_Location and when you click on that property, you can click on instances (right window) and we can see all of the locations that we've created.

                                     

                                    If I highlight a target, and click on BAC_LOCATION within the Properties tab (next to permissions tab), click the elipse button, the same property instance window appears as above.

                                    1 2 Previous Next