# LibreNMS 警報相關設定

LibreNMS 警報相關設定

# LibreNMS LINE Messaging API 設定

##### **運行環境**  


- **Librenms 25.9.0**

##### **LINE Messaging API 申請**

**先在LINE Developers新增一個channel並選擇Messaging API**

**[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-09/scaled-1680-/lNtimage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-09/lNtimage.png)**

##### **設定警報傳送**

**Type選擇LINE Messaging API**

**Access token輸入Channel access token**

**userID輸入Channel 內的user ID**

**[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-09/scaled-1680-/e3Rimage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-09/e3Rimage.png)**

**設定好後點選右邊Test，LINE有出現測試訊息則成功**

**[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-09/scaled-1680-/qFkimage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-09/qFkimage.png)**

# LibreNMS Mdadm RAID監控警報

##### **啟用Mdadm**

**確認已安裝[Mdadm監控](https://note.homesitetw.com/books/librenms/page/librenms-mdadm-raid)**

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

**Severity:警報等級**

**Max alert ：最多通知幾次**

**Delay ：延遲多久再來通知**

**Interval ：通知間隔**

**Transports:選擇傳送類別**

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

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

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

```
{{ $alert->title }}
設備名稱: {{ $alert->sysName }}
等級: {{ $alert->severity }}
運行時間: {{ $alert->uptime_short }}
警示時間: {{ $alert->timestamp }}
@foreach ($alert->faults as $key => $value)
RAID : @php echo (explode("_", $value['metric'])[0]); @endphp

@endforeach
```

##### **測試**

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

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

# LibreNMS 硬碟使用率監控警報

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

**範例監控"/"根目錄使用率超過80%**

**Severity:警報等級**

**Max alert ：最多通知幾次**

**Delay ：延遲多久再來通知**

**Interval ：通知間隔**

**Transports:選擇傳送類別**

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

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

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

```
{{ $alert->title }}
設備名稱: {{ $alert->sysName }}
等級: {{ $alert->severity }}
運行時間: {{ $alert->uptime_short }}
警示時間: {{ $alert->timestamp }}
@foreach ($alert->faults as $key => $value)
硬碟名稱: {{ $value['storage_descr'] }}
目前硬碟使用率: {{ $value['storage_perc'] }} %
@endforeach
```

##### **測試**

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

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

# LibreNMS CPU使用率監控警報

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

**Severity:警報等級**

**Max alert ：最多通知幾次**

**Delay ：延遲多久再來通知**

**Interval ：通知間隔**

**Transports:選擇傳送類別**

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-09/scaled-1680-/4rIimage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-09/4rIimage.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/2025-09/scaled-1680-/Pzfimage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-09/Pzfimage.png)

```
SELECT devices.device_id, devices.hostname, devices.status, devices.disabled, devices.ignore,
       AVG(processors.processor_usage) AS cpu_avg, 
	   MIN(processor_descr) AS processor_descr
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,processor_descr
HAVING AVG(processors.processor_usage) > 70;
```

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

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

```
{{ $alert->title }}
設備名稱: {{ $alert->sysName }}
等級: {{ $alert->severity }}
運行時間: {{ $alert->uptime_short }}
警示時間: {{ $alert->timestamp }}
@foreach ($alert->faults as $key => $value)
CPU名稱: {{ $value['processor_descr'] }}
目前CPU使用率: {{ round($value['cpu_avg']) }} %
@endforeach
```

##### **測試**

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

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