V1rus Private
User / IP
:
216.73.217.108
Host / Server
:
190.92.174.125 / aerosofthealthcare.com
System
:
Linux s3739.bom1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64
Cmd
|
Upload
|
Mass Deface
|
Create
|
Sym
:
/
lib64
/
nagios
/
plugins
/
Viewing: check_proxmox_backups.sh
#!/bin/bash # Ref - 8696dk1zc - check proxmox backups state # cahe_interval=21600 # interval to check cahe_log="/tmp/check_proxmox_backups.log" # default path to log file cacheage () { file=${1} now=$(date +%s) mtime=$(stat -c %Y "${file}") delta=$(( now - mtime )) echo "${delta}" } if ! which proxmox-backup-manager > /dev/null 2>&1; then echo "check_proxmox_backups - OK - No proxmox backups setup" >${cahe_log} cat ${cahe_log} exit 0 fi # go through all proxmox upids and collect last day backup completion data check_backup_state() { last_day=$(date -d "yesterday" +"%a %b %d") backup_dc=$(hostname | awk -F '.whgi' '{print $1}' | awk -F '.' '{print $2}') backup_today_upid=($(proxmox-backup-manager task list --all | grep "${last_day}" | awk '{print $14}' | grep "${backup_dc}" | grep "@pbs"| grep -v "prune:backup")) for backup_id in ${backup_today_upid[@]}; do upid_data=$(proxmox-backup-manager task log ${backup_id}) if [[ -n "${upid_data}" ]];then if echo "${upid_data}" | grep -q "successfully finished backup"; then index_date=$(echo "${upid_data}" | grep 'created new fixed index 1') echo "OK - job completed successfully (${index_date})" else echo "CRIT - ${backup_id} job has not been completed" fi else echo "CRIT - ${backup_id} job has no task log" fi done } # generate a cache if [[ ! -e ${cahe_log} ]]; then touch ${cahe_log} check_backup_state >${cahe_log} else fileage=$(cacheage ${cahe_log}) if [ "${fileage}" -ge "${cahe_interval}" ]; then check_backup_state >${cahe_log} fi fi # use cache to populate monitoring data if [[ -s "${cahe_log}" ]]; then if grep -q CRIT "${cahe_log}"; then echo -e "check_proxmox_backups - CRIT\n$(cat ${cahe_log})" exit 2 else echo -e "check_proxmox_backups - OK\n$(cat ${cahe_log})" exit 0 fi fi
Coded With 💗 by
HanzOFC