cancel
Showing results for 
Search instead for 
Did you mean: 

we have 1500 clients in our backup rotation

noazara
Level 6

Hi Folks,

Please provide me the scripts that I can use in my environment for backup jobs/clients  which are running more than 24 hours.

 

Please provide the detailed steps.I meean how to create the script file and how to run that.

 

NBU 7.1

LINUX(tikanga)

 

1 ACCEPTED SOLUTION

Accepted Solutions

Nicolai
Moderator
Moderator
Partner    VIP   

The shebang expiression added, this script is written for Korn shell not Bash. Path to bpdbjobs is now full

But do take a look at my previos post that contain a link to a perl script that do the same.The script below is one I wrote and then replaved with a perl version. 

#!/usr/bin/ksh
ALARM_TRESHOLD=84000
RUNTIME=0
/usr/openv/netbackup/bin/admincmd/bpdbjobs -most_columns | awk -F "," ' $3 ~ /^1$/ { print } ' |  awk -F "," ' $2 ~ /^0$/ { print } '  | awk -F "," '{ print $1, $3, $6, $7, $10 }' | while read  PID STATE SCHEDULE CLIENT RUNTIME
do
 if [ RUNTIME -gt ALARM_TRESHOLD ]
  then
     echo "Job ${PID} ${CLIENT} ${SCHEDULE} runtime is ${RUNTIME}. It's exceeded runtime treshold of ${ALARM_TRESHOLD} "
   fi
done

View solution in original post

24 REPLIES 24

tom_sprouse
Level 6
Employee Accredited Certified

Noazara,

Please see forum post - https://www-secure.symantec.com/connect/forums/long-running-or-hung-jobs-script#comment-3583201

ALARM_TRESHOLD=84000
RUNTIME=0
bpdbjobs -most_columns | awk -F "," ' $3 ~ /^1$/ { print } ' |  awk -F "," ' $2 ~ /^0$/ { print } '  | awk -F "," '{ print $1, $3, $6, $7, $10 }' | while read  PID STATE SCHEDULE CLIENT RUNTIME
do
 if [ RUNTIME -gt ALARM_TRESHOLD ]
  then
     echo "Job ${PID} ${CLIENT} ${SCHEDULE} runtime is ${RUNTIME}. It's exceeded runtime treshold of ${ALARM_TRESHOLD} "
   fi
done

 

However, if you are already using OpsCenter for reporting, you can setup an alert for long running jobs.

If you have any questions, please let me know.

 

-Tom

 

noazara
Level 6

Thanks.

 

But how to start this script.I mean how to create this.

 

I need to run sudo vi first?

tom_sprouse
Level 6
Employee Accredited Certified

noazara,

Yes, you will need to create a file in linux first... name it something like jobs_over_24_hours.sh

Then use vi to modify the contents of the file.

Once you save it, execute the script to see if it works.

You may want to modify the ALARM_THRESHOLD value from 84000 to 3600 to monitor jobs over 1 hour first for testing.

Once you have the script working, adjust the value back to 84000 for 24 hour jobs.

--Tom

 

Marianne
Level 6
Partner    VIP    Accredited Certified

Seems you need basic Unix training? 

Please do not expect to get it in a NetBackup forum....

The script is extremely helpful. Please mark Tom's post as Solution and ask your Unix administrator for further assistance.

noazara
Level 6

-bash-3.2$ sudo ./24.sh

./24.sh: line 3: bpdbjobs: command not found

 

 

-bash-3.2$ cat 24.sh

ALARM_TRESHOLD=84000

RUNTIME=0

bpdbjobs -most_columns | awk -F "," ' $3 ~ /^1$/ { print } ' |  awk -F "," ' $2 ~ /^0$/ { print } '  | awk -F "," '{ print $1, $3, $6, $7, $10 }' | while read  PID STATE SCHEDULE CLIENT RUNTIME

do

if [ RUNTIME -gt ALARM_TRESHOLD ]

  then

     echo "Job ${PID} ${CLIENT} ${SCHEDULE} runtime is ${RUNTIME}. It's exceeded runtime treshold of ${ALARM_TRESHOLD} "

   fi

done

 

 

Getting the above error !!!

noazara
Level 6

I am running this under /usr/openv/netbackup/scripts

Ankit_Maheshwar
Level 5

tom_sprouse..

As an option we can add below path in this script to run from any path...

 

cd /usr/openv/netbackup/bin/admincmd

 

 

Marianne
Level 6
Partner    VIP    Accredited Certified

If you don't have a PATH variable set, add the full path to bpdbjobs:
/usr/openv/netbackup/bin/admincmd/bpdbjobs

Please - this is Unix basics.....

noazara
Level 6

Can anybody please modify the script and let me know

noazara
Level 6

 

-bash-3.2$ sudo ./24.sh

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

 

-bash-3.2$ cat 24.sh

PATH=$PATH:/usr/openv/netbackup/bin:/usr/openv/netbackup/bin/admincmd

 

ALARM_TRESHOLD=84000

RUNTIME=0

bpdbjobs -most_columns | awk -F "," ' $3 ~ /^1$/ { print } ' |  awk -F "," ' $2 ~ /^0$/ { print } '  | awk -F "," '{ print $1, $3, $6, $7, $10 }' | while read  PID STATE SCHEDULE CLIENT RUNTIME

do

if [ RUNTIME -gt ALARM_TRESHOLD ]

  then

     echo "Job ${PID} ${CLIENT} ${SCHEDULE} runtime is ${RUNTIME}. It's exceeded runtime treshold of ${ALARM_TRESHOLD} "

   fi

done

 

Ankit_Maheshwar
Level 5

make the following change

cd /usr/openv/netbackup/scripts

 

mv 24.sh /usr/openv/netbackup/bin/admincmd

now cd  /usr/openv/netbackup/bin/admincmd

 

check permission for 24.sh  file

change permission by chmod if file does not have execute permission...

run the script....

 

 

 

Hope this will work...

noazara
Level 6

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

./24.sh: line 7: [: RUNTIME: integer expression expected

 

Ankit_Maheshwar
Level 5

have u copied this under admincmd

Ankit_Maheshwar
Level 5

File having execution permission..

 

do change by 

chmod 777 filename 

 

rerun this...

Marianne
Level 6
Partner    VIP    Accredited Certified

NO!!! Home-grown scripts should NEVER be created/copied in NBU folders.

Correct PATH variable or full pathnames is all that is needed.

Issue is no longer with PATH but with value of variable.

noazara
Level 6

I am confused.Ankit is saying under admincmd and marianne is saying something else

 

I am running this under admincmd

with 777 permission.

 

-bash-3.2$ sudo ./24.sh

 

./24.sh: line 7: [: RUNTIME: integer expression expected

-bash-3.2$ ls -ltr |grep -i 24

-r-xr-xr-x 1 root daemon 2473618 Feb  3  2011 bpmedialist

-r-xr-xr-x 1 root daemon   26324 Feb  3  2011 bpgetdebuglog

-rwxrwxrwx 1 root root       474 Jun 14 23:54 24.sh

-bash-3.2$ pwd

/usr/openv/netbackup/bin/admincmd

mph999
Level 6
Employee Accredited

As marianne suggests, home written scripts should not go in to netbackup binary dirs.  You could perhaps put it in netbackup/bin/goodies but personally I would put it somewhere outside /usr/openv

Persoanlly I have a /netbackup folder, and keep stuff in there.  scripts go under /netbackup/scripts for example.

You need to set the PATH in the .profile of the user you log in as.

eg.

PATH=$PATH:/usr/openv/netbackup/bin:/usr/openv/netbackup/bin/admincmd:/usr/openv/volmgr/bin

If you run this from the command line, and then run the script, it should work.

Martin

Nicolai
Moderator
Moderator
Partner    VIP   

Try this perl script I wrote some time ago. This is what we use every day

https://www-secure.symantec.com/connect/forums/email-alert-backup-running-longer-time

Edit the line "use lib "/usr/openv/nnit/master" to match the location where you place the nnit_env file. The nnit_env file contain email adresses.

 

Nicolai
Moderator
Moderator
Partner    VIP   

ALWAYS use the shebang expression in the start of a script. This script is written for the korn shell (ksh)

Add in the first line the following - including the #

#!/usr/bin/ksh