{"id":37318450,"url":"https://github.com/mariosergiosl/memusage","last_synced_at":"2026-01-16T03:14:23.887Z","repository":{"id":263893337,"uuid":"888592952","full_name":"mariosergiosl/memusage","owner":"mariosergiosl","description":"This tool displays the memory usage of processes on a Linux system,  including total system memory, free memory, and used memory.  It also shows the memory usage of each process in a hierarchical tree format.","archived":false,"fork":false,"pushed_at":"2025-10-03T20:10:28.000Z","size":230,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-03T20:33:57.367Z","etag":null,"topics":["automation","automations","devops","linux","memory-usage","process-monitoring","psutil","python","security","security-tools","sysadmin","troubleshooting"],"latest_commit_sha":null,"homepage":"https://build.opensuse.org/project/show/home:mariosergiosl:memusage","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mariosergiosl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-14T17:01:34.000Z","updated_at":"2025-10-03T20:10:32.000Z","dependencies_parsed_at":"2025-06-12T21:43:25.251Z","dependency_job_id":"42a19c31-7b26-45c2-86f6-bbb47a4ab060","html_url":"https://github.com/mariosergiosl/memusage","commit_stats":null,"previous_names":["mariosergiosl/memusage"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/mariosergiosl/memusage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariosergiosl%2Fmemusage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariosergiosl%2Fmemusage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariosergiosl%2Fmemusage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariosergiosl%2Fmemusage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mariosergiosl","download_url":"https://codeload.github.com/mariosergiosl/memusage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariosergiosl%2Fmemusage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","automations","devops","linux","memory-usage","process-monitoring","psutil","python","security","security-tools","sysadmin","troubleshooting"],"created_at":"2026-01-16T03:14:23.188Z","updated_at":"2026-01-16T03:14:23.879Z","avatar_url":"https://github.com/mariosergiosl.png","language":"Python","readme":"# memusage - A Swiss Army knife for comprehensive Linux process analysis\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg?logo=python\u0026logoColor=white)](https://www.python.org/)\n[![Platform: Linux](https://img.shields.io/badge/platform-linux-green.svg?logo=linux\u0026logoColor=white)](https://www.kernel.org/)\n[![GitHub Stars](https://img.shields.io/github/stars/mariosergiosl/memusage?style=social)](https://github.com/mariosergiosl/memusage/stargazers)\n[![GitHub Forks](https://img.shields.io/github/forks/mariosergiosl/memusage?style=social)](https://github.com/mariosergiosl/memusage/network/members)\n[![GitHub Release](https://img.shields.io/github/v/release/mariosergiosl/memusage)](https://github.com/mariosergiosl/memusage/releases)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/mariosergiosl/memusage/python-app.yml?branch=main)](https://github.com/mariosergiosl/memusage/actions)\n[![Issues](https://img.shields.io/github/issues/mariosergiosl/memusage)](https://github.com/mariosergiosl/memusage/issues)\n[![Code Size](https://img.shields.io/github/languages/code-size/mariosergiosl/memusage)](https://github.com/mariosergiosl/memusage)\n[![Last Commit](https://img.shields.io/github/last-commit/mariosergiosl/memusage)](https://github.com/mariosergiosl/memusage/commits/main)\n[![Downloads](https://img.shields.io/github/downloads/mariosergiosl/memusage/total?label=Downloads)](https://github.com/mariosergiosl/memusage/releases)\n\nThis tool provides deep insights into process behavior, making it invaluable for\ntroubleshooting and security auditing. It details:\n\n- Memory usage (current and cumulative process tree).\n- Open files, including extensive disk attributes (filesystem type, mount options,\n  UUIDs, LVM, multipath, disk type, model, vendor, and persistent device aliases).\n- Network connections (local/remote addresses, status).\n- I/O activity (read/write bytes).\n- Executable forensics (MD5 hash for integrity checks).\n- Process context (full command line, security labels like AppArmor/SELinux).\n- Anomaly detection via suspicious environment variables.\n\nDesigned for system administrators, security analysts, and DevOps engineers.\n\n---\n\n## Hands-On Lab: Troubleshooting a High I/O Scenario\n\nWant to see `memusage.py` in action? Follow our step-by-step tutorial to simulate and diagnose a real-world disk I/O bottleneck.\n\n**➡️ [Click here to open the Lab Instructions](./LAB.md)**\n\n---\n\n## Features\n\n`memusage` gives a detailed, hierarchical view of system processes, including:\n\n- **Memory:** Current and cumulative usage for a process and its entire child tree.\n- **Open Files:** Lists open files with extensive disk attributes (filesystem, mount options, UUIDs, LVM, multipath, disk type, model, and vendor).\n- **Network:** Active network connections with addresses, status, and I/O stats.\n- **Disk I/O:** Cumulative read and write bytes for each process.\n- **Forensics:** The MD5 hash of the process executable for integrity verification.\n- **Security:** The process's security context (e.g., AppArmor/SELinux) and highlights potentially suspicious environment variables.\n\n---\n\n## Installation\n\nFor detailed installation instructions, please see the [INSTALL.md](./INSTALL.md) file.\n\n---\n\n## Running code (Not Installation)\n\n1. Install dependency:\n   ```bash\n   pip3 install psutil\n   ```\n\n2. Run the script:\n   ```bash\n   python3 memusage.py\n   ```\n\n---\n\n## Usage - Running code (Not Installation)\n\nRun the script from the command line:\n\n```bash\npython3 memory_usage.py\n```\n\n---\n\n## Usage - if installation\n\nRun the script from the command line:\n\n```bash\nmemusage\n```\n\n---\n\n## Output\n\nThe output will show:\n\n- Total system memory\n- Free system memory\n- Used system memory\n- Total memory usage of the process tree\n- Memory usage of each process with its PID, name, and memory consumption, color-coded by priority:\n  - For each process:\n    - PID\n    - CMDLINE\n    - Executable MD5\n    - Security Context\n    - Loaded Libraries (Non-System)\n    - Process name\n    - Memory usage\n    - Open files\n      - Disk Device Information\n    - Network connections\n    - I/O activity (read and write bytes)\n    - Note: The Read bytes and Write bytes values are cumulative.\n- The output is color-coded based on process priority:\n\n| Priority | Color  | Nice Value  |\n|----------|--------|-------------|\n| High     | Red    | -20, -15, -10 |\n| Medium   | Yellow | -5, 0, 5    |\n| Low      | Green  | 10, 15, 19  |\n\n---\n\n## Testing Color-Coded Output\n\nTo test the color-coded output, you can run processes with different priorities using the `nice` command.\n\n**Examples:**\n\n- High priority:\n  ```bash\n  nice -n -20 yes \u003e /dev/null \u0026\n  ```\n\n- Medium priority:\n  ```bash\n  nice -n -20 yes \u003e /dev/null \u0026\n  ```\n\n- Low priority:\n  ```bash\n  nice -n -20 yes \u003e /dev/null \u0026\n  ```\n\nAfter running these commands, execute `memusage` again and observe the color-coded output.\n\n**Priority Color Table:**\n\n```\nPriority: -20   Color:\nPriority: -19   Color:\nPriority: -18   Color:\nPriority: -17   Color:\nPriority: -16   Color:\nPriority: -15   Color:\nPriority: -14   Color:\nPriority: -13   Color:\nPriority: -12   Color:\nPriority: -11   Color:\nPriority: -10   Color:\nPriority: -9    Color:\nPriority: -8    Color:\nPriority: -7    Color:\nPriority: -6    Color:\nPriority: -5    Color:\nPriority: -4    Color:\nPriority: -3    Color:\nPriority: -2    Color:\nPriority: -1    Color:\nPriority: 0     Color:\nPriority: 1     Color:\nPriority: 2     Color:\nPriority: 3     Color:\nPriority: 4     Color:\nPriority: 5     Color:\nPriority: 6     Color:\nPriority: 7     Color:\nPriority: 8     Color:\nPriority: 9     Color:\nPriority: 10    Color:\nPriority: 11    Color:\nPriority: 12    Color:\nPriority: 13    Color:\nPriority: 14    Color:\nPriority: 15    Color:\nPriority: 16    Color:\nPriority: 17    Color:\nPriority: 18    Color:\nPriority: 19    Color:\n\nTotal system memory: 7877.34375 MB\nFree system memory: 5532.8359375 MB\nUsed system memory: 2344.5078125 MB\n\nTotal memory process tree: 3469.51 MB\n\nMemory usage of each process:\nPID - Process Name (Memory Usage)\n1 - systemd (14.37 MB)\n  - CMDLINE: /usr/lib/systemd/systemd --switched-root --system --deserialize=42\n  - Executable MD5: 0d31356f9ce30df5916faa0a5b4c440a\n  - Security Context: AppArmor: unconfined\n  - Read bytes: 885152256\n  - Write bytes: 529428480\n  600 - systemd-journald (9.88 MB)\n    - CMDLINE: /usr/lib/systemd/systemd-journald\n    - Executable MD5: 95366e94f1ff2fec08432a507a451337\n    - Security Context: AppArmor: unconfined\n    - /proc/sys/kernel/hostname\n    - /run/log/journal/24a550029dff4a95994d4266dd0763e7/system.journal\n    - Read bytes: 225280\n    - Write bytes: 0\n  626 - systemd-udevd (13.00 MB)\n    - CMDLINE: /usr/lib/systemd/systemd-udevd\n    - Executable MD5: 7ba915087bd426a3e2a8d6d63ef6de20\n    - Security Context: AppArmor: unconfined\n    - /etc/udev/hwdb.bin (FSTYPE:btrfs DISK:/dev/sda DEV:sda2 ID:c929e557-b1f5-491e-9740-35c7a3d348d3 UUID:4774239a-1b39-4397-b9d6-ee8bc6315f86 DISK_TYPE:HDD MODEL: VENDOR: ALIASES:[by-path/pci-0000:00:10.0-scsi-0:0:0:0-part2])\n    - Read bytes: 26279424\n    - Write bytes: 0\n  686 - haveged (4.86 MB)\n    - CMDLINE: /usr/sbin/haveged -w 1024 -v 0 -F\n    - Executable MD5: 4feb98b6eb6a768c200ac11336022f33\n    - Security Context: AppArmor: unconfined\n    - Read bytes: 151552\n    - Write bytes: 0\n\n... [continue]\n\n--- End of Report ---\n\nNotes:\n - Accessing some information - \ne.g., open files of other users, multipath, executable hash, env vars, security context\nmay require 'sudo' privileges.\n - Read bytes and Write bytes values are cumulative since process start.\n - 'N/A' means information could not be obtained or is not applicable.\n\n\n--- Understanding Disk Identifiers in Data Centers ---\n - For enterprise storage (SAN/NAS), standard device names like /dev/sda are volatile.\n - Persistent identifiers like UUID and aliases are crucial:\n   - UUID: Universal Unique Identifier of the filesystem on a partition/volume.\n     Often used in /etc/fstab for consistent mounting.\n   - ID (PARTUUID): Unique ID of the partition itself (if applicable).\n     Distinguishes partitions on the same disk when UUIDs might conflict (e.g., after cloning).\n   - ALIASES: Alternate, persistent paths to the device in /dev/disk/ by-id, by-path, by-uuid, by-label.\n     - by-id/: Hardware-based IDs (manufacturer, model, serial). Highly stable.\n     - by-path/: Physical path through hardware (PCI slot, HBA port, SCSI target).\n       * CRUCIAL for SANs: 'by-path' (e.g., pci-0000:00:10.0-scsi-0:0:0:0-part2)\n         can reveal the HBA adapter (e.g., pci-0000:00:10.0), Fibre Channel/iSCSI port,\n         and LUN ID from the storage array. This allows correlation with SAN zoning/masking.\n         It helps identify the physical location of the LUN within the storage infrastructure.\n     - by-uuid/: Symlinks using the filesystem UUID (duplicate of the UUID field, but listed here for completeness of aliases).\n     - by-label/: Symlinks using filesystem labels defined by the user.\n - LVM (Logical Volume Management): Indicates if a file resides on a logical volume.\n   LVM allows flexible storage management over physical volumes.\n - Disk Type (SSD/HDD), Model, Vendor: Provide insights into disk performance characteristics.\n - Multipath (MP_ID, MP_PATHS): Shows if multiple paths exist to the same LUN for redundancy/performance.\n   Common in SAN environments to avoid single points of failure.\n - Command and path limits have been applied for better readability.\n```\n\n---\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request if you have any suggestions or bug reports.\n\n---\n\n## License\n\nThis program is licensed under the GNU General Public License v2 or later.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariosergiosl%2Fmemusage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariosergiosl%2Fmemusage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariosergiosl%2Fmemusage/lists"}