Skip to content

Commit

Permalink
running containers added
Browse files Browse the repository at this point in the history
  • Loading branch information
prasaanth2k committed Sep 9, 2024
1 parent fba4b28 commit eceaa52
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions monisys/Managers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ def __init__(self,args:Arguments):
system.display_uptime()
if self.args.hasOptions(["--docker-images"]) or self.args.hasOptions(["-di"]):
system.get_docker_images()
if self.args.hasOptions(["--display-running-containers"]) or self.args.hasOptions(["-rc"]):
system.get_all_running_containers()
21 changes: 21 additions & 0 deletions monisys/Managers/systeminfocli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self):
self.periferal_com = SystemInfo("pci_devices")
self.uptime = SystemInfo("uptime")
self.docker_images = SystemInfo("docker_images")
self.docker_containers = SystemInfo("docker_containers")
self.console = Console()

def get_cpuinfo(self):
Expand Down Expand Up @@ -291,4 +292,24 @@ def get_docker_images(self):

table.add_row(tags, created, image_id, f"{size_mb} MB")

console.print(table)

def get_all_running_containers(self):
dockerrunningcontainers = self.docker_containers.get_all_data()
console = Console()
table = Table(title="Docker Containers", show_header=True, header_style="bold magenta", show_lines=True)

table.add_column("Name",style="cyan")
table.add_column("State",style="yellow")
table.add_column("ID",style="bold green")
table.add_column("privileged",style="green")

for containers in dockerrunningcontainers:
name = containers['name']
state = containers['state']
containerid = containers['id']
privileged = containers['privileged']

table.add_row(name, state, containerid, privileged)

console.print(table)
2 changes: 2 additions & 0 deletions monisys/monicli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def helpmessage(self):
table.add_row("-ut,--display-uptime","Shows the display uptime")
table.add_row("-ud,--display-usbdevices","Show the usb devices")
table.add_row("-dp,--display-peripheral_compo","Show the Peripheral Components")
table.add_row("-di,--docker-images","Show the docker images")
table.add_row("-rc,--display-running-containers","Show the running docker containers")
panel = Panel(
table, title="[Options]", title_align="left", border_style="bold white"
)
Expand Down
2 changes: 1 addition & 1 deletion monitest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
import time
from monisys.Managers.Systeminfo import SystemInfo
system_info = SystemInfo('docker_images')
system_info = SystemInfo('docker_info')

cpuinfo = system_info.get_all_data()

Expand Down

0 comments on commit eceaa52

Please sign in to comment.