Skip to content

Commit

Permalink
CLI Changed
Browse files Browse the repository at this point in the history
  • Loading branch information
prasaanth2k committed Aug 13, 2024
1 parent 11ce223 commit dc24e9d
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 735 deletions.
19 changes: 5 additions & 14 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
from monisys.Managers.dockermanager import Dockermanage
from monisys.Managers.essentialsmanager import EssentialsManager
from monisys.Managers.systemresourses import Cpuinforesponse , CpuidResponse
import time
from monisys.Managers.Systeminfo import SystemInfo
kernel_info = SystemInfo('uptime')

# Create instances of the managers
cpuinfo = Cpuinforesponse()
cpuid = CpuidResponse()
docker = Dockermanage()
essentials = EssentialsManager()

# docker_images = docker.images()
# for image in docker_images:
# print(image.id)

print(cpuinfo.manufacturer)
names = kernel_info.get_all_data()
print(names)
30 changes: 30 additions & 0 deletions monisys/Managers/Systeminfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import subprocess
import json

class SystemInfo:
def __init__(self, table_name: str):
self.table_name = table_name

def get_data(self):
try:
# Run the osquery command for the specific table
command = ['osqueryi', '--json', f'SELECT * FROM {self.table_name};']
output = subprocess.run(command, capture_output=True, check=True)
result = json.loads(output.stdout)
return result
except subprocess.CalledProcessError as e:
print(f"Command '{e.cmd}' failed with exit code {e.returncode}")
print(e.stderr)
return None

def get_values_by_key(self, query_key: str):
result = self.get_data()
if not result:
return "No data found"

# Extract values for the specified key
values = [item.get(query_key, 'Key not found') for item in result]
return values

def get_all_data(self):
return self.get_data()
58 changes: 0 additions & 58 deletions monisys/Managers/dockerclimanager.py

This file was deleted.

235 changes: 0 additions & 235 deletions monisys/Managers/dockermanager.py

This file was deleted.

38 changes: 0 additions & 38 deletions monisys/Managers/essentialsclimanager.py

This file was deleted.

Loading

0 comments on commit dc24e9d

Please sign in to comment.