跳到主內容

Proxmox VE 安裝及設定 LibreNMS-Agent

第一步:安裝 SNMP 套件


  • 安裝 SNMP 服務套件
apt install snmpd -y
  • SNMP 設定檔備份並且重新命名
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.ori
  • 新增 SNMP 設定檔
vim /etc/snmp/snmpd.conf
  • 設定檔內容
# this create a  SNMPv1/SNMPv2c community named "my_servers"
# and restricts access to LAN adresses 192.168.0.0/16 (last two 0's are ranges)
rocommunity my_servers 192.168.0.0/16
# setup info
syslocation  "rack 1, room 3, serverrroom"
syscontact  "Svenn"
# open up
agentAddress  udp:161
# run as
agentuser  root
# dont log connection from UDP:
dontLogTCPWrappersConnects yes
# fix for disks larger then 2TB
realStorageUnits 0

disk / 10%
  • 重新啟動 SNMP 服務,設定開機時自動啟用
systemctl restart snmpd && systemctl enable snmpd
  • snmp 設定檔另一個版本
com2sec notConfigUser  default       public
com2sec local localhost public
com2sec my1network1 172.16.1.58/32 01
com2sec my2network2 172.16.2.10/32 02
com2sec my3network2 172.16.0.248/32 03

group MyRWGroup v1 local
group MyRWGroup v2c local
group MyROGroup v1 my1network1
group MyROGroup v2c my1network1
group MyROGroup v1 my2network2
group MyROGroup v2c my2network2
group MyROGroup v1 my3network2
group MyROGroup v2c my3network2

view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.2
view    systemview    included   .1.3.6.1.2.1.25.1.1

access  notConfigGroup ""      any       noauth    exact  systemview none none

view all    included  .1                               80

access MyROGroup "" any noauth prefix all none none
access MyRWGroup "" any noauth prefix all all all

dontLogTCPWrappersConnects yes

syslocation  "rack 1, room 3, serverrroom"
syscontact  "Svenn"

第二步:安裝 LibreNMS-Agent


  • 在 LibreNMS 服務上您要先在設定檔裡面新增一行 vim /opt/librenms/config.php
$config['enable_proxmox'] = 1;
  • 回到 PVE 主機更新套件
apt update
  • 再下載 libpve-apiclient-perlsudo 套件
apt install libpve-apiclient-perl sudo -y
  • 然後再從官網下載 PVE 專用套件
wget https://raw.githubusercontent.com/librenms/librenms-agent/master/agent-local/proxmox -O /usr/local/bin/proxmox
  • 設定此套件能有執行權限
chmod +x /usr/local/bin/proxmox
  • 編輯 vim /etc/sudoers 設定方式官方說明不一樣。因為 /etc/passwd 裡面設定的用戶名是 Debian-snmp,而不是官網文件的 snmp,所以要依下面的設定,讓 Debian-snmp 可以不用密碼 sudo/usr/local/bin/proxmox
Debian-snmp     ALL=(ALL) NOPASSWD: /usr/local/bin/proxmox
  • vim /etc/snmp/snmpd.conf 要加一行 extend 描述,官網沒有加上 sudo 執行,這會造成執行權限錯誤。
extend proxmox  /usr/bin/sudo /usr/local/bin/proxmox

# 指令
echo "extend proxmox  /usr/bin/sudo /usr/local/bin/proxmox" >> /etc/snmp/snmpd.conf
  • 設定完成後,記得重跑 snmpd
systemctl restart snmpd



參考相關網頁