06-14-2013 06:59 PM
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)
Solved! Go to Solution.
06-15-2013 12:42 PM
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
06-14-2013 07:30 PM
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
06-14-2013 07:37 PM
Thanks.
But how to start this script.I mean how to create this.
I need to run sudo vi first?
06-14-2013 07:48 PM
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
06-14-2013 08:08 PM
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.
06-14-2013 08:19 PM
-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 !!!
06-14-2013 08:21 PM
I am running this under /usr/openv/netbackup/scripts
06-14-2013 08:37 PM
tom_sprouse..
As an option we can add below path in this script to run from any path...
cd /usr/openv/netbackup/bin/admincmd
06-14-2013 08:39 PM
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.....
06-14-2013 08:49 PM
Can anybody please modify the script and let me know
06-14-2013 08:57 PM
-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/
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
06-14-2013 10:36 PM
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...
06-14-2013 11:36 PM
./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
06-15-2013 12:32 AM
have u copied this under admincmd
06-15-2013 12:36 AM
File having execution permission..
do change by
chmod 777 filename
rerun this...
06-15-2013 12:46 AM
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.
06-15-2013 02:36 AM
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/
06-15-2013 04:46 AM
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
06-15-2013 10:02 AM
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.
06-15-2013 10:03 AM
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