CMDB是运维自动化的基础,它为日志系统,发布系统,监控系统等运维系统(ELK,zabbix,open-falcon)提供接口函数,

第一种方式:Agent方法实现,agent不能直接访问数据库,因为agent端有可能被入侵,入侵之后,黑客可以获取数据库权限,造成删库等损失,所以得用url方式

####server

from django.shortcuts import render,HttpResponse

# Create your views here.

def asset(request):
    if request.method == "POST":
        print(request.POST)
        # 写入到数据
        return HttpResponse('1002')
    else:
        return HttpResponse('姿势不对')


####agent
import subprocess
import requests

v1 = subprocess.getoutput("ifconfig")
value1 = (v1[51:55])

v2 = subprocess.getoutput("dir")
value2 = (v2[14:20])

url = "http://127.0.0.1:8000/asset.html"

response = requests.post(url,data={"k1":value1,"k2":value2})
print(response.text)
View Code

相关文章:

  • 2021-05-22
  • 2021-11-17
  • 2021-11-17
  • 2022-12-23
  • 2021-12-27
  • 2021-11-29
  • 2022-12-23
  • 2021-12-02
猜你喜欢
  • 2022-02-14
  • 2021-08-11
  • 2022-12-23
  • 2021-12-16
  • 2021-12-20
  • 2022-12-23
  • 2021-12-11
相关资源
相似解决方案