LinuxMonitor 1.4.2__tar.gz → 1.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: LinuxMonitor
3
- Version: 1.4.2
3
+ Version: 1.4.4
4
4
  Summary: Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)
5
5
  Home-page: https://github.com/QuentinCG/Linux-Monitor-Python-Library
6
6
  Author: Quentin Comte-Gaz
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: LinuxMonitor
3
- Version: 1.4.2
3
+ Version: 1.4.4
4
4
  Summary: Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)
5
5
  Home-page: https://github.com/QuentinCG/Linux-Monitor-Python-Library
6
6
  Author: Quentin Comte-Gaz
@@ -179,8 +179,14 @@ def main() -> None:
179
179
 
180
180
  if args.list_processes:
181
181
  handled = True
182
- print("Listing active processes...")
183
- out_msg: str = asyncio.run(monitoring.get_ordered_processes(get_non_consuming_processes=False))
182
+ print("Listing active processes (ordered by RAM usage)...")
183
+ out_msg: str = asyncio.run(monitoring.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=True))
184
+ print(out_msg)
185
+
186
+ if args.list_processes_order_by_cpu:
187
+ handled = True
188
+ print("Listing active processes (ordered by CPU usage)...")
189
+ out_msg: str = asyncio.run(monitoring.get_ordered_processes(get_non_consuming_processes=False, order_by_ram=False))
184
190
  print(out_msg)
185
191
 
186
192
  if args.kill_process is not None:
@@ -33,7 +33,7 @@ __email__ = "quentin@comte-gaz.com"
33
33
  __license__ = "MIT License"
34
34
  __copyright__ = "Copyright Quentin Comte-Gaz (2024)"
35
35
  __python_version__ = "3.+"
36
- __version__ = "1.4.2 (2024/10/07)"
36
+ __version__ = "1.4.4 (2024/10/07)"
37
37
  __status__ = "Usable for any Linux project"
38
38
 
39
39
  import json
@@ -1672,11 +1672,12 @@ class LinuxMonitor:
1672
1672
 
1673
1673
  #region Processes
1674
1674
 
1675
- async def get_ordered_processes(self, get_non_consuming_processes: bool = False) -> str:
1675
+ async def get_ordered_processes(self, get_non_consuming_processes: bool = False, order_by_ram: bool = True) -> str:
1676
1676
  """
1677
1677
  Get the ordered list of processes by memory and CPU usage.
1678
1678
 
1679
1679
  :param get_non_consuming_processes: If True, get all processes, otherwise only get processes consuming resources.
1680
+ :param order_by_ram: If True, order by RAM usage, otherwise order by CPU usage.
1680
1681
 
1681
1682
  :return: A string containing the result message.
1682
1683
  """
@@ -1707,7 +1708,7 @@ class LinuxMonitor:
1707
1708
  'pid': process.info['pid'],
1708
1709
  'name': process.info['name'],
1709
1710
  'username': process.info['username'],
1710
- 'cpu_percent': process.cpu_percent(interval=None),
1711
+ 'cpu_percent': process.info['cpu_percent'],
1711
1712
  'memory': process.info['memory_info'].rss, # Resident Set Size (RSS) memory
1712
1713
  'create_time': create_time,
1713
1714
  'cmdline': cmdline
@@ -1716,7 +1717,7 @@ class LinuxMonitor:
1716
1717
  pass
1717
1718
 
1718
1719
  # Sort processes by memory usage, then by CPU usage, both in descending order
1719
- processes.sort(key=lambda proc: (proc['memory'], proc['cpu_percent'], proc['create_time']), reverse=True) # type: ignore
1720
+ processes.sort(key=lambda proc: (order_by_ram ? proc['memory']: proc['cpu_percent'], order_by_ram ? proc['cpu_percent']: proc['memory'], proc['create_time']), reverse=True) # type: ignore
1720
1721
 
1721
1722
  full_res: str = ""
1722
1723
  for proc in processes: # type: ignore
@@ -6,7 +6,7 @@ with io.open(file='README.md', mode='r', encoding='utf-8') as readme_file:
6
6
 
7
7
  setup(
8
8
  name="LinuxMonitor",
9
- version="1.4.2",
9
+ version="1.4.4",
10
10
  description="Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)",
11
11
  long_description=readme,
12
12
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes