6 Replies Latest reply on Sep 18, 2019 8:51 AM by Bill Robinson

    How do I  create scheduled job notification in Execution Task using BLCLI

    Justan Suss
      Share This:

      I've got a script to create an Execution Task and add a one time schedule with ExecutionTask addonetimeschedule. Now I'd like to add a Scheduled Job Notification to the one time schedule but I can't find anything in the ExecutionTask namespace (released or unreleased). Anyone have an idea as to how I can do this?

        • 1. Re: How do I  create scheduled job notification in Execution Task using BLCLI
          Greg Michael

          From the BLCLI unreleased commands documentation, I found this in the Job.addOneTimeSchedule command:

          This command does not send a job notification. To add a schedule that includes notifications, see the Job addOneTimeScheduleWithSNMPNotification or Job addOneTimeScheduleWithEMailNotification commands.

          It's not specifically for the Execution Task, but maybe it will point you in the right direction?

          • 2. Re: How do I  create scheduled job notification in Execution Task using BLCLI
            Bill Robinson

            right:

            CommandInputReturn value stored name
            ExecutionTask.findByDBKey$etKey$executionTask
            ExecutionTask.getExecutionTaskIdno inputexecutionTaskId
            ExecutionTask.getJobDbKeyByExecutionTaskIdNAMED_OBJECT=executionTaskIdjobKey
            Job.checkApprovalEnabledNAMED_OBJECT=jobKey false-
            Utility.stringToDate$dateString$scheduleDate
            Utility.createModelObjectJobSchedule-
            JobSchedule.setExecutionTask$etKey$-
            JobSchedule.setOnceDateTimeNAMED_OBJECT=scheduleDate-
            JobSchedule.setSchedFreqTypeId1-
            Schedule.createno input-
            JobSchedule.getScheduleIdno inputscheduleId
            Utility.setInputAsTargetObject$etKey$-

            and then

             

            CommandInputReturn value stored name
            Job.checkApprovalEnabled$jobKey$ false-
            Utility.stringToDate$dateString$scheduleDate
            Utility.createModelObjectNotification-
            Notification.setNotificationType1-
            Notification.setRecipient$recipient$-
            Notification.setStatusTypes$statusType$-
            Utility.storeTargetObjectnotifier-
            Utility.createModelObjectJobSchedule-
            JobSchedule.setJobId$jobKey$-
            JobSchedule.addNAMED_OBJECT=notifier-
            JobSchedule.setOnceDateTimeNAMED_OBJECT=scheduleDate-
            JobSchedule.setSchedFreqTypeId1-
            Schedule.createno input-
            JobSchedule.getScheduleIdno inputscheduleId
            Utility.setInputAsTargetObject$jobKey$-

             

            so probably something like:

            blcli_execute ExecutionTask findByDBKey ${etKey}

            blcli_execute Utility storeTargetObject et

            blcli_execute Utility stringToDate "${dateString}"

            blcli_execute Utility storeTargetObject scheduleDate

            blcli_execute Utility createModelObject Notification

            blcli_execute Notification setNotificationType 1

            blcli_execute Notification setStatusTypes ${statusType}

            blcli_execute Utility storeTargetObject notifier

            blcli_execute Utility createModelObject JobSchedule

            blcli_execute JobSchedule setExecutionTask ${etKey}

            blcli_execute JobSchedule add NAMED_OBJECT=et

            blcli_execute JobSchedule setOnceDateTime NAMED_OBJECT=scheduleDate

            blcli_execute JobSchedule setSchedFreqTypeId 1

            blcli_execute Schedule create

            blcli_execute JobSchedule getScheduleId

            blcli_execute Utility setInputAsTargetObject ${etKey}

            1 of 1 people found this helpful
            • 3. Re: How do I  create scheduled job notification in Execution Task using BLCLI
              Justan Suss

              Thanks for the quick reply. I've made some changes in the snippet you provided (changed vars to match what I've already got) , but I'm stuck with a mismatch arguments error with the JobSchedule.add.

               

              "Error 09/17/2019 14:50:01 Command execution failed. com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Found command 'JobSchedule.add' but with mismatching arguments."

               

              Looking at the info on JobSchedule.add I see it asks for INPUT variable 'x'... so I just thought I 'd try a few different inputs

               

              I've tried:

              blcli_execute JobSchedule add NAMED_OBJECT=et

              and

              blcli_execute JobSchedule add NAMED_OBJECT et

              and

              blcli_execute JobSchedule add et

               

              and still same error.

               

              If it helps, my script in its entirety is:

              ==================================================

               

              blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true

              file_name="$2"

              TASKNAME="$3"

              echo "the source file is: "$file_name

               

              # readng the columns from the source CSV

              sed 1d $file_name | while IFS=, read -r START_DATE START_TIME CRQNO JOBNAME JOBFOLDER SERVERNAME EMAIL TASKFOLDER;do

               

              ## BEGIN SCRIPT

              blcli_connect

               

              echo " "

              echo "*** CREATING EXECUTION TASK FOR BATCH JOB: $JOBNAME, LOCATED AT: $JOBFOLDER ***"

              echo "*** TARGET SERVER IS: $SERVERNAME ***"

               

              # get the DBKEY of the job the execution task will run and store as 'jobkey'

              blcli_execute BatchJob getDBKeyByGroupAndName "$JOBFOLDER" $JOBNAME

              blcli_storeenv jobkey

              echo "*** JOB KEY FOR THE BATCH IS: $jobkey ***"

               

               

              # use the jobjkey to create execution task and store the tasks DBKey as 'etkey'

              echo "*** Creating Execution Task and then storing it's key so we can move the task to its final destination ***"

              blcli_execute ExecutionTask createExecutionTask $jobkey $TASKNAME"_"$CRQNO"_"$SERVERNAME

              blcli_storeenv etkey

              echo "*** TASK KEY IS: $etkey ***"

               

               

              # use the etkey now to add target Server

              echo "*** ADDING $SERVERNAME TO THE EXECUTION TASK ***"

              blcli_execute ExecutionTask addTargetServers $etkey $SERVERNAME

               

               

              echo "*** MOVING TASK TO $TASKFOLDER ***"

              # Get 'groupId' of the folder the task will be moved TO and store as variable 'groupId'

              blcli_execute JobGroup groupNameToId $TASKFOLDER

              blcli_storeenv groupId

               

              #Use 'etkey'  to load the task as a stored object in utility namespace called 'et'

              # blcli_execute ExecutionTask findByDBKey ${etkey}

              blcli_execute ExecutionTask findByDBKey ${etkey}

              blcli_execute Utility storeTargetObject et

               

              # define use 'groupId' command to define target folder the task should be moved to

              blcli_execute ExecutionTask setGroupId ${groupId}

               

              # commit the change to the Execution task

              blcli_execute ExecutionTask update NAMED_OBJECT=et

               

              echo "*** ADDING ONE TIME SCHEDULE TO $TASKNAME"_"$CRQNO"_"$SERVERNAME ***"

               

              DATE_STRING="$START_DATE $START_TIME"

              # blcli ExecutionTask addOneTimeSchedule $etkey "$DATE_STRING"

              echo "*** Task will execute $DATE_STRING ***"

               

              RECIPIENT=$EMAIL

              # explainer on "Notification_Status" is here: http://www.techjeeper.com/BLCLI/Job.html#addOneTimeScheduleWithEMailNotification-1

              # NOTIFICATION_STATUS=14

              statustype=14

              echo "*** Target email address for job notification is: $RECIPIENT ***"

               

              #blcli_execute ExecutionTask findByDBKey ${etKey}

              blcli_execute ExecutionTask findByDBKey $etkey

              blcli_execute Utility storeTargetObject et

              #blcli_execute Utility stringToDate "${dateString}"

              blcli_execute Utility stringToDate "${DATE_STRING}"

              blcli_execute Utility storeTargetObject scheduleDate

              blcli_execute Utility createModelObject Notification

              blcli_execute Notification setNotificationType 1

              # blcli_execute Notification setStatusTypes ${statusType}

              blcli_execute Notification setStatusTypes $statustype

              blcli_execute Utility storeTargetObject notifier

              blcli_execute Utility createModelObject JobSchedule

              blcli_execute JobSchedule setExecutionTask $etkey

              #blcli_execute JobSchedule add NAMED_OBJECT=et

              #blcli_execute JobSchedule add NAMED_OBJECT et

              #blcli_execute JobSchedule add NAMED_OBJECT=et

              blcli_execute JobSchedule add et

              blcli_execute JobSchedule setOnceDateTime NAMED_OBJECT=scheduleDate

              blcli_execute JobSchedule setSchedFreqTypeId 1

              blcli_execute Schedule create

              blcli_execute JobSchedule getScheduleId

              blcli_execute Utility setInputAsTargetObject $etkey

               

              done

               

              =====================================

               

              Any help / suggestions appreciated

              • 4. Re: How do I  create scheduled job notification in Execution Task using BLCLI
                Bill Robinson

                blcli_storeenv etKey

                blcli_execute ExecutionTask findByDBKey ${etKey}

                blcli_execute Utility storeTargetObject et

                blcli_execute Utility clearContext

                blcli_execute Utility stringToDate "${dateString}"

                blcli_execute Utility setTargetObject

                blcli_execute Utility storeTargetObject scheduleDate

                blcli_execute Utility createModelObject Notification

                blcli_execute Notification setNotificationType 1

                blcli_execute Notification setRecipient "${recipient}"

                blcli_execute Notification setStatusTypes ${statusType}

                blcli_execute Utility storeTargetObject notifier

                blcli_execute Utility createModelObject JobSchedule

                blcli_execute JobSchedule setExecutionTask ${etKey}

                blcli_execute JobSchedule add NAMED_OBJECT=notifier

                blcli_execute JobSchedule setOnceDateTime NAMED_OBJECT=scheduleDate

                blcli_execute JobSchedule setSchedFreqTypeId 1

                blcli_execute Schedule create

                blcli_execute JobSchedule getScheduleId

                missed a couple things in the first go.

                1 of 1 people found this helpful
                • 5. Re: How do I  create scheduled job notification in Execution Task using BLCLI
                  Rakesh Swain

                  Hi Justan,

                   

                  Use below blcli mail command inside your script to trigger mail notification. I hope this method may help to resolve your requirement.

                   

                  blcli_execute Email sendMail "SENDER" "RECEIVER" "SUBJECT" "BODY"

                  • 6. Re: How do I  create scheduled job notification in Execution Task using BLCLI
                    Bill Robinson

                    doesn't look like he's using a nsh script job there...