Skip to content

Commit dab7165

Browse files
committed
Updated graph code
1 parent a0ee5df commit dab7165

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

.github/workflows/deploy-bot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ jobs:
2121
- name: Build and deploy
2222
run: |
2323
docker compose down
24-
docker compose up -d --build
24+
docker compose build --no-cache
25+
docker compose up -d

app/graph/cpu_load.png

-6.15 KB
Loading

app/graph/graph_24hr.py

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,32 @@
33
import datetime
44
import os
55

6-
76
def graph_cpu_load(db_report):
87
now = datetime.datetime.now()
98
window_start = now - datetime.timedelta(hours=24)
109

11-
times = []
12-
loads = []
10+
time = []
11+
load = []
1312

1413
for entry in db_report:
15-
t = datetime.datetime.fromtimestamp(entry['timestamp'])
16-
if t >= window_start:
17-
times.append(t)
18-
loads.append(entry['cpu_prcnt'])
19-
20-
if not times:
21-
times = [window_start, now]
22-
loads = [0, 0]
23-
24-
times, loads = zip(*sorted(zip(times, loads)))
14+
dt = datetime.datetime.fromtimestamp(entry['timestamp'])
15+
time.append(dt)
16+
load.append(entry['cpu_prcnt'])
2517

2618
plt.figure(figsize=(14, 6))
2719
plt.title("CPU Usage - Last 24 Hours", fontsize=14, fontweight='bold')
2820
plt.xlabel("Time", fontsize=12)
29-
plt.ylabel("CPU Load (%)", fontsize=12)
21+
plt.ylabel("CPU Load", fontsize=12)
3022

31-
plt.plot(times, loads, linewidth=1.5)
32-
33-
plt.grid(True, alpha=0.5, color='gray')
34-
plt.ylim(0, 100)
35-
36-
ax = plt.gca()
37-
ax.set_xlim(window_start, now)
38-
39-
ax.xaxis.set_major_locator(mdates.HourLocator(interval=2))
40-
ax.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
23+
plt.plot(time, load, linewidth=1.5)
24+
plt.xlim(window_start, now)
4125

26+
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
27+
plt.gca().xaxis.set_major_locator(mdates.HourLocator(interval=2))
4228
plt.gcf().autofmt_xdate()
43-
plt.tight_layout()
29+
30+
plt.grid(True, alpha=0.5, color='gray')
31+
#plt.ylim(0, 100)
4432

4533
script_dir = os.path.dirname(os.path.abspath(__file__))
4634
save_path = os.path.join(script_dir, 'cpu_load.png')

app/services/clock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async def five_min_clock(self):
1111
self.five_min_event.set()
1212
await asyncio.sleep(1)
1313
self.five_min_event.clear()
14-
await asyncio.sleep(300)
14+
await asyncio.sleep(20)
1515
print("Five minute clock triggered")
1616

1717
async def day_cycle_clock(self):

0 commit comments

Comments
 (0)