Added systemd config
This commit is contained in:
@@ -154,6 +154,44 @@ Run the monitoring loop to continuously push data:
|
|||||||
./monitor_loop.sh "London" 60 "http://10.0.0.5:8428"
|
./monitor_loop.sh "London" 60 "http://10.0.0.5:8428"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Systemd Service (Autostart on Boot)
|
||||||
|
|
||||||
|
To run the monitor automatically as a system service:
|
||||||
|
|
||||||
|
1. **Install the service:**
|
||||||
|
```bash
|
||||||
|
sudo cp nationalgrid-monitor.service /etc/systemd/system/
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Customize settings (optional):**
|
||||||
|
Edit `/etc/systemd/system/nationalgrid-monitor.service` and modify the `ExecStart` line to change:
|
||||||
|
- GSP name (default: "Bishops Wood")
|
||||||
|
- Update interval in seconds (default: 60)
|
||||||
|
- VictoriaMetrics URL (default: http://localhost:8428)
|
||||||
|
|
||||||
|
3. **Enable and start the service:**
|
||||||
|
```bash
|
||||||
|
sudo systemctl enable nationalgrid-monitor.service
|
||||||
|
sudo systemctl start nationalgrid-monitor.service
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Check service status:**
|
||||||
|
```bash
|
||||||
|
sudo systemctl status nationalgrid-monitor.service
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **View logs:**
|
||||||
|
```bash
|
||||||
|
sudo journalctl -u nationalgrid-monitor.service -f
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Stop or disable:**
|
||||||
|
```bash
|
||||||
|
sudo systemctl stop nationalgrid-monitor.service
|
||||||
|
sudo systemctl disable nationalgrid-monitor.service
|
||||||
|
```
|
||||||
|
|
||||||
## Grafana Integration
|
## Grafana Integration
|
||||||
|
|
||||||
Once metrics are in VictoriaMetrics:
|
Once metrics are in VictoriaMetrics:
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=National Grid Monitor Service
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/opt/nationalgrid
|
||||||
|
ExecStart=/bin/bash /opt/nationalgrid/monitor_loop.sh "Bishops Wood" 60 http://localhost:8428
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
User=root
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user