summaryrefslogtreecommitdiff
path: root/procedures/genesis_uptime_monitor.md
blob: 6505f060a6e1b7849a24ac7451fef0ee734b09b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Genesis Uptime Monitor

This package sets up a simple service uptime tracker on your local server (e.g., Krang). It includes:

- A Python Flask API to report 24-hour uptime
- A bash script to log uptime results every 5 minutes
- A systemd unit to keep the API running

## Setup Instructions

### 1. Install Requirements

```bash
sudo apt install python3-venv curl
cd ~
python3 -m venv genesis_api
source genesis_api/bin/activate
pip install flask
```

### 2. Place Files

- `uptime_server.py` → `/home/doc/uptime_server.py`
- `genesis_check.sh` → `/usr/local/bin/genesis_check.sh` (make it executable)
- `genesis_uptime_api.service` → `/etc/systemd/system/genesis_uptime_api.service`

### 3. Enable Cron

Edit your crontab with `crontab -e` and add:

```cron
*/5 * * * * /usr/local/bin/genesis_check.sh
```

### 4. Start API Service

```bash
sudo systemctl daemon-reload
sudo systemctl enable --now genesis_uptime_api
```

Then browse to `http://localhost:5000/api/uptime/radio`

## Web Integration

In your HTML, add a div and script like this:

```html
<div id="radioUptime"><small>Uptime: Loading…</small></div>
<script>
fetch('/api/uptime/radio')
  .then(r => r.json())
  .then(data => {
    document.getElementById('radioUptime').innerHTML = `<small>Uptime: ${data.uptime}% (24h)</small>`;
  });
</script>
```