├── .gitignore ├── LICENSE ├── README.md ├── index.sh └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Mathias Buus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lil-pids-ps 2 | 3 | Run ps with all active lil-pids services 4 | 5 | ``` 6 | npm install -g lil-pids-ps 7 | ``` 8 | 9 | ## Usage 10 | 11 | ``` shell 12 | # simply call lil-pids-ps with a path to the pids file 13 | lil-pids-ps ./pids 14 | ``` 15 | 16 | Running the above will print out status of all running processes and their child processes using `ps`. 17 | 18 | ``` 19 | PID PPID ELAPSED %MEM %CPU COMMAND 20 | 27498 766 05:07:10 0.0 0.0 /bin/sh -c taco-nginx -n hasselhoff node server.js 21 | 27499 27498 05:07:10 0.0 0.0 /bin/bash /usr/local/bin/taco-nginx -n hasselhoff node server.js 22 | 29867 766 15:48 0.0 0.0 /bin/sh -c dat dats/gifs --quiet 23 | 29868 29867 15:48 0.1 0.2 dat 24 | 29869 766 15:48 0.0 0.0 /bin/sh -c dat dats/youtube --quiet 25 | 29870 29869 15:48 0.1 0.3 dat 26 | ``` 27 | 28 | ## License 29 | 30 | MIT 31 | -------------------------------------------------------------------------------- /index.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | EMPTY=true 4 | PIDS_FILE="$1" 5 | [ "$PIDS_FILE" == "" ] && PIDS_FILE="pids" 6 | 7 | if [ ! -f "$PIDS_FILE" ]; then 8 | echo "$PIDS_FILE does not exist. Pass a path to the ./pids file" 9 | exit 1 10 | fi 11 | 12 | cmd="ps -o pid,ppid,etime,%mem,%cpu,args" 13 | for pid in $(cut -c1-5 < "$PIDS_FILE"); do 14 | EMPTY=false 15 | cmd="$cmd -p $pid" 16 | for ppid in $(pgrep -P $pid); do 17 | cmd="$cmd -p $ppid" 18 | done 19 | done 20 | 21 | ($EMPTY && $cmd | head -n 1) || $cmd 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lil-pids-ps", 3 | "version": "1.0.0", 4 | "description": "Run ps with all active lil-pids services", 5 | "main": "index.js", 6 | "bin": { 7 | "lil-pids-ps": "./index.sh" 8 | }, 9 | "dependencies": {}, 10 | "devDependencies": {}, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/mafintosh/lil-pids-ps.git" 14 | }, 15 | "author": "Mathias Buus (@mafintosh)", 16 | "license": "MIT", 17 | "bugs": { 18 | "url": "https://github.com/mafintosh/lil-pids-ps/issues" 19 | }, 20 | "homepage": "https://github.com/mafintosh/lil-pids-ps" 21 | } 22 | --------------------------------------------------------------------------------