# LibreNMS CPU使用率監控警報

##### **新增警報規則**

<span style="color: rgb(0, 0, 0);">**Severity:警報等級**</span>

<span style="color: rgb(0, 0, 0);">**Max alert ：最多通知幾次**</span>

<span style="color: rgb(0, 0, 0);">**Delay ：延遲多久再來通知**</span>

<span style="color: rgb(0, 0, 0);">**Interval ：通知間隔**</span>

<span style="color: rgb(0, 0, 0);">**Transports:選擇傳送類別**</span>

<span style="color: rgb(0, 0, 0);">**範例使用CPU&gt;70%持續10分鐘發出警報**</span>

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2026-11/scaled-1680-/sUXimage.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/sUXimage.png)

**由於多核心CPU預設一顆CPU觸發就會警報，故修改使用平均使用率計算**

**官方解決範本[https://docs.librenms.org/Alerting/Rules/#advanced](https://docs.librenms.org/Alerting/Rules/#advanced)，不過有GROUP語法錯誤告警**

**以下為自訂修改版本搭配警報範本使用，Override SQL記得開啟**

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2026-11/scaled-1680-/image.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/image.png)

```
SELECT 
    devices.device_id, 
    devices.hostname, 
    devices.status, 
    devices.disabled, 
    devices.ignore, 
    AVG(processors.processor_usage) AS cpu_avg
FROM devices 
INNER JOIN processors ON devices.device_id = processors.device_id 
WHERE devices.device_id = ? 
  AND devices.status = 1 
  AND devices.disabled = 0 
  AND devices.ignore = 0 
GROUP BY 
    devices.device_id, 
    devices.hostname, 
    devices.status, 
    devices.disabled, 
    devices.ignore 
HAVING AVG(processors.processor_usage) > 70;
```

##### **新增警報範本**

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2026-11/scaled-1680-/BY5image.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/BY5image.png)

```
{{ $alert->title }}
設備名稱: {{ $alert->display }} 
@if (!empty($alert->uptime_short))
運行時間: {{ $alert->uptime_short }}
@endif
@if ($alert->state == 0)
持續時間: {{ $alert->elapsed }}
恢復時間: {{ $alert->timestamp }}
@else
告警時間: {{ $alert->timestamp }}
@if ($alert->faults)
@foreach ($alert->faults as $key => $value)
超過10分鐘CPU使用率: {{ (float)$value['cpu_avg'] }} %
@endforeach
@endif
@endif
```

##### **測試**

<span style="color: rgb(0, 0, 0);">**這裡先調成&gt;1%做測試**</span>

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2026-11/scaled-1680-/tAaimage.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/tAaimage.png)

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2026-11/scaled-1680-/v5zimage.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/v5zimage.png)