# 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:選擇傳送類別**

<span style="color: rgb(0, 0, 0);">**範例監控RAID降級後1分鐘發出警報**</span>

[![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/2026-11/scaled-1680-/hunimage.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/hunimage.png)

```
{{ $alert->title }}
設備名稱: {{ $alert->display }} 
@if (!empty($alert->uptime_short))
運行時間: {{ $alert->uptime_short }}
@endif
@if ($alert->state == 0)
持續時間: {{ $alert->elapsed }}
恢復時間: {{ $alert->timestamp }}
@foreach ($alert->faults as $key => $value)
降級恢復RAID : {{ explode('_', $value['metric'])[0] }}
@endforeach
@else
告警時間: {{ $alert->timestamp }}
@foreach ($alert->faults as $key => $value)
降級RAID : {{ explode('_', $value['metric'])[0] }}
@endforeach
@endif
```

##### **測試**

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

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2026-11/scaled-1680-/B5Nimage.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/B5Nimage.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使用率監控警報

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

<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)

# LibreNMS ICMP 監控警報

#### <span style="color: rgb(0, 0, 0);">**新增警報規則**</span>

<span style="color: rgb(0, 0, 0);">**若ICMP 5分鐘沒恢復則發送告警**</span>

<span style="color: rgb(0, 0, 0);">**Transport選擇要發送的位置**</span>

<span style="color: #000000;">**若不選擇設備則預設全部設備套用**</span>

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

#### <span style="color: rgb(0, 0, 0);">**新增警報範本**</span>

```
{{ $alert->title }}
設備名稱: {{ $alert->display }} 
@if (!empty($alert->uptime_short))
運行時間: {{ $alert->uptime_short }}
@endif
@if ($alert->state == 0)
持續時間: {{ $alert->elapsed }}
恢復時間: {{ $alert->timestamp }}
@else
告警時間: {{ $alert->timestamp }}
@endif
```

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

#### <span style="color: rgb(0, 0, 0);">**測試**</span>

<span style="color: rgb(0, 0, 0);">**測試告警**</span>

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

# LibreNMS 自訂 LVM-Thin Pool 監控

<div class="" data-bfc="" data-complete="true" data-hveid="CAIIAAgACA8QAQ" data-sfc-cp="" data-sfc-root="c" data-ved="2ahUKEwinnvn1meuXAxUWsFYBHVKKDuEQi4wTegoIAggACAAIDxAB" id="bkmrk-%E5%82%B3%E7%B5%B1-lvm%EF%BC%9A-%E7%95%B6%E6%82%A8%E5%BB%BA%E7%AB%8B%E5%82%B3%E7%B5%B1%E7%9A%84-lv%EF%BC%88l" jsaction="" jscontroller="eHDDzf#DtOdcb" jsuid="HbIrYb_63">**<span style="color: rgb(0, 0, 0);"><span class="iNqyIf" data-complete="true" data-sfc-cp="" data-sfc-root="c"><span class="rQesXe MPyX"><span style="color: rgb(224, 62, 45);">傳統 LVM</span>：</span> 當您建立傳統的 LV（Logical Volume）並格式化掛載（例如 `/dev/mapper/vg-lv` 掛載到 `/data`），它在作業系統中是一個標準的「掛載檔案系統」。LibreNMS 透過標準的 SNMP（HOST-RESOURCES-MIB）就能直接抓到這個掛載點的磁碟容量與使用率。</span></span>**</div><div class="" data-bfc="" data-complete="true" data-hveid="CAIIAAgACA8QBQ" data-sfc-cp="" data-sfc-root="c" data-ved="2ahUKEwinnvn1meuXAxUWsFYBHVKKDuEQi4wTegoIAggACAAIDxAF" id="bkmrk-lvm-thin-pool%EF%BC%9A-lvm-t" jsaction="" jscontroller="eHDDzf#DtOdcb" jsuid="HbIrYb_6e">**<span class="iNqyIf" data-complete="true" data-sfc-cp="" data-sfc-root="c" style="color: rgb(0, 0, 0);"><span class="rQesXe MPyX"><span style="color: rgb(224, 62, 45);">LVM-Thin Pool</span>：</span> LVM-Thin Pool 是一個「區塊層級的儲存池」（如 Proxmox VE 上的 `local-lvm`）。<span class="rQesXe MPyX">它本身沒有檔案系統，也沒有掛載到任何目錄上</span>。因為它在系統中沒有 mount point，標準的 SNMP 走索引時根本看不到它，LibreNMS 自然就無法自動探索（Discovery）並畫出圖表。</span>**</div>#### <span style="color: rgb(0, 0, 0);">**<span class="iNqyIf" data-complete="true" data-sfc-cp="" data-sfc-root="c">建立SNMP Extend 腳本</span>**</span>

<span style="color: rgb(0, 0, 0);">**<span class="iNqyIf" data-complete="true" data-sfc-cp="" data-sfc-root="c">我的lvm-thin是使用USB外接硬碟，已經建立usb-lvm-thin</span>**</span>

<span style="color: rgb(0, 0, 0);">**<span class="iNqyIf" data-complete="true" data-sfc-cp="" data-sfc-root="c">建立`/etc/snmp/usb-lvm-thin`，<span style="color: rgb(45, 194, 107);">usb-lvm-thin</span>修改成自已的Thin Pool</span>**</span>

```
#!/bin/bash
percent=$(sudo /sbin/lvdisplay -m usb-lvm-thin 2>/dev/null | /bin/grep "Allocated pool data" | /usr/bin/awk '{print $4}' | /bin/sed 's/[.].*$//')

if [ -z "$percent" ]; then
    echo "0"
else
    echo "$percent"
fi
```

```
chmod +x /etc/snmp/usb-lvm-thin
```

<span style="color: rgb(0, 0, 0);">**新增`/etc/sudoers.d/snmpd-lvm`**</span><span style="color: rgb(0, 0, 0);">**，讓snmp能執行lvdisplay**</span>

```
Debian-snmp ALL=(ALL) NOPASSWD: /sbin/lvdisplay
```

<span style="color: rgb(0, 0, 0);">**確認snmp程序能抓取資料**</span>

```
su -s /bin/bash Debian-snmp -c "/etc/snmp/usb-lvm-thin"
```

`<span style="color: rgb(0, 0, 0);"><strong>/etc/snmp/snmpd.conf</strong></span>`<span style="color: rgb(0, 0, 0);">**新增extend**</span>

```
extend lvmthin /etc/snmp/usb-lvm-thin
```

```
service snmpd restart
```

#### <span style="color: rgb(0, 0, 0);">**Custom OID設定**</span>

**確認已經建立OID，名稱統一為<span style="color: rgb(224, 62, 45);">LVM-THIN</span>，後續只要自訂LVM THIN OID都能統一套用**

```
NET-SNMP-EXTEND-MIB::nsExtendOutLine."lvmthin".1
```

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

<span style="color: rgb(0, 0, 0);">**確認有顯示圖表**</span>

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

#### **建立警報規則**

<span style="color: rgb(0, 0, 0);">**選擇`Create rule from collection`，選擇`CustomOID over warning limit`**</span>

<span style="color: rgb(0, 0, 0);">**Add rule放在上面，讓descr匹配LVM-THIN**</span>

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

#### **建立警報範本**

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2026-11/scaled-1680-/E40image.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/E40image.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)
超過告警值: {{ $value['customoid_limit_warn'] }} %
硬碟名稱: {{ $value['customoid_descr'] }}
使用率: {{ $value['customoid_current'] }} %
@endforeach
@endif
@endif
```

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

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

# LibreNMS 自訂CPU溫度監控警報

#### <span style="color: rgb(0, 0, 0);">**自訂OID**</span>

<span style="color: rgb(0, 0, 0);">**確認已經建立OID，名稱統一為<span style="color: rgb(224, 62, 45);">CPU溫度</span>，後續只要自訂CPU 監控OID都能統一套用**</span>

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

#### <span style="color: rgb(0, 0, 0);">**建立警報規則**</span>

<span style="color: #000000;">**選擇`Create rule from collection`，選擇`CustomOID over warning limit`**</span>

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

<span style="color: rgb(0, 0, 0);">**Add rule放在上面，讓descr匹配CPU溫度**</span>

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


#### <span style="color: rgb(0, 0, 0);">**建立警報範本**</span>

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2026-11/scaled-1680-/EApimage.png)](https://note.homesitetw.com/uploads/images/gallery/2026-11/EApimage.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)
超過告警值: {{ $value['customoid_limit_warn'] }} °C
{{ $value['customoid_descr'] }} 溫度: {{ $value['customoid_current'] }} °C
@endforeach
@endif
@endif
```

<span style="color: rgb(0, 0, 0);">**此為通用範例自行修改**</span>

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

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