• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to stop the backup script and send an alert if the server loads higher on Oracle Linux 9.3

  • 00:49 cat /etc/os-release
  • 01:06 vim backup_script
  • 10:52 chmod +x backup_script
  • 11:03 ll
  • 11:14 uptime
  • 11:22 ./backup_script
  • 11:47 vim infinite_loop
  • 13:09 ./infinite_loop
  • 13:23 ./backup_script
  • 15:56 chmod +x infinite_loop
7783

To Stop The Backup Script And Send An Alert If The Server Load Is Higher On Oracle Linux 9.3

Introduction

This straightforward procedure allows you to automatically halt backup operations when the server's resources are strained, and it simultaneously sends alerts to administrators. This proactive approach helps maintain system stability and data integrity by preventing resource overuse during peak times. By setting up this automated system, you can balance data protection and system performance on your Oracle Linux server.

Procedure Steps

Step 1: Check the OS version by using the below command

[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3

Step 2: Create and Edit Script file by using the below command

[root@linuxhelp ~]# vim backup_script
#!/bin/bash
# Define the maximum limit of system load
maximum_limit=10 # Change the limit to your requirement
# Get the System load average
load_average=$(uptime | grep -o average.* | awk '{print $2}' | tr -d ',')
# Calculate the system core and system load average then convert to percentage
percentage=$(bc -l <<< "scale=2; $load_average / $(nproc) * 100" | sed 's/.000//g')
# if statement for creating conditions to make decisions
if (( $(echo "$percentage > $maximum_limit" | bc -l) ));
then
echo "Alert! The system load is above 10%, percentage load:$percentage%, load average:$load_average so Backup Stopped."
else
 echo "Success! The system load is below 10%, percentage load:$percentage%, load average:$load_average  so the Backup Started Successfully"
fi

Step 3: Give the executable permission to the file by using the below command

[root@linuxhelp ~]# chmod +x backup_script

Step 4: Long list to check the file permission by using the below command

[root@linuxhelp ~]# ll
total 8
-rw-------. 1 root root 1067 Jan  7 03:03 anaconda-ks.cfg
-rwxr-xr-x. 1 root root  764 Mar 11 04:23 backup_script
drwxr-xr-x. 2 root root    6 Jan  7 03:26 Desktop
drwxr-xr-x. 2 root root    6 Jan  7 03:26 Documents
drwxr-xr-x. 2 root root    6 Jan  7 03:26 Downloads
drwxr-xr-x. 2 root root    6 Jan  7 03:26 Music
drwxr-xr-x. 2 root root    6 Jan  7 03:26 Pictures
drwxr-xr-x. 2 root root    6 Jan  7 03:26 Public
drwxr-xr-x. 2 root root    6 Jan  7 03:26 Templates
drwxr-xr-x. 2 root root    6 Jan  7 03:26 Videos

Step 5: Check the server load by using the below command

[root@linuxhelp ~]# uptime
 04:24:14 up  4:06,  3 users,  load average: 0.00, 0.00, 0.00

Step 6: Run the backup_script file by using the below command

[root@linuxhelp ~]# ./backup_script
Success! The system load is below 10%, percentage load:0%, load average:0.00  so the Backup Started Successfully

Step 7: Open new terminal tab as shown in below image. Snap1

Step 8: Create and edit the script file to increase server load by using following command.

[root@linuxhelp ~]# vim infinite_loop
#!/bin/bash
while : true
do
echo "Running infinite loop, to exit press ctrl+c"
done

Step 9: Change the executable permission to inifinite loop script file by using the below command

[root@linuxhelp ~]# chmod +x infinite_loop

Step 10: Run the infinite_loop script file to increase server load by using the below command

[root@linuxhelp ~]# ./infinite_loop
Running infinite loop, to exit press ctrl+c
Running infinite loop, to exit press ctrl+c
Running infinite loop, to exit press ctrl+c
Running infinite loop, to exit press ctrl+c
Running infinite loop, to exit press ctrl+c
Running infinite loop, to exit press ctrl+c
Running infinite loop, to exit press ctrl+c

Step 11: Again check the server load by using the below command

[root@linuxhelp ~]# uptime
 04:29:17 up  4:11,  4 users,  load average: 0.30, 0.08, 0.02

Step 12: Again, Run the backup_script file by using the below command

[root@linuxhelp ~]# ./backup_script
Alert! The system load is above 10%, percentage load:26.00%, load average:1.06 so Backup Stopped.

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Stop Backup Script and Send Alert if Server Load above 80% on Oracle Linux 9.3. Your feedback is much welcome.

Tags:
jacob
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

Why is it important to stop the backup script during high server loads?

A

When the server load is high, it indicates that system resources are under strain. Stopping the backup script temporarily helps prevent further resource consumption, ensuring the server remains responsive and stable.

Q

What does "Server Load above 80%" mean?

A

"Server Load above 80%" typically refers to the system load average, a measure of the server's workload. When this load average exceeds 80%, it suggests the server is under significant load, which can affect performance.
"Server Load above 80%" typically refers to the system load average, a measure of the server's workload. When this load average exceeds 80%, it suggests the server is under significant load, which can affect performance.

Q

How do I set up monitoring for server load on Oracle Linux?

A

You can set up monitoring using tools like `uptime`, `sar`, or specialized monitoring software such as Nagios. These tools can periodically check the system load average.

Q

What kind of alerts can be sent to administrators?

A

Alerts can be sent via email, SMS, or other notification methods. They typically include information about the high server load, timestamps, and possibly suggestions for further actions.

Q

How can I modify the load threshold (80%) to suit my server's needs?

A

You can modify the load threshold by changing the value of `load_maximum_limit` in the script to your desired percentage. It's important to choose a threshold that aligns with your server's capacity and performance requirements.

Related Tutorials in How to stop the backup script and send an alert if the server loads higher on Oracle Linux 9.3

Related Tutorials in How to stop the backup script and send an alert if the server loads higher on Oracle Linux 9.3

How to Install Mondo Rescue Disaster Recovery Tool in Linux
How to Install Mondo Rescue Disaster Recovery Tool in Linux
Jun 9, 2016
How to Configure HAproxy Load Balancer with Keepalived in CentOS
How to Configure HAproxy Load Balancer with Keepalived in CentOS
Nov 21, 2016
How to Setup Backup Server Using Bacula And Webmin in CentOS
How to Setup Backup Server Using Bacula And Webmin in CentOS
Jul 20, 2016
How to Configure Load Balancer in Apache
How to Configure Load Balancer in Apache
Nov 18, 2016
How to install Zevenet an open source load balancing server
How to install Zevenet an open source load balancing server
Jun 26, 2018
How to install Freefilesync in Ubuntu
How to install Freefilesync in Ubuntu
Jul 29, 2016
How to Configure Nginx Load Balancer in Ubuntu
How to Configure Nginx Load Balancer in Ubuntu
Nov 19, 2016
How to use Duplicity in Linux
How to use Duplicity in Linux
May 25, 2016

Related Forums in How to stop the backup script and send an alert if the server loads higher on Oracle Linux 9.3

Related Forums in How to stop the backup script and send an alert if the server loads higher on Oracle Linux 9.3

Backup
joshwariddin class=
Elastix backup file location
Jan 29, 2018
Ubuntu
mason class=
Backup files with rsync: error 23
Feb 25, 2021
Bash-scripting
aristosv class=
Bash script filtering output issue
Jun 4, 2019
Shell Script
symonds class=
Sort only unique words inside a file
Apr 6, 2018
Linux
connor class=
float values is not accepting in bash
Apr 20, 2017
Bash-scripting
elijah class=
What does shebang first line mean
Jul 12, 2019
Linux
ethan class=
How to get line number of the bash script on run time?
Jun 3, 2024
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaiah ?
What is the use of SUID & SGID commands

How to set the special permissions to the files and folders using SUID and SGID commands...

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.