mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-15 09:46:11 +01:00
Initial Commit
This commit is contained in:
98
plogical/getSystemInformation.py
Normal file
98
plogical/getSystemInformation.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import platform
|
||||
import os
|
||||
import datetime
|
||||
import math
|
||||
|
||||
class SystemInformation:
|
||||
now = datetime.datetime.now()
|
||||
|
||||
@staticmethod
|
||||
def cpuLoad():
|
||||
return os.getloadavg()
|
||||
|
||||
@staticmethod
|
||||
def getOSName():
|
||||
|
||||
OSName = platform.platform()
|
||||
data = OSName.split("-")
|
||||
|
||||
checker = 0
|
||||
finalOSName = ""
|
||||
|
||||
for items in data:
|
||||
|
||||
if checker == 1:
|
||||
finalOSName = items
|
||||
break
|
||||
|
||||
if items == "with":
|
||||
checker = 1
|
||||
|
||||
return finalOSName
|
||||
|
||||
@staticmethod
|
||||
def getCurrentSystemTime():
|
||||
return SystemInformation.now.strftime("%I:%M")
|
||||
|
||||
@staticmethod
|
||||
def currentWeekDay():
|
||||
return SystemInformation.now.strftime("%a")
|
||||
|
||||
@staticmethod
|
||||
def currentMonth():
|
||||
return SystemInformation.now.strftime("%B")
|
||||
|
||||
@staticmethod
|
||||
def currentYear():
|
||||
return SystemInformation.now.strftime("%Y")
|
||||
|
||||
@staticmethod
|
||||
def currentDay():
|
||||
return SystemInformation.now.strftime("%d")
|
||||
|
||||
@staticmethod
|
||||
def getAllInfo():
|
||||
OSName = SystemInformation.getOSName()
|
||||
loadAverage = SystemInformation.cpuLoad()
|
||||
currentTime = SystemInformation.getCurrentSystemTime()
|
||||
weekDayNameInString = SystemInformation.currentWeekDay()
|
||||
currentMonthName = SystemInformation.currentMonth()
|
||||
currentDayInDecimal = SystemInformation.currentDay()
|
||||
currentYear = SystemInformation.currentYear()
|
||||
loadAverage = list(loadAverage)
|
||||
one = loadAverage[0]
|
||||
two = loadAverage[1]
|
||||
three = loadAverage[2]
|
||||
|
||||
data = {"weekDayNameInString": weekDayNameInString, "currentMonthName": currentMonthName,
|
||||
"currentDayInDecimal": currentDayInDecimal, "currentYear": currentYear, "OSName": OSName,
|
||||
"loadAVG": loadAverage, "currentTime": currentTime, "one":one,"two":two,"three":three}
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@staticmethod
|
||||
def getSystemInformation():
|
||||
try:
|
||||
import psutil
|
||||
SystemInfo = {'ramUsage': int(math.floor(psutil.virtual_memory()[2])), 'cpuUsage': int(math.floor(psutil.cpu_percent())), 'diskUsage': int(math.floor(psutil.disk_usage('/')[3]))}
|
||||
return SystemInfo
|
||||
except:
|
||||
SystemInfo = {'ramUsage': 0,
|
||||
'cpuUsage': 0,
|
||||
'diskUsage': 0}
|
||||
return SystemInfo
|
||||
|
||||
@staticmethod
|
||||
def cpuRamDisk():
|
||||
try:
|
||||
import psutil
|
||||
SystemInfo = {'ramUsage': int(math.floor(psutil.virtual_memory()[2])),
|
||||
'cpuUsage': int(math.floor(psutil.cpu_percent())),
|
||||
'diskUsage': int(math.floor(psutil.disk_usage('/')[3]))}
|
||||
except:
|
||||
SystemInfo = {'ramUsage': 0,
|
||||
'cpuUsage': 0,
|
||||
'diskUsage': 0}
|
||||
|
||||
return SystemInfo
|
||||
Reference in New Issue
Block a user