...
 
Commits (2)
......@@ -7,6 +7,7 @@ verify_ssl = true
[packages]
ipython = "*"
psutil = "*"
[requires]
python_version = "3.8"
python_version = "3.7"
{
"_meta": {
"hash": {
"sha256": "82119c477cfe55e8c4a836bc241def1d8a1262f46e8cb2f7d8023067781250f3"
"sha256": "1f06c618652f6f97e25876d59d98bc5d486cc5b10fd547af5340fb386d7bec23"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
"python_version": "3.7"
},
"sources": [
{
......@@ -81,6 +81,23 @@
],
"version": "==3.0.5"
},
"psutil": {
"hashes": [
"sha256:1413f4158eb50e110777c4f15d7c759521703bd6beb58926f1d562da40180058",
"sha256:298af2f14b635c3c7118fd9183843f4e73e681bb6f01e12284d4d70d48a60953",
"sha256:60b86f327c198561f101a92be1995f9ae0399736b6eced8f24af41ec64fb88d4",
"sha256:685ec16ca14d079455892f25bd124df26ff9137664af445563c1bd36629b5e0e",
"sha256:73f35ab66c6c7a9ce82ba44b1e9b1050be2a80cd4dcc3352cc108656b115c74f",
"sha256:75e22717d4dbc7ca529ec5063000b2b294fc9a367f9c9ede1f65846c7955fd38",
"sha256:a02f4ac50d4a23253b68233b07e7cdb567bd025b982d5cf0ee78296990c22d9e",
"sha256:d008ddc00c6906ec80040d26dc2d3e3962109e40ad07fd8a12d0284ce5e0e4f8",
"sha256:d84029b190c8a66a946e28b4d3934d2ca1528ec94764b180f7d6ea57b0e75e26",
"sha256:e2d0c5b07c6fe5a87fa27b7855017edb0d52ee73b71e6ee368fae268605cc3f5",
"sha256:f344ca230dd8e8d5eee16827596f1c22ec0876127c28e800d7ae20ed44c4b310"
],
"index": "pypi",
"version": "==5.7.0"
},
"ptyprocess": {
"hashes": [
"sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0",
......
......@@ -6,7 +6,7 @@ After=syslog.target network.target
Type=simple
User=osinfo
Group=osinfo
ExecStart=/usr/bin/python3 /opt/osinfo/server.py
ExecStart=/usr/bin/python3.7 /opt/osinfo/server.py
[Install]
WantedBy=multi-user.target
......
......@@ -11,6 +11,7 @@ import os
import sys
import subprocess
import socket
import psutil
LOG = logging.getLogger("osinfo")
......@@ -66,16 +67,18 @@ def main(host="0.0.0.0", port=7777):
out = subprocess.run(["/usr/bin/lsb_release", "-ds"], stdout=subprocess.PIPE)
os_name = out.stdout.decode().replace('\n', '')
os_version = get_os_version()
os_users = get_users_linux()
# os_users = get_users_linux()
elif system == 'Windows':
# Windows 10
os_name = "%s %s" % (system, platform.release())
os_version = platform.version()
os_users = get_users_windows()
# os_users = get_users_windows()
message = "%s;%s;%s" % (os_name, os_version, os_users)
os_users = len(psutil.users())
# message = "%s;%s;%s" % (os_name, os_version, os_users)
message = f"{os_name};{os_version};{os_users}"
LOG.debug("sending: " + str(message))
LOG.debug(f"sending: {message}")
conn.send(message.encode())
conn.close()
......@@ -117,7 +120,7 @@ def get_users_linux():
def get_users_windows():
try:
out = subprocess.run(["quser"], stdout=subprocess.PIPE)
out = subprocess.run(["c:\Windows\System32\quser.exe"], stdout=subprocess.PIPE)
txt = out.stdout.decode()
LOG.debug(txt)
nb = txt.count("Actif")
......