Пример #1
0
def sendCPU():
    hostname = cpu.getHostname()
    cpuCount = cpu.cpuCount()
    cpuFreq = cpu.cpuFreq()
    cpuPercent = cpu.cpuPercent()

    cpuInfos = {
        "hostname": hostname,
        "count": cpuCount,
        "frequence": cpuFreq[2],
        "min-max": [cpuFreq[0], cpuFreq[1]],
        "percentage": cpuPercent,
        "added": datetime.datetime.now()
    }
    """
    if cpuColl.find_one({"hostname": hostname}):
        print("Mise a jour des infos du CPU de  {} !").format(hostname)
        cpuColl.find_one_and_replace({"hostname": hostname}, cpuInfos)
    else:
        print("Ajout des infos du CPU de : {}").format(hostname)
        cpuColl.insert_one(cpuInfos)
    """

    print("\n\nAjout des infos du CPU de : {}\n").format(hostname)
    cpuColl.insert_one(cpuInfos)

    # suppression des infos datant de plus d'une heure
    date = datetime.datetime.now() - datetime.timedelta(hours=1)
    cpuColl.delete_many({"added": {"$lt": date}})  # NOQA
Пример #2
0
def sendPROCESS():
    x = subprocess.check_output("./sondes/sPROCESS.sh", shell=True)
    hostname = cpu.getHostname()
    mylist = x.split("\n")

    procInfos = {
        "hostname": hostname,
        "total": mylist[0],
        "root": mylist[1]}

    url = 'http://localhost:5001/sonde/sprocess'
    req = requests.post(url, json=procInfos)
    print(req.text)
Пример #3
0
def sendNET():
    hostname = cpu.getHostname()
    network = net.getInfos()

    networkInfos = {
        "hostname": hostname,
        "sent": network[0],
        "recv": network[1],
        "psent": network[2],
        "precv": network[3]}

    url = 'http://localhost:5001/sonde/snetwork'
    req = requests.post(url, json=networkInfos)
    print(req.text)
Пример #4
0
def sendMEM():
    hostname = cpu.getHostname()
    total = mem.total()
    used = mem.used()
    available = mem.available()

    memInfos = {
        "hostname": hostname,
        "total": total,
        "used": used,
        "available": available}

    url = 'http://localhost:5001/sonde/smemory'
    req = requests.post(url, json=memInfos)
    print(req.text)
Пример #5
0
def sendCPU():
    hostname = cpu.getHostname()
    cpuCount = cpu.cpuCount()
    cpuFreq = cpu.cpuFreq()
    cpuPercent = cpu.cpuPercent()

    cpuInfos = {
        "hostname": hostname,
        "count": cpuCount,
        "frequence": cpuFreq[2],
        "min-max": [cpuFreq[0], cpuFreq[1]],
        "percentage": cpuPercent}

    url = 'http://localhost:5001/sonde/scpu'
    req = requests.post(url, json=cpuInfos)
    print(req.text)
Пример #6
0
def sendProcess():
    total, root = proc.getProcessInfos()
    hostname = cpu.getHostname()

    procInfos = {
        "hostname": hostname,
        "total": total,
        "root": root,
        "added": datetime.datetime.now()
    }

    print("\n\nAjout des infos sur les Processus : {}\n").format(hostname)
    procColl.insert_one(procInfos)

    # suppression des infos datant de plus d'une heure
    date = datetime.datetime.now() - datetime.timedelta(hours=1)
    procColl.delete_many({"added": {"$lt": date}})
Пример #7
0
def sendDISK():
    hostname = cpu.getHostname()
    total = disk.total()
    used = disk.used()
    free = disk.free()
    percent = disk.percent()

    diskInfos = {
        "hostname": hostname,
        "total": total,
        "used": used,
        "free": free,
        "percent": percent}

    url = 'http://localhost:5001/sonde/sdisk'
    req = requests.post(url, json=diskInfos)
    print(req.text)
Пример #8
0
def sendNetwork():
    hostname = cpu.getHostname()
    network = net.getInfos()

    networkInfos = {
        "hostname": hostname,
        "sent": network[0],
        "recv": network[1],
        "psent": network[2],
        "precv": network[3],
        "added": datetime.datetime.now()
    }

    print("\n\nAjout des infos de la carte réseau : {}\n").format(hostname)
    netColl.insert_one(networkInfos)

    # suppression des infos datant de plus d'une heure
    date = datetime.datetime.now() - datetime.timedelta(hours=1)
    netColl.delete_many({"added": {"$lt": date}})
Пример #9
0
def sendMEMORY():
    hostname = cpu.getHostname()
    total = mem.total()
    used = mem.used()
    available = mem.available()

    memInfos = {
        "hostname": hostname,
        "total": total,
        "used": used,
        "available": available,
        "added": datetime.datetime.now()
    }

    print("\n\nAjout des infos de la RAM de : {}\n").format(hostname)
    memColl.insert_one(memInfos)

    # suppression des infos datant de plus d'une heure
    date = datetime.datetime.now() - datetime.timedelta(hours=1)
    memColl.delete_many({"added": {"$lt": date}})
Пример #10
0
def sendSensors():
    time = sens.getBootTimes()
    temp = sens.getTemperatures()
    kernel = sens.getKernelInfos()
    hostname = cpu.getHostname()

    procInfos = {
        "hostname": hostname,
        "time": time,
        "temperature": temp,
        "kernel": kernel,
        "added": datetime.datetime.now()
    }

    print("\n\nAjout des infos diverses : {}\n").format(hostname)
    sensColl.insert_one(procInfos)

    # suppression des infos datant de plus d'une heure
    date = datetime.datetime.now() - datetime.timedelta(hours=1)
    sensColl.delete_many({"added": {"$lt": date}})
Пример #11
0
def sendSENSORS():
    try:
        time = sens.getBootTimes()
        temp = sens.getTemperatures()
        kernel = sens.getKernelInfos()
        hostname = cpu.getHostname()

        sensInfos = {
            "hostname": hostname,
            "time": time,
            "temperature": temp,
            "kernel": kernel}

        url = 'http://localhost:5001/sonde/ssensors'
        req = requests.post(url, json=sensInfos)
        print(req.text)

    except Exception:
        print "no sensors"
        return
Пример #12
0
def sendDISK():
    hostname = cpu.getHostname()
    total = disk.total()
    used = disk.used()
    free = disk.free()
    percent = disk.percent()

    diskInfos = {
        "hostname": hostname,
        "total": total,
        "used": used,
        "free": free,
        "percent": percent,
        "added": datetime.datetime.now()
    }

    print("\n\nAjout des infos de de la partiton / de : {}\n").format(hostname)
    diskColl.insert_one(diskInfos)

    # suppression des infos datant de plus d'une heure
    date = datetime.datetime.now() - datetime.timedelta(hours=1)
    diskColl.delete_many({"added": {"$lt": date}})