11-06-2018
03:03 PM
- last edited on
11-07-2018
12:13 AM
by
Marianne
**** Moved to new post from https://vox.veritas.com/t5/NetBackup/Long-running-or-Hung-jobs-script/m-p/289306 ****
Hi @Jacob,
can you please share the same script for windows please, actually we have windows server fro master and media( only 1 master & 1 media)
11-07-2018 04:53 AM
Convert the script to powershell (I am trying it on this ) or use cygwin to run this script.
11-07-2018 06:14 AM
OpsCenter can give you this also
11-08-2018 09:49 AM
Hi Tape_Archived,
Thnaks for the response
Can you please share me the powershell script actually i am not good in powershell
Thaank you in advance
11-08-2018 10:16 AM
Hi,
I tried to modify in powershell, Can you please confirm will it work or not
$date = Get-Date -Format "yyyy-MM-dd"
$rpt_file ="c:\temp\backup_rpt_"+$date+".csv"
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
# Sending email
set $SMTPport=Port number
set $Mailto=xyz.com
set $Mailfrom=abc.com
set $Mailsubject="Long Backup Report"
set $AttachmentDir=" c:\temp"
set $AttachmentFile_UK=$rpt_file
Send-MailMessage -SmtpServer "X.X.X.X" -From "abc.com" -To "xyz.com" -Attachments $rpt_file -Subject "Long Backup Report"
11-12-2018 12:04 AM
Hi Tape_Archived,
Thnaks for the response
Can you please share me the powershell script actually i am not good in powershell
Thaank you in advance
11-12-2018 10:56 AM
I didn't try translating this script to powershell. I may try but it will take some time. I will update when I am ready.
11-13-2018 04:11 AM
Thank you
11-22-2018 12:56 AM
Hi Tape_Archived,
Any luck, actually i have to implement this in my environment ASAP
01-07-2019 05:23 AM
@Tape_Archivedyou chance to convert this to powershell ?
01-08-2019 11:56 AM - edited 01-08-2019 01:46 PM
@Ranjit1 I might try my hand at this...
01-08-2019 12:56 PM - edited 01-09-2019 01:50 AM
I'll let you work out how to send an email from PowerShell...
...and I have also tried to give you a simple "jacket / header" script for your own future PowerShell scripts...
################################################################################################################### # Vers Date Who Description # ---- ---- --- ----------- # v0.01 08-Jan-2019 sdo Simple script to list long running backup jobs. ################################################################################################################### # Assumptions # ----------- # 1) That the Windows system path has been modified to include the folder paths for NetBackup commands. # 2) That this script will be run on a Master Server, or on a Media Server that is a Server of a Master Server. # # Abstract # -------- # Creates a simple report file of long running jobs. ################################################################################################################### ################################################################################################################### # Script behaviour settings... # $ErrorActionPreference = "Stop" ################################################################################################################### # Functions... # Function Log( $myText ) { If ( $myText -eq $Null ) { Write-Host "" } Else { Write-Host $myText } If ( $myScriptLog -ne "" ) { If ( $myText -eq $Null ) { Add-Content -Path $myScriptLog -Value "" } Else { Add-Content -Path $myScriptLog -Value $myText } } } Function Test-IsAdmin { Try { $myIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() $myPrincipal = New-Object Security.Principal.WindowsPrincipal -ArgumentList $myIdentity Return $myPrincipal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ) } Catch { Throw "...failed to determine if the current user is an admin, error '{0}'..." -f $_ } } ################################################################################################################### # Display script name and location... # $myScriptSpec = [System.IO.FileInfo]$PSCommandPath $myScriptPath = $myScriptSpec.Directory $myScriptName = $myScriptSpec.BaseName $myUsername = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name $myComputerDomain = ( Get-WmiObject Win32_ComputerSystem ).Domain $myComputername = ( Get-WmiObject Win32_ComputerSystem ).Name $myScriptDat = Join-Path $myScriptPath "$myScriptName.dat" $myScriptLog = Join-Path $myScriptPath "$myScriptName.log" $myScriptTmp = Join-Path $myScriptPath "$myScriptName.tmp" $myScriptTxt = Join-Path $myScriptPath "$myScriptName.txt" If ( Test-Path $myScriptDat ) { Remove-Item $myScriptDat } If ( Test-Path $myScriptLog ) { Remove-Item $myScriptLog } If ( Test-Path $myScriptTmp ) { Remove-Item $myScriptTmp } If ( Test-Path $myScriptTxt ) { Remove-Item $myScriptTxt } Log "" Log "...script spec: $myScriptSpec" Log "...script path: $myScriptPath" Log "...script name: $myScriptName" Log "" Log "...user: $myUsername" Log "...computer name: $myComputerName" Log "...computer domain: $myComputerDomain" Log "" Log "" If ( -not ( Test-IsAdmin ) ) { Log "...script must be run as administrator, script aborting..." Exit 2 } ################################################################################################################### # Once more unto the breach, dear friends... # $myThreshold = 86400 bpdbjobs -most_columns -file $myScriptDat $myStatus = $LastExitCode If ( $myStatus -ne 0 ) { Log "...failed to collect job data, status '$myStatus'..." Exit $myStatus } Get-Content $myScriptDat | ForEach-Object { $myData = $_ -Split "," $jobID = $myData[0] $jobType = $myData[1] $jobState = $myData[2] $jobSchedule = $myData[5] $jobClient = $myData[6] $jobRunTime = [int]$myData[9] If ( $jobType -eq "0" ) { If ( $jobRunTime -gt $myThreshold ) { Log "job $jobID $jobClient $jobSchedule runtime is $jobRuntime" Add-Content -Path $myScriptTxt -Value "long job $jobID $jobClient $jobSchedule runtime is $jobRuntime" } } } Exit 0
01-10-2019 07:47 AM
@sdoThank you very much, i will try this