aiopsutil


Nameaiopsutil JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
Summaryaiopsutil is an asynchronous version of the popular psutil library, designed to provide an efficient and non-blocking way to retrieve information on running processes and system utilization.
upload_time2025-02-08 01:11:38
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseBSD 3-Clause License Copyright (c) 2025, SSSSSNOWWWWW Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords aiopsutil async psutil psutil
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aiopsutil-python

**aiopsutil: Asynchronous Utilities for Gathering System and Process Information**

`aiopsutil` is an asynchronous version of the popular `psutil` library, designed to provide an efficient and non-blocking way to retrieve information on running processes and system utilization. This Python package is tailored for developers who need to monitor and manage system resources in an asynchronous programming environment.

## Table of Contents
- [Key Features](#key-features)
- [Installation](#installation)
- [Initialization](#initialization)
- [API Methods](#api-methods)
- [AsyncProcess Class](#asyncprocess-class)
- [Usage Examples](#usage-examples)
- [Contributing](#contributing)
- [License](#license)

## Key Features
- **Asynchronous Operations**: Leverage Python's `asyncio` library to perform system and process monitoring without blocking the event loop.
- **Comprehensive Functionality**: Offers a rich set of functions to retrieve information about system CPU, memory, disks, network, sensors, and running processes.
- **Ease of Integration**: Designed with a familiar interface for users of `psutil`, making it easy to adopt in existing projects.
- **Cross-Platform Support**: Works on multiple operating systems, including Linux, Windows, and macOS.

## Installation
To use `aiopsutil`, you must have `psutil` installed. You can install it using pip:
```bash
pip install psutil
```

## Initialization
Create an instance of `AsyncPSUtil` within an asynchronous context:
```python
async def main():
    aps = AsyncPSUtil()
    # Use aps to call methods...
```

## API Methods
`aiopsutil` provides a variety of methods to asynchronously gather system and process information. Here's a brief overview:

### CPU Related
- `cpu_percent(interval: float = 0.1, percpu: bool = False) -> float`: Get CPU usage percentage.
- `cpu_stats() -> Dict`: Return CPU statistics.
- `cpu_freq(percpu: bool = False) -> Dict`: Get CPU frequency information.

### Memory Related
- `virtual_memory() -> Dict`: Return virtual memory information.
- `swap_memory() -> Dict`: Return swap memory information.

### Disk Related
- `disk_usage(path: str = "/") -> Dict`: Get disk usage information for the given path.
- `disk_io_counters(perdisk: bool = False) -> Dict`: Return disk I/O statistics.

### Network Related
- `net_io_counters(pernic: bool = False) -> Dict`: Return network I/O statistics.
- `net_connections(kind: str = 'inet') -> List[Dict]`: Return a list of network connections.

### Sensors Related
- `sensors_temperatures() -> Dict`: Return temperature data grouped by sensor.
- `sensors_battery() -> Dict`: Return battery status information.

### System Information
- `boot_time() -> float`: Return system boot timestamp.
- `users() -> List[Dict]`: Return a list of logged-in users.

### Process Management
- `process_iter(attrs: List[str] = None)`: An asynchronous iterator for iterating over processes.
- `process_by_pid(pid: int) -> AsyncProcess`: Get a process object by PID.

## AsyncProcess Class
The `AsyncProcess` class provides methods to interact with individual processes:
- `memory_info() -> Dict`: Return memory information.
- `terminate()` / `kill()`: Terminate the process.
- `children(recursive: bool = False) -> List[AsyncProcess]`: Get a list of child processes.

## Usage Examples
Here's an example of how to use `aiopsutil` to monitor system resources:
```python
import asyncio

async def monitor_system():
    aps = AsyncPSUtil()
    
    # Get CPU usage
    cpu_usage = await aps.cpu_percent(interval=1)
    print(f"CPU Usage: {cpu_usage}%")
    
    # Get memory information
    mem_info = await aps.virtual_memory()
    print(f"Memory Used: {mem_info['used'] / 1024**3:.2f} GB")
    
    # Iterate over processes
    async for proc in aps.process_iter(['pid', 'name']):
        if proc.info['name'] == 'python':
            p = await aps.process_by_pid(proc.info['pid'])
            mem = await p.memory_info()
            print(f"Python process using {mem['rss']} bytes")

# Run the monitor system function
asyncio.run(monitor_system())
```

## Contributing
Contributions to `aiopsutil` are welcome! Please ensure that your code follows the existing coding standards and passes all tests before submitting a pull request.

## License
`aiopsutil` is licensed under the BSD 3-Clause License. See the LICENSE file for more details.

---

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aiopsutil",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "aiopsutil, async psutil, psutil",
    "author": null,
    "author_email": "\u89e3\u6587 <2965312076@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/94/99/5e1348bd5eff77582e0105d2553ce3fecc489e65b6987a27064371d67662/aiopsutil-0.1.0.tar.gz",
    "platform": null,
    "description": "# aiopsutil-python\n\n**aiopsutil: Asynchronous Utilities for Gathering System and Process Information**\n\n`aiopsutil` is an asynchronous version of the popular `psutil` library, designed to provide an efficient and non-blocking way to retrieve information on running processes and system utilization. This Python package is tailored for developers who need to monitor and manage system resources in an asynchronous programming environment.\n\n## Table of Contents\n- [Key Features](#key-features)\n- [Installation](#installation)\n- [Initialization](#initialization)\n- [API Methods](#api-methods)\n- [AsyncProcess Class](#asyncprocess-class)\n- [Usage Examples](#usage-examples)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Key Features\n- **Asynchronous Operations**: Leverage Python's `asyncio` library to perform system and process monitoring without blocking the event loop.\n- **Comprehensive Functionality**: Offers a rich set of functions to retrieve information about system CPU, memory, disks, network, sensors, and running processes.\n- **Ease of Integration**: Designed with a familiar interface for users of `psutil`, making it easy to adopt in existing projects.\n- **Cross-Platform Support**: Works on multiple operating systems, including Linux, Windows, and macOS.\n\n## Installation\nTo use `aiopsutil`, you must have `psutil` installed. You can install it using pip:\n```bash\npip install psutil\n```\n\n## Initialization\nCreate an instance of `AsyncPSUtil` within an asynchronous context:\n```python\nasync def main():\n    aps = AsyncPSUtil()\n    # Use aps to call methods...\n```\n\n## API Methods\n`aiopsutil` provides a variety of methods to asynchronously gather system and process information. Here's a brief overview:\n\n### CPU Related\n- `cpu_percent(interval: float = 0.1, percpu: bool = False) -> float`: Get CPU usage percentage.\n- `cpu_stats() -> Dict`: Return CPU statistics.\n- `cpu_freq(percpu: bool = False) -> Dict`: Get CPU frequency information.\n\n### Memory Related\n- `virtual_memory() -> Dict`: Return virtual memory information.\n- `swap_memory() -> Dict`: Return swap memory information.\n\n### Disk Related\n- `disk_usage(path: str = \"/\") -> Dict`: Get disk usage information for the given path.\n- `disk_io_counters(perdisk: bool = False) -> Dict`: Return disk I/O statistics.\n\n### Network Related\n- `net_io_counters(pernic: bool = False) -> Dict`: Return network I/O statistics.\n- `net_connections(kind: str = 'inet') -> List[Dict]`: Return a list of network connections.\n\n### Sensors Related\n- `sensors_temperatures() -> Dict`: Return temperature data grouped by sensor.\n- `sensors_battery() -> Dict`: Return battery status information.\n\n### System Information\n- `boot_time() -> float`: Return system boot timestamp.\n- `users() -> List[Dict]`: Return a list of logged-in users.\n\n### Process Management\n- `process_iter(attrs: List[str] = None)`: An asynchronous iterator for iterating over processes.\n- `process_by_pid(pid: int) -> AsyncProcess`: Get a process object by PID.\n\n## AsyncProcess Class\nThe `AsyncProcess` class provides methods to interact with individual processes:\n- `memory_info() -> Dict`: Return memory information.\n- `terminate()` / `kill()`: Terminate the process.\n- `children(recursive: bool = False) -> List[AsyncProcess]`: Get a list of child processes.\n\n## Usage Examples\nHere's an example of how to use `aiopsutil` to monitor system resources:\n```python\nimport asyncio\n\nasync def monitor_system():\n    aps = AsyncPSUtil()\n    \n    # Get CPU usage\n    cpu_usage = await aps.cpu_percent(interval=1)\n    print(f\"CPU Usage: {cpu_usage}%\")\n    \n    # Get memory information\n    mem_info = await aps.virtual_memory()\n    print(f\"Memory Used: {mem_info['used'] / 1024**3:.2f} GB\")\n    \n    # Iterate over processes\n    async for proc in aps.process_iter(['pid', 'name']):\n        if proc.info['name'] == 'python':\n            p = await aps.process_by_pid(proc.info['pid'])\n            mem = await p.memory_info()\n            print(f\"Python process using {mem['rss']} bytes\")\n\n# Run the monitor system function\nasyncio.run(monitor_system())\n```\n\n## Contributing\nContributions to `aiopsutil` are welcome! Please ensure that your code follows the existing coding standards and passes all tests before submitting a pull request.\n\n## License\n`aiopsutil` is licensed under the BSD 3-Clause License. See the LICENSE file for more details.\n\n---\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License\n        \n        Copyright (c) 2025, SSSSSNOWWWWW\n        \n        Redistribution and use in source and binary forms, with or without\n        modification, are permitted provided that the following conditions are met:\n        \n        1. Redistributions of source code must retain the above copyright notice, this\n           list of conditions and the following disclaimer.\n        \n        2. Redistributions in binary form must reproduce the above copyright notice,\n           this list of conditions and the following disclaimer in the documentation\n           and/or other materials provided with the distribution.\n        \n        3. Neither the name of the copyright holder nor the names of its\n           contributors may be used to endorse or promote products derived from\n           this software without specific prior written permission.\n        \n        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n        ",
    "summary": "aiopsutil is an asynchronous version of the popular psutil library, designed to provide an efficient and non-blocking way to retrieve information on running processes and system utilization.",
    "version": "0.1.0",
    "project_urls": {
        "Bug Reports": "https://github.com/nostalgiatan/aiopsutil-python/issues",
        "repository": "https://github.com/nostalgiatan/aiopsutil-python"
    },
    "split_keywords": [
        "aiopsutil",
        " async psutil",
        " psutil"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "abe5d86e0814810aca160cd5f4daaf89866b629c5c9c24572f3c75072a898d0e",
                "md5": "4906c5f26a60daa16fe83633cba4f463",
                "sha256": "57625dcf90acb672df3ffd9c59cd8bccb7effba12697a973bf9d3cb9477f1324"
            },
            "downloads": -1,
            "filename": "aiopsutil-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4906c5f26a60daa16fe83633cba4f463",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 7914,
            "upload_time": "2025-02-08T01:11:36",
            "upload_time_iso_8601": "2025-02-08T01:11:36.660989Z",
            "url": "https://files.pythonhosted.org/packages/ab/e5/d86e0814810aca160cd5f4daaf89866b629c5c9c24572f3c75072a898d0e/aiopsutil-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "94995e1348bd5eff77582e0105d2553ce3fecc489e65b6987a27064371d67662",
                "md5": "3f5cde300f0e61ad91f91938d00c05e4",
                "sha256": "9dc6f82d8fbd7921b8c68631adb5c87b161033e2f9d9c86c0e16db1a9ed96ff1"
            },
            "downloads": -1,
            "filename": "aiopsutil-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3f5cde300f0e61ad91f91938d00c05e4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8051,
            "upload_time": "2025-02-08T01:11:38",
            "upload_time_iso_8601": "2025-02-08T01:11:38.836409Z",
            "url": "https://files.pythonhosted.org/packages/94/99/5e1348bd5eff77582e0105d2553ce3fecc489e65b6987a27064371d67662/aiopsutil-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-08 01:11:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nostalgiatan",
    "github_project": "aiopsutil-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aiopsutil"
}
        
Elapsed time: 0.71328s