Proxmox VE 安裝及設定 LibreNMS-Agent

第一步:安裝 SNMP 套件

apt install snmpd -y #安裝 SNMP 套件

再把 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

新增完後重新啟動 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;

先更新套件

apt update

再下載 libpve-apiclient-perl 套件,也要下載 sudo 套件

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

/etc/sudoers 裡,要加上的設定跟 Proxmox 官網說明的不同。因為 /etc/passwd 裡面設定的用戶名是 Debian-snmp,而不是官網文件的 snmp,所以要依下面的設定,讓 Debian-snmp 可以不用密碼 sudo 跑 /usr/local/bin/proxmox

Debian-snmp     ALL=(ALL) NOPASSWD: /usr/local/bin/proxmox

在 /etc/snmp/snmpd.conf 要加一行 extend 描述,官網沒有加上 sudo 執行,這會造成執行權限錯誤。

extend proxmox  /usr/bin/sudo /usr/local/bin/proxmox

設定完成後,記得重跑 snmpd

systemctl restart snmpd

 

參考相關網頁: