-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11ce223
commit dc24e9d
Showing
10 changed files
with
80 additions
and
735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.