403Webshell
Server IP : 172.64.80.1  /  Your IP : 216.73.216.175
Web Server : LiteSpeed
System : Linux srv13.swhc.ca 4.18.0-553.126.2.lve.el8.x86_64 #1 SMP Thu May 28 14:12:30 UTC 2026 x86_64
User : hongluck ( 2522)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib64/nagios/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib64/nagios/plugins/check_jetbackup
#!/bin/bash

var=3600

job_name=$(jetbackup5api -F listBackupJobs -O json | jq -r '.data.jobs |.[]| select(.disabled == 0 and .name != "JetBackup Config").name' | tail -n1)
# Run the jetbackup5api command and capture the JSON output
json_output=$(jetbackup5api -F listLogs -D 'limit=400' -O json | jq -r --arg job "$job_name" '.data.logs | map(select(.info.Backup == $job and .type == 1)) | sort_by(.start_time) | .[-1] | "\(.file) \(.info."Total Accounts") \(.status) \(.execution_time)"')

# Use read to assign values to Bash variables
IFS=' ' read -r log_file total_accounts status exec_time <<< "$json_output"

if [[ -z $log_file ]]; then
 	echo "CRITICAL - JB5 log file NOT generated, check if the JOB is enable."
	exit 1
fi

acct_w_bk=$(grep -c -w "Backup Completed" $log_file)
time=$(echo "scale=2 ; $exec_time / $var" | bc)


if [[ ! -z $acct_w_bk ]]; then 
	pct=$(( $total_accounts - $acct_w_bk ))
	PerfData="'accts-no-backup'=$pct;"
	pc=$((100*$pct/$total_accounts))
fi

if [[ "$status" -eq 1 ]]; then 
	status=Completed
	echo "OK - JB5 Job Completed - Total accounts with backup = $acct_w_bk - Time $time hours | 'accts-no-backup'=$pct;"
	exit 0
fi

if [[ "$status" -eq 6 ]] && [[ $exec_time -gt 72000 ]]; then 
		status='Processing'
		echo "Warning - JB5 Job has been running for more than 20 hours - JB5 Job Processing - Total accounts with backup = $acct_w_bk - Time $time"
		exit 1
fi

if [[ "$status" -eq 6 ]] ; then
 	status='Processing'
 	echo "OK - JB5 Job Processing - Total accounts with backup = $acct_w_bk - Time $time hours"
	exit 0
fi

if [[ "$status" -eq 2 ]]; then
	status=Failed
	echo "CRITICAL - JB5 Job Failed | 'accts-no-backup'=$total_accounts;"
	exit 2
fi

if [[ "$status" -eq 3 ]]; then
	status=Aborted
	echo "CRITICAL - JB5 Job Aborted | 'accts-no-backup'=$pct;"
	exit 2
fi

if [[ "$status" -eq 5 ]]; then
	status='Never Finished'
	echo "CRITICAL - JB5 Job Never Finish | 'accts-no-backup'=$pct;"
	exit 2
fi

if [[ "$status" -eq 4 && "$pc" -ge 1 ]]; then
	status='Partially Completed'
	echo "OK - JB5 Job Partially Completed - Total accounts without backup = $pct - Time $time hours | 'accts-no-backup'=$pct;"
	exit 0
else
	echo "OK - JB5 Job Partially Completed - Total accounts with backup = $acct_w_bk - Time $time hours | 'accts-no-backup'=$pct;"
	exit 0
fi

Youez - 2016 - github.com/yon3zu
LinuXploit