-
Grant executable permission to
download_drive_file.sh
sudo chmod +x ~/download_drive_file.sh
-
Command to download supplier data
./download_drive_file.sh 1LePo57dJcgzoK4uiI_48S01Etck7w_5f supplier-data.tar.gz
-
Extract the downloaded data
tar xf ~/supplier-data.tar.gz
-
Create a new Python script named
changeImage.py
to convert raw image data tojpeg
-
Grant executable permission to
changeImage.py
sudo chmod +x ~/changeImage.py
-
Confirm whether the properties of new image has been properly converted
file ~/supplier-data/images/003.jpeg
-
Grant executable permission to
example_upload.py
sudo chmod +x ~/example_upload.py
-
The command below will upload the sample image to web server
./example_upload.py
-
Create a Python script named
supplier_image_upload.py
to upload converted images to web server -
Grant executable permission to
supplier_image_upload.py
sudo chmod +x ~/supplier_image_upload.py
-
At this point, the Django server has been running. The Django REST framework can be accessed on URL below.
{PUBLIC_IP}/fruits
-
Try
POST
method with the followingjson
data{ "name": "Test Fruit", "weight": 100, "description": "This is the description of my test fruit", "image_name": "icon.sheet.png" }
-
Create a Python script named
run.py
to read item description from directory and upload all description to web server -
Grant executable permission to
run.py
sudo chmod +x ~/run.py
-
Run the script
./run.py
-
Validate the process and ensure all images are shown on the web
http://{public_ip}/
-
There are 3 scripts that have to be created,
reports.py
,emails.py
, andreport_email.py
-
The
reports.py
will create apdf
report based on name and weight of items supplied by suppliers. -
The
emails.py
will create a message object and send message to receiver. The content of the email includes thepdf
file generated byreports.py
-
Finally
report_email.py
is the main script that will call bothreports.py
andemails.py
to perform these tasks. -
Grant executable permissions to
report_email.py
sudo chmod +x ~/report_email.py
-
Run the script
./report_email.py
-
Confirm that the email is actually sent to the receiver by logging in to webmail
{public_ip}/webmail
-
The final part is about creating an automatic alerting system in case abnormal behavior in the system is detected
-
Create a Python script named
health_check.py
to monitor CPU usage, disk space, available memory, and localhost connection -
The check should be performed every 1 minute. If abnormal behavior occurs, the script will send an email to receiver.
-
While the script is running, install
stress
toll to test the scriptsudo apt install stress
-
Run the
stress
tool and check whether alert message is received on receiver side.stress --cpu 8