11 Replies Latest reply on Jan 16, 2014 3:39 AM by Rajeev Gupta

    Sending SNMP Notification

    Rajeev Gupta

      Hi,

       

      I have created a NSH script to create a Deploy Job, but I am unable to add the 3 parts:

      1. Send SNMP trap once the job is complete. (Job Notification)

      2. 'Execute job Now' or Schedule Now option or to run the Job as soon as its created.

      3. Fetch the Logs of the Job run in some shared location. (Same way we can extract job run logs)

       

      Please let me know the exact command to add these above conditions in the script.

       

      blcli_execute

        • 1. Re: Sending SNMP Notification
          Bill Robinson

          can you share your nsh script ?

          • 2. Re: Sending SNMP Notification
            Bill Robinson

            so for the 'default Notifier' you can use

            DeployJob setDefaultSNMPNotifier

             

            if you want to set snmp notify for a schedule you'd use DeployJob addOntTimeScheduleWithSNMPNotification

             

            to run the job now you can use

            DeployJob executeJobAndWait or the onetimeschedule one.

             

            to export the log use

            Utility exportDeployRun

             

            then use nsh to copy that to some shared location.

            1 of 1 people found this helpful
            • 3. Re: Sending SNMP Notification
              Rajeev Gupta

              For SNMP Notification, I am using

               

              PACKAGE_NAME=adobe.msi

              JOB_FOLDER='<Deplot_Location> eg: /Application/Environment/package folder>'

               

              blcli_execute Job setDescription Test_Job_Details

               

              SNMP_NOTIFIER='snmp.<Server_Name>.<net/com>'

                  blcli_execute DeployJob setDefaultSNMPNotifier "${JOB_FOLDER}" "${PACKAGE_NAME}" "${SNMP_NOTIFIER} 14

               

              But this is not getting added to the Deploy Job. Please suggest

              • 4. Re: Sending SNMP Notification
                Bill Robinson

                so the name of the job is 'adobe.msi' in the /application/environment/package folder in the JOBS workspace ?

                 

                do you get a return from the blcli_execute DeployJob setDefaultSNMPNotifier command ?

                 

                also - your 'setDescription' requires the dbkey for the job so you need to do like:

                blcli_execute DeployJob getDBKeyByGroupAndName /blah foo

                blcli_storeenv jobKey

                blcli_execute DeployJob setDescription ${jobKey} "Test_Job_Details"

                 

                though when you created the job you should have been able to pass a description.

                • 5. Re: Sending SNMP Notification
                  Rajeev Gupta

                  I guess the SNMP is not getting set. I got this output (Submit Debug: SNMP_SET_DESCRIPTION:    <Blank>    ) when I ran the following:

                   

                       JOB_FOLDER="/$LOB/$ENV/$APP_NAME"

                       SOFTWARE_TYPE="CUSTOM_SOFTWARE_INSTALLABLE"

                   

                  #   GROUP_ID=`blcli_execute JobGroup groupNameToId "${JOB_FOLDER}"`

                      blcli_execute JobGroup groupNameToId "${JOB_FOLDER}" > /dev/null && blcli_storeenv GROUP_ID

                      echo "Group_ID?: ${GROUP_ID}"

                      [[ $DEBUG = "true" ]] && echo "Submit Debug: GROUP_ID:" $GROUP_ID


                  # Retrieve the package unique identifier (DBKey)

                        blcli_execute DepotObject getDBKeyByTypeStringGroupAndName "${SOFTWARE_TYPE}" "${DEPOT_FOLDER}" "${PACKAGE_NAME}" > nul 2>nul

                  [[ "$?" -ne "0" ]] && { echo "Cannot find depot object by name : ${PACKAGE_NAME} in group : ${DEPOT_FOLDER} with type : ${SOFTWARE_TYPE}"; echo "13"; exit 13; }

                  blcli_storeenv SOFTWARE_KEY

                  echo "Software_Key: ${SOFTWARE_KEY}"


                  ##Setting SNMP Notifier

                   

                      blcli_execute DeployJob setDefaultSNMPNotifier <GROUP_ID> <SOFTWARE_KEY> <Server_where_SNMP_to_be_Send> 14 > /dev/null && blcli_storeenv SNMP_SET_DESCRIPTION

                    [[ $DEBUG = "true" ]] && echo "Submit Debug: SNMP_SET_DESCRIPTION:" $SNMP_SET_DESCRIPTION

                  • 6. Re: Sending SNMP Notification
                    Bill Robinson

                    so a couple things:

                     

                    1 - using FOO=`blcli_execute xxx` negates the purpose of using the performance commands.  you should do:

                    blcli_execute xxx

                    blcli_storeenv blah

                     

                    2 - why are you using the depot object key in the command to set the snmp notification ?

                     

                    blcli_execute DeployJob setDefaultSNMPNotifier <GROUP_ID> <SOFTWARE_KEY> <Server_where_SNMP_to_be_Send> 14

                     

                    this takes:

                    1 - GROUP NAME

                    2 - JOB NAME

                    3 - SNMP TARGET

                    4 - STATUS TYPE

                     

                    you are passing the wrong arguments to this command.  you are passing the group id and the blpackage key.  you need to pass the group name that the job is in, and the name of the job.

                    • 7. Re: Sending SNMP Notification
                      Rajeev Gupta

                      I ran the command now as below, but this is still not getting added to the Job.

                       

                      JOB_FOLDER="/LOB/ENV/APP_NAME"

                      DEPLOY_JOB_NAME=packageName-Timestamp

                       

                      blcli_execute DeployJob setDefaultSNMPNotifier ${JOB_FOLDER} ${DEPLOY_JOB_NAME} snmp.<Server_Name> 14 > /dev/null && blcli_storeenv SNMP_SET_DESCRIPTION

                        [[ $DEBUG = "true" ]] && echo "Submit Debug: SNMP_SET_DESCRIPTION:" $SNMP_SET_DESCRIPTION

                       

                      1. Here, SNMP Target server should be only ServerName or snmp.ServerName

                       

                      2. Is there some part of the Script where i need to place this exclusively.

                      Currently I am putting this sequence : JobGroup, createSoftwareDeployJob, clearTargetServer, addTargetServers, setDescription, setPropertyValue, setDefaultSNMPNotifier, executeJob, executeJobAndWait, exportDeployRun

                      • 8. Re: Sending SNMP Notification
                        Bill Robinson

                        1 – just the hostname or ip of the snmp receiver.

                        2 – can you attach or paste the entire script ?

                        • 9. Re: Sending SNMP Notification
                          Rajeev Gupta

                          Seems like its not getting the Job name now.

                          Command execution failed. com.bladelogic.om.infra.mfw.util.NotFoundException: No job found with name : <Job_name> group : 2024060 and type : DEPLOY_JOB

                          • 10. Re: Sending SNMP Notification
                            Bill Robinson

                            does a deploy job w/ the name you specified exist in the folder you specified ?

                             

                            it would be helpful if you could post or attach the entire script you are using.

                            • 11. Re: Sending SNMP Notification
                              Rajeev Gupta

                              Thanks Bill, i figured out where i was making a mistake.

                               

                              You are the God of BladeLogic