The Lazy Admin Blog

Home  /  cPanel • JetBackup  /  JetBackup Cheat Sheet :: Automatically Acknowledge Alerts

JetBackup Cheat Sheet :: Automatically Acknowledge Alerts

November 15, 2018 cPanel, JetBackup 1 Comment

JetBackup version 4+ introduced a fancy new alerts system in which you can easily get an overview of your notifications in one central place.

There are 3 types of alerts : Information, Warning & Critical . You can also get email notifications based on these alerts, setting this will be done through the Settings -> Notification page.

By default ‘Warning’ & ‘Critical’ alerts will send emails.

Unacknowledged alerts will continue to send emails until you acknowledge them from the GUI [ Emails are sent once on the daily cron. ]

Using a JetBackup hook to auto acknowledge alerts

Using A JetBackup hook, you can automate the procedure of acknowledging the alerts.

STEP 1 – Create bash hook file

Edit the hook file –

vi /root/acknowledgeAlerts

Paste the following code –

#!/bin/sh
for x in $(jetapi backup -F listAlerts | grep "_id" | awk '{print $2}'); do jetapi backup -F acknowledgeAlerts -D '_id[]='$x; done;

Give executable permissions –

chmod +x /root/acknowledgeAlerts

You can execute your hook to test if it’s working –

[root@cpanel01 ~]# /root/acknowledgeAlerts 
success: 1
message: Alerts Acknowledged Successfully
system:
  version: 3.1.20-1
  tier: STABLE
  drMode: 
  agreement: 
  licenseIssue: 
data:
success: 1
message: Alerts Acknowledged Successfully
system:
  version: 3.1.20-1
  tier: STABLE
  drMode: 
  agreement: 
  licenseIssue: 
data:
success: 1
message: Alerts Acknowledged Successfully

Empty response means no alerts to acknowledge.

STEP 2 – Apply your hook inside JetBackup

Navigate to “Hooks” & Click on “Create new hook” button.

Name your hook, paste your script location under “Hook script” and choose “Daily cron” from the type. As for the position, it could run PRE or POST the daily cron.

Running the hook at PRE daily cron – Will acknowledge the alerts and prevent the daily cron from sending email alerts (as they are already acknowledged once the cron reached there, so nothing to do).

Running the hook POST daily cron – Will acknowledge the alerts after daily cron already sent email alerts about them. There will no more emails about this alert anymore (as they are acknowledged).

We recommend using the POST position, as we want to receive at least one email notification about this alert.

ADVANCED USAGE – ACKNOWLEDGING SPECIFIC ALERTS

We can use some “bash magic” to acknowledge specific alerts. Let’s use the “No Disaster Recovery destination was set” alert as an example.

First, let’s show the alert from our bash using JETAPI –

[root@cpanel-dev-qa ~]# jetapi backup -F listAlerts
success: 1
message: 
system:
  version: 4.0.6
  tier: EDGE
  drMode: 
  agreement: 
  licenseIssue: 
data:
  alerts: 
    0: 
      _id: 5beca8f23d278dc906648e53
      title: No Disaster Recovery destination was set
      message: Please go to the destinations page and click on the "Shield" icon near the destination you want set as Disaster Recovery destination
      created: 2018-11-14T23:00:02+00:00
      acknowledge: 
      type: warning
      level: 64
  total: 1

We can use the same script as before, only that we will “grep” the specific alert(s) we want to ‘catch’, get their ID and auto acknowledge them.

Catching the ID –

[root@cpanel-dev-qa ~]# jetapi backup -F listAlerts | grep 'No Disaster Recovery destination' -B 1 | grep '_id' | awk {'print $2'}
5beca8f23d278dc906648e53

Creating a loop –

for x in $(jetapi backup -F listAlerts | grep 'No Disaster Recovery destination' -B 1 | grep '_id' | awk {'print $2'}); do jetapi backup -F acknowledgeAlerts -D '_id[]='$x; done;

Testing from command line –

[root@cpanel-dev-qa ~]# for x in $(jetapi backup -F listAlerts | grep 'No Disaster Recovery destination' -B 1 | grep '_id' | awk {'print $2'}); do jetapi backup -F acknowledgeAlerts -D '_id[]='$x; done;
 
success: 1
message: Alerts Acknowledged Successfully
system:
  version: 4.0.6
  tier: EDGE
  drMode: 
  agreement: 
  licenseIssue: 
data:

To also automate this procedure, go through steps 1 & 2 as before and use the loop code above instead.

“Where there is a bash, there is a way…” 🙂

 

 

Previous Article
Next Article

1 Comment

  1. Jim Reply
    October 12, 2019 at 14:10

    Thanks, very helpful..

Leave a Reply

Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search Our Blog

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
Apache
CentOS
CloudLinux
cPanel
Emails
ESXI
iSCSI
JetBackup
Litespeed
MySQL
NGINX
Oracle
Reduxio
Security
SSL
Uncategorized
VMware
Wordpress
XEN

Tags

apache aspx backup CentOS cloudlinux cPanel CXS Emails freetds google htaccess IMAP InnoDB iscsi JetBackup Libmodsecurity litespeed modsec modsecurity mssql MySQL netapp nginx odbc Oracle php php.ini phpselector rsync ssh VMFS WHM Wordpress xenserver

Popular Posts

  • Allow a cPanel server to run a VHOST from multiple IP addresses April 3, 2018
  • How To Install & Configure a Galera Cluster with MySQL on Centos 7 February 6, 2018
  • Libmodsecurity installation April 14, 2016
  • JetBackup Cheat Sheet :: Automatically Acknowledge Alerts November 15, 2018

Recent Posts

  • rsync without prompting for password October 10, 2022
  • Convert JetBackup to cPanel structure October 6, 2022
  • Configure LiteSpeed Crawler October 5, 2022
  • Change Hostname in Oracle Cloud Infrastructure (OCI) October 3, 2022

Recent Comments

  • Anonymous on InnoDB: Failed to find tablespace for table `X` in the cache
  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Oleg Drabkin on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
Privacy Policy • Contact