9 Replies Latest reply on Jul 6, 2011 11:48 AM by Bill Robinson

    SmartGroups Re: Creating From File

    Rob Slattery

      Hello everyone,

       

      I've opened a case with BMC and have searched the knowledge base but keep coming up empty.  Is there anyway at all, you can create Smart Groups from an excel spreadsheet or even a text file?

       

      I know you can create a Server Group from a text file, and even import servers to BladeLogic using a text file with headers, so I'm guessing you should be able to do the same for creating Smart Groups.

       

      So far, BMC says they can't find a way out of the box but are looking for some sort of an nsh script to complete this task.

        • 1. Re: SmartGroups Re: Creating From File
          Bill Robinson

          You can create a smart group using the blcli w/ conditions – look at ‘SmartGroup.createGroup’ and ‘SmartGroup.addCondition’ – these are released commands.  You can write a wrapper to read a file and pass the appropriate info to these commands.

           

          What is the case # ?

          • 2. SmartGroups Re: Creating From File
            Rob Slattery

            Okay, so that sounds promising.  I'll look into this.  Would I find this in the BMC BladeLogic Users Guide?

             

            So my goal is this.  I currently have an nsh job running every Monday, Wednesday, and Saturday which collects information about a server which in turn places the servers into their correct smart groups.

             

            The information it collects from is in a reg key.  If there are any changes to the server or a group of servers, we have to log into each server and update.  The problem with this is, we have people typing in information incorrectly, leaving keys blank, etc., etc.  So, if we have one flat file, we can easily fill in the blanks and/or find-replace.

             

            The result will be servers in their proper smart groups and no reason to have reg key with server information.  We create a key called "FM" and then all subkeys with server information, patching days, groups, times, and customer information.  We call it the FM reg key.

             

            Oh - the incident number is ISS03800559

            • 3. Re: SmartGroups Re: Creating From File
              Bill Robinson

              It’s in the blcli guide – in the start menu on a system w/ the bladelogic gui installed.

               

              What conditions are you using to build the smart groups?

              • 4. SmartGroups Re: Creating From File
                Rob Slattery

                Yes, found it, looking in there now.

                 

                We use the following three keys:  HKLM\system\systeminfo\MaintenanceWindow

                                                                                                        \PatchTime

                                                                                                        \PatchGroup

                 

                MaintenanceWindow = Thursday, Friday, Saturday, or Sunday

                PatchTime = The times which business units or individual customers would like their server patched

                PatchGroup = LE, Prod A, Prod B, or Prod C - - these are the environments.

                • 5. Re: SmartGroups Re: Creating From File
                  Bill Robinson

                  But then how do you build the smart group conditions?  Are you setting a property value on the server based on the reg key and then the smart group memberships are based on that value?

                  • 6. SmartGroups Re: Creating From File
                    Rob Slattery

                    Oh, I got ya'.  Yes, we have a bunch of property values defined within BladeLogic and then we use an nsh script which looks like what I've supplied below.  And then I just create my smart groups based off the values within my property values.

                     

                    #!/usr/nsh

                    ###
                    #
                    # This script is used to pull Windows server information into a smartgoup for installs and upgrades of Windows servers.
                    #
                    # Return Value: 0 = Script Success
                    #             1 = Script Failure
                    #
                    ###

                    SUCCESS=0
                    FAILURE=1

                    ###
                    #
                    # Method for printing script usage
                    #
                    ###

                    print_usage()
                    {
                    echo "$SERVER     Name of server script is running on"
                                            echo "PatchGroup Registry entry for patchgroup on remote system"
                                            echo "PatchTime Registry entry for patching time on remote system"
                                            echo "MaintenanceWindow Registry entry for patching time on remote system"     
                    }

                    ##
                    # Declare variables
                    ##

                    SERVER=$NSH_RUNCMD_HOST

                    ###
                    #
                    # Ensure that the arguments have been set.
                    #
                    ###

                    if test -z $SERVER
                    then
                      echo "Target host name could not be established"
                        print_usage
                        exit $FAILURE
                    fi

                    ##
                    # Execute reg command to pull values from reg
                    ##

                    PROPVAL2=`nexec $SERVER reg query "HKLM\System\FM\SysInfo"  /v PatchGroup | awk '{print $3, $4, $5}' | strings -n 2`

                    PROPVAL3=`nexec $SERVER reg query "HKLM\System\FM\SysInfo"  /v PatchTime  | awk '{print $3, $4}' | strings -n 2`

                    PROPVAL4=`nexec $SERVER reg query "HKLM\System\FM\SysInfo"  /v MaintenanceWindow | awk '{print $3, $4}' | strings -n 2`

                    ##
                    # Verify Results
                    ##


                    if test -z $PROPVAL2
                    then
                      echo "No PatchGroup entry found."
                    else
                         echo "PatchGroup for $SERVER is $PROPVAL2"
                    fi

                    if test -z $PROPVAL3
                    then
                      echo "No patchtime entry found."
                    else
                      echo "Patchtime for $SERVER is $PROPVAL3"
                    fi

                    if test -z $PROPVAL4
                    then
                      echo "No MaintenanceWindow entry found."
                    else
                      echo "MaintenanceWindow for $SERVER is $PROPVAL4"
                    fi

                    fi

                    ##
                    # Set the WintelPOC property
                    ##

                           echo "Setting WintelPOC to $PROPVAL"
                           echo "Be patient this process may take time"

                    blcli Server setPropertyValueByName $SERVER FM_WINTEL_wintelpoc "$PROPVAL"

                    ##
                    #  Verify command executed properly
                    ##

                    EXIT_CODE=$?
                    if test $EXIT_CODE -ne 0
                    then
                    echo "ERROR: Set WintelPOC property entry failed"
                    echo "Aborting."
                    return 5
                    fi

                    ##
                    # Set the Contact_Name property
                    ##

                    ##
                    # Set the PatchGroup property
                    ##

                          echo "Setting PatchGroup to $PROPVAL2"
                          echo "Be patient this process may take time"

                           blcli Server setPropertyValueByName $SERVER FM_WINTEL_patchgroup "$PROPVAL2"

                    ##
                    #  Verify command executed properly
                    ##

                    EXIT_CODE=$?
                    if test $EXIT_CODE -ne 0
                    then
                    echo "ERROR: Set PatchGroup property entry failed"
                    echo "Aborting."
                    return 5
                    fi

                    ##
                    # Set the PatchTime property
                    ##

                          echo "Setting PatchTime to $PROPVAL3"
                          echo "Be patient this process may take time"

                           blcli Server setPropertyValueByName $SERVER FM_WINTEL_patchtime "$PROPVAL3"

                    ##
                    #  Verify command executed properly
                    ##

                    EXIT_CODE=$?
                    if test $EXIT_CODE -ne 0
                    then
                    echo "ERROR: Set PatchTime property entry failed"
                    echo "Aborting."
                    return 5
                    fi

                    ##
                    # Set the MaintenanceWindow property
                    ##

                          echo "Setting MaintenanceWindow to $PROPVAL4"
                          echo "Be patient this process may take time"

                           blcli Server setPropertyValueByName $SERVER FM_WINTEL_maintenance "$PROPVAL4"

                    ##
                    #  Verify command executed properly
                    ##

                    EXIT_CODE=$?
                    if test $EXIT_CODE -ne 0
                    then
                    echo "ERROR: Set Maintenance Window property entry failed"
                    echo "Aborting."
                    return 5
                    fi

                    ##
                    #  Verify command executed properly
                    ##

                    EXIT_CODE=$?
                    if test $EXIT_CODE -ne 0
                    then
                    echo "ERROR: Set Domain property entry failed"
                    echo "Aborting."
                    return 5
                    fi

                    echo "PatchGroup has been set to $PROPVAL2"
                    echo "Patch Time has been set to $PROPVAL3"
                    echo "Maintenance Window has been set to $PROPVAL4"
                    echo "Process Complete"

                    return $EXIT_CODE

                    • 7. Re: SmartGroups Re: Creating From File
                      Bill Robinson

                      How frequently do you need to create the smart groups?  Because I would expect you create the smart groups once, and then just update the property values on the servers.

                      • 8. SmartGroups Re: Creating From File
                        Rob Slattery

                        Correct, very infrequently and in fact, I think these smart groups (well, we still use hfnetcheck from Shavlik) have not changed but one or two times in the past eight years.

                         

                        Our Shavlik maintenance ends in July so this is our last patching we can do and then we're totally dependant on BladeLogic.

                        • 9. Re: SmartGroups Re: Creating From File
                          Bill Robinson

                          Ok-  just making sure ☺