-
Clone Repo:
git clone https://github.com/aryangupta701/django-monitoring-restro/
-
Switch to Project Directory:
cd django-monitoring-restro
-
Activate Environment:
source ../bin/activate
In the data folder add -
-
Menuhours.csv
-
storestatus.csv
-
timezones.csv
source ./bin/activate
python manage.py makemigrations
python manage.py migrate
python manage.py load_data
python manage.py runserver
METHOD - POST
http://127.0.0.1:8000/trigger_report/
METHOD - GET
http://127.0.0.1:8000/get_report/<report-id>
-
Every time is converted into UTC before use
-
To get all the unique store_id the database table store_status is used
- An interpolation curve is being formed with points defined as timestamps (in seconds) of the poll of previous 10 days using scipy using the following code
interp_func = interp1d(timestamps, states, kind='nearest', fill_value='extrapolate')
-
On X-axis - Timestamp ( timestamps )
-
On Y-axis - Either 0 (for inactive) or 1 (for active) is stored ( states )
- Now to calculate last-hour uptime used the following logic :
-
Iterated over each second in the last hour and checked if the timestamp of the second is within the range of working hours of that day or not.
-
If it is in the range then append it to the
interpolated_timestamps
array -
Now pass this array to the interpolation object and it will return the predicted values of each timestamp in
interpolated_states
which consists of either 0 or 1. -
Now uptime can be calculated by adding the whole
interpolated_states
array -
To calculate the downtime we can be calculated by subtracting the uptime from the total length of
interpolated_timestamps
-
The same logic is used for the calculation of last day and last week.
-
At the uptime and downtime which were calculated in seconds and converted into the required format (hours or minutes )