8 Replies Latest reply on Aug 2, 2017 10:44 AM by Artur Rychlewicz

    BladeLogic CLI - NSH Script Jobs

      1. I am looking to enable/check the “List failed servers in email notification” on NSH Script Jobs using blcli. I looked at the documentation for Utility/Notification/Job/NSHScriptJob etc but did not see a way to achieve this? I may have totally missed this on the documentation, apologies if I did. Appreciate any help.

       

      2. When creating, NSHScriptJob using "NSHScriptJob createNSHScriptJob" - Job Description is a required parameter. But this doesn't seem to set Job Description as you would expect. NSHScriptJob setDescription had to be explicitly executed after the Job creation to achieve this. Any way around this or something that I am missing here?

       

      Thanks,

      Mohan.

        • 1. Re: BladeLogic CLI - NSH Script Jobs
          Ashitosh Wagh

          Hi Mohan,

           

          You can use following set of blcli

           

          RECIPIENT="someone@company.com"

          NOTIFICATION_STATUS=14

          DATE_STRING="2012-09-11 23:35:00"

          JOB_KEY=`blcli NSHScriptJob getDBKeyByGroupAndName /nshjobs nshjob`

          JOB_KEY=`blcli Job addDailyScheduleWithEMailNotification $JOB_KEY "$DATE_STRING" $RECIPIENT $NOTIFICATION_STATUS

           

          For Last parameter Notification status :

          The statusType argument determines the statuses for which you want to issue a notification. The possible statuses each have a value as follows:

          • Success=2

          • Failure=4

          • Cancel=8

          For statusType, add the statuses for which you want to issue notifications. For example, if you want to issue notifications when the job status is Failure or Cancel, then statusType=12.

           

           

          Thanks

          Ashitosh

          • 2. Re: BladeLogic CLI - NSH Script Jobs

            Thanks Ashitosh for the response.

             

            The above snippet calls for adding a Daily Schedule but I do not want to add any schedule on the jobs, I just want to be able to enable/check the “List failed servers in email notification” on NSH Script Jobs using blcli.

             

            Thanks,

            Mohan.

            • 3. Re: BladeLogic CLI - NSH Script Jobs
              Bill Robinson

              I know what you want to do, but I’m not sure if this is possible right now – you’d need to figure out some of the notification flag settings and such.  I’ve been meaning to do this, just haven’t had time.

              • 4. Re: BladeLogic CLI - NSH Script Jobs
                Ashitosh Wagh

                Hi Mohan,

                 

                as Bill said I am also not sure it is possible directly.

                 

                You can use One time schedule BLCLI -> addOneTimeScheduleWithEMailNotification  in above solution I provided.

                Job is runing only once so it will not be executing again.

                 

                So you need to use:

                 

                NOTIFICATION_STATUS=14

                DATE_STRING="2012-09-11 23:35:00"

                JOB_KEY=`blcli NSHScriptJob getDBKeyByGroupAndName /nshjobs nshjob`

                JOB_KEY=`blcli Job addOneTimeScheduleWithEMailNotification $JOB_KEY "$DATE_STRING" $RECIPIENT $NOTIFICATION_STATUS

                 

                For Last parameter Notification status :

                The statusType argument determines the statuses for which you want to issue a notification. The possible statuses each have a value as follows:

                • Success=2

                • Failure=4

                • Cancel=8

                For statusType, add the statuses for which you want to issue notifications. For example, if you want to issue notifications when the job status is Failure or Cancel, then statusType=12

                 

                Thanks

                Ashitosh

                • 5. Re: BladeLogic CLI - NSH Script Jobs
                  Ashitosh Wagh

                  Hi Mohan,

                   

                  Is your problem solved ?

                   

                  Let me know if you faced any issue.

                   

                  Please Mark answer correct or helpful.

                   

                  Thanks

                  Ashitosh

                  • 6. Re: BladeLogic CLI - NSH Script Jobs

                    This was quite interesting excersize... Here's how you set this option:

                     

                    -------------------------------

                    GROUP_NAME="/Test"

                    JOB_NAME="Test"

                     

                    blcli_execute NSHScriptJob getDBKeyByGroupAndName "$GROUP_NAME" "$JOB_NAME"

                     

                     

                    blcli_execute NSHScriptJob setOptionValue  303 Y

                     

                     

                    blcli_execute Utility storeTargetObject job
                    blcli_execute Job update NAMED_OBJECT=job

                    -------------------------------

                     

                    Here is how I derived at it, in case this is helpful to you to set other options of interest:

                     

                    - Set as many options in my Test job as I could ('set' meaning modified from default value)

                     

                    - Ran through the loop for the first million values and printed out all option ids with their values:

                     

                    for Value in {0..1000000}

                    do

                        blcli_execute NSHScriptJob getOptionStringValue $Value

                        blcli_storeenv Opt

                        [ "$Opt" != "void" ] && echo "Option $Value: $Opt"

                    done

                     

                    Option 303 returned as Y. I tested to set it to N and back to Y using the script above, and this option was it.

                     

                    Note: if you're running through the loop, and the value in the job is at the default, then the value may be returned as 'void', so first set the value to something, then run the loop. This is all unreleased, and you all know the baggage that comes with it.

                    • 7. Re: BladeLogic CLI - NSH Script Jobs

                      Thanks lazar, worked like a charm.

                      Appreciate the detailed steps to help figure out any other options.

                      • 8. Re: BladeLogic CLI - NSH Script Jobs
                        Artur Rychlewicz

                        Has this been fixed yet? I wasn't unable to find this option either, relying on rather hacky way by Lazar.