使用LibreNMS添加不支持SNMP协议,但是有IP的设备。批量添加
import requests
import json
# API 配置
api_url = "http://10.40.31.253/api/v0/devices" #实际是信息
api_token = "9560e9254e6e48be8826fd77fe5b031b" # 替换为实际的 API Token
headers = {
"Authorization": f"Bearer {api_token}",
"Content-Type": "application/json"
}
# 读取摄像头信息文件
camera_file = "cameras.txt"
with open(camera_file, "r") as file:
cameras = [line.strip().split(",") for line in file]
# 添加摄像头设备函数
def add_camera(name, ip):
payload = {
"hostname": ip,
"ip": ip,
"status": "1",
"snmp_disable": 1, # 关闭 SNMP
"os": "generic",
"device_type": "other"
}
try: