mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 10:02:15 +03:00
registration and login messages extended
This commit is contained in:
parent
4a2fc67eac
commit
eee958a134
4 changed files with 98 additions and 13 deletions
2
debian/control
vendored
2
debian/control
vendored
|
@ -8,5 +8,5 @@ Homepage: http://www.liderahenk.org.tr
|
||||||
|
|
||||||
Package: ahenk
|
Package: ahenk
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: bash, python3 (>= 3), cython, libidn11, libidn11-dev, python3-dev, python3-pip, python3-watchdog, libffi-dev, libssl-dev, python3-paramiko, python3-cpuinfo, python3-psutil (>= 4), libpam-script, python3-sleekxmpp, dmidecode, python3-easygui, notify-osd
|
Depends: bash, python3 (>= 3), cython, libidn11, libidn11-dev, python3-dev, python3-pip, python3-watchdog, libffi-dev, libssl-dev, python3-paramiko, python3-cpuinfo, python3-psutil (>= 4), libpam-script, python3-sleekxmpp, dmidecode, python3-easygui, notify-osd, read-edid
|
||||||
Description: Lider Ahenk is an open source project which provides solutions to manage, monitor and audit unlimited number of different systems and users on a network.
|
Description: Lider Ahenk is an open source project which provides solutions to manage, monitor and audit unlimited number of different systems and users on a network.
|
||||||
|
|
|
@ -70,6 +70,13 @@ class Messaging(object):
|
||||||
data['username'] = username
|
data['username'] = username
|
||||||
data['ipAddresses'] = str(System.Hardware.Network.ip_addresses()).replace('[', '').replace(']', '')
|
data['ipAddresses'] = str(System.Hardware.Network.ip_addresses()).replace('[', '').replace(']', '')
|
||||||
data['timestamp'] = Util.timestamp()
|
data['timestamp'] = Util.timestamp()
|
||||||
|
|
||||||
|
data['hardware.monitors'] = str(System.Hardware.monitors()),
|
||||||
|
data['hardware.screens'] = str(System.Hardware.screens()),
|
||||||
|
data['hardware.usbDevices'] = str(System.Hardware.usb_devices()),
|
||||||
|
data['hardware.printers'] = str(System.Hardware.printers()),
|
||||||
|
data['hardware.systemDefinitions'] = str(System.Hardware.system_definitions()),
|
||||||
|
|
||||||
json_data = json.dumps(data)
|
json_data = json.dumps(data)
|
||||||
self.logger.debug('Login message was created')
|
self.logger.debug('Login message was created')
|
||||||
return json_data
|
return json_data
|
||||||
|
|
|
@ -125,10 +125,16 @@ class Registration:
|
||||||
'hardware.disk.used': System.Hardware.Disk.used(),
|
'hardware.disk.used': System.Hardware.Disk.used(),
|
||||||
'hardware.disk.free': System.Hardware.Disk.free(),
|
'hardware.disk.free': System.Hardware.Disk.free(),
|
||||||
'hardware.disk.partitions': str(parts),
|
'hardware.disk.partitions': str(parts),
|
||||||
|
'hardware.monitors': str(System.Hardware.monitors()),
|
||||||
|
'hardware.screens': str(System.Hardware.screens()),
|
||||||
|
'hardware.usbDevices': str(System.Hardware.usb_devices()),
|
||||||
|
'hardware.printers': str(System.Hardware.printers()),
|
||||||
|
'hardware.systemDefinitions': str(System.Hardware.system_definitions()),
|
||||||
'hardware.memory.total': System.Hardware.Memory.total(),
|
'hardware.memory.total': System.Hardware.Memory.total(),
|
||||||
'hardware.network.ipAddresses': System.Hardware.Network.ip_addresses(),
|
'hardware.network.ipAddresses': str(System.Hardware.Network.ip_addresses()),
|
||||||
'sessions.userNames': System.Sessions.user_name(),
|
'sessions.userNames': str(System.Sessions.user_name()),
|
||||||
'bios.releaseDate': System.BIOS.release_date()[1].replace('\n', '') if System.BIOS.release_date()[0] == 0 else 'n/a',
|
'bios.releaseDate': System.BIOS.release_date()[1].replace('\n', '') if System.BIOS.release_date()[
|
||||||
|
0] == 0 else 'n/a',
|
||||||
'bios.version': System.BIOS.version()[1].replace('\n', '') if System.BIOS.version()[0] == 0 else 'n/a',
|
'bios.version': System.BIOS.version()[1].replace('\n', '') if System.BIOS.version()[0] == 0 else 'n/a',
|
||||||
'bios.vendor': System.BIOS.vendor()[1].replace('\n', '') if System.BIOS.vendor()[0] == 0 else 'n/a',
|
'bios.vendor': System.BIOS.vendor()[1].replace('\n', '') if System.BIOS.vendor()[0] == 0 else 'n/a',
|
||||||
'hardware.baseboard.manufacturer': System.Hardware.BaseBoard.manufacturer()[1].replace('\n', '') if
|
'hardware.baseboard.manufacturer': System.Hardware.BaseBoard.manufacturer()[1].replace('\n', '') if
|
||||||
|
|
|
@ -2,18 +2,21 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Author: Volkan Şahin <volkansah.in> <bm.volkansahin@gmail.com>
|
# Author: Volkan Şahin <volkansah.in> <bm.volkansahin@gmail.com>
|
||||||
|
|
||||||
import platform
|
|
||||||
import psutil
|
|
||||||
import cpuinfo
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import configparser
|
import configparser
|
||||||
import socket
|
|
||||||
import fcntl
|
import fcntl
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
|
import socket
|
||||||
import struct
|
import struct
|
||||||
from uuid import getnode as get_mac
|
from uuid import getnode as get_mac
|
||||||
from base.util.util import Util
|
|
||||||
|
import cpuinfo
|
||||||
|
import psutil
|
||||||
|
|
||||||
from base.scope import Scope
|
from base.scope import Scope
|
||||||
|
from base.util.util import Util
|
||||||
|
|
||||||
|
|
||||||
class System:
|
class System:
|
||||||
|
@ -472,6 +475,77 @@ class System:
|
||||||
|
|
||||||
return arr
|
return arr
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def screen_info_json_obj(info):
|
||||||
|
label_list = [
|
||||||
|
# 'Identifier',
|
||||||
|
'ModelName', 'VendorName', 'Monitor Manufactured', 'DisplaySize',
|
||||||
|
# 'Gamma',
|
||||||
|
# 'Horizsync',
|
||||||
|
# 'VertRefresh'
|
||||||
|
]
|
||||||
|
data = dict()
|
||||||
|
|
||||||
|
for line in info.splitlines():
|
||||||
|
line = line.strip().replace('"', '')
|
||||||
|
intersection = list(set(line.split(' ')).intersection(label_list))
|
||||||
|
if len(intersection) > 0:
|
||||||
|
data[str(intersection[0])] = line.split(intersection[0])[1].strip()
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def monitors():
|
||||||
|
edid_list = glob.glob('/sys/class/drm/*/edid')
|
||||||
|
|
||||||
|
monitor_list = list()
|
||||||
|
for edid in edid_list:
|
||||||
|
result_code, p_out, p_err = Util.execute('parse-edid < {0}'.format(edid))
|
||||||
|
|
||||||
|
if result_code == 0:
|
||||||
|
monitor_list.append(System.Hardware.screen_info_json_obj(p_out))
|
||||||
|
|
||||||
|
return monitor_list
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def screens():
|
||||||
|
result_code, p_out, p_err = Util.execute('xrandr')
|
||||||
|
arr = []
|
||||||
|
if result_code == 0:
|
||||||
|
for line in p_out.splitlines():
|
||||||
|
if len(list(set(line.split(' ')).intersection(['connected']))) > 0:
|
||||||
|
arr.append(line)
|
||||||
|
return arr
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def usb_devices():
|
||||||
|
result_code, p_out, p_err = Util.execute('lsusb')
|
||||||
|
arr = []
|
||||||
|
if result_code == 0:
|
||||||
|
for line in p_out.splitlines():
|
||||||
|
if ':' in line and 'Device 001' not in line.split(':')[0]:
|
||||||
|
arr.append(line)
|
||||||
|
return arr
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def printers():
|
||||||
|
result_code, p_out, p_err = Util.execute('lpstat -a')
|
||||||
|
arr = None
|
||||||
|
if result_code == 0:
|
||||||
|
arr = p_out.splitlines()
|
||||||
|
return arr
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def system_definitions():
|
||||||
|
result_code, p_out, p_err = Util.execute('dmidecode -t system')
|
||||||
|
arr = []
|
||||||
|
if result_code == 0:
|
||||||
|
for line in p_out.splitlines():
|
||||||
|
line = line.strip()
|
||||||
|
if len(list(set(line.split(' ')).intersection(['Manufacturer:', 'Product']))) > 0:
|
||||||
|
arr.append(line)
|
||||||
|
return arr
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def machine_type():
|
def machine_type():
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
@ -479,7 +553,6 @@ class System:
|
||||||
config.read(System.Ahenk.config_path())
|
config.read(System.Ahenk.config_path())
|
||||||
return config.get('MACHINE', 'type')
|
return config.get('MACHINE', 'type')
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def interfaces_details():
|
def interfaces_details():
|
||||||
return psutil.net_if_addrs()
|
return psutil.net_if_addrs()
|
||||||
|
@ -543,4 +616,3 @@ class System:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def model():
|
def model():
|
||||||
return cpuinfo.get_cpu_info()['model']
|
return cpuinfo.get_cpu_info()['model']
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue