Changes between Version 2 and Version 3 of resource-hog
- Timestamp:
- Oct 26, 2018, 2:07:10 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
resource-hog
v2 v3 5 5 Here are some tricks to find that user. 6 6 7 == Munin == 8 9 See our [wiki:munin munin page] for how to see graphs that show resource usage over time. 10 7 11 == Resource Hog == 8 12 9 The ` mf-resource-hog` script will output the top CPU users by minute going back between 1 and 2days.13 The `resourcehog` script will output the top CPU, disk and memory users going back up to three days. 10 14 11 You can modify it's behavior in a number of ways: 15 By default, it shows a summary of usage over the last hour. 12 16 13 * `mf-resource-hog cpu`: outputs CPU usage. This is the defalt 14 * `mf-resource-hog disk-read`: outputs disk read in kB per user. 15 * `mf-resource-hog disk-write`: outputs disk writes in kB per user. 16 * `mf-resource-hog tps`: outputs transactions per second per block device (only useful on physical servers). 17 Run `resourcehog -h` to get the full usage: 17 18 18 The second argument specifies an interval: 19 {{{ 20 usage: resourcehog [-h] [--include-root] [--include-system] [--munin] 21 [--resource {cpu,read,write,rss}] [--limit LIMIT] 22 [--include-commands] [--quiet] [--debug] [--since SINCE] 23 [--until UNTIL] 19 24 20 * `mf-resource-hog cpu minute`: outputs usage on a per-minute basis. This is the default. 21 * `mf-resource-hog cpu hour`: outputs usage on a per-hour basis. 22 * `mf-resource-hog cpu day`: outputs usage on a per-day basis. 23 * `mf-resource-hog cpu month`: outputs usage on a per-month basis. 25 Report on resource usage by user. 24 26 25 If you want real-time continuous output, you can run the collector script: 26 27 `mf-resource-hog-collector [cpu|disk-read|disk-write]` 28 29 Or, you can check out `man pidstat` to read up on the underlying tool used to generate this data. 27 optional arguments: 28 -h, --help show this help message and exit 29 --include-root Include root user in the report results 30 --include-system Include root user in the report results 31 --munin Instead of printing a summary of usage, output in a 32 format suitable for munin. 33 --resource {cpu,read,write,rss} 34 Limit to a particular resource, repeat as needed 35 --limit LIMIT Limit results to this number 36 --include-commands Instead of grouping by user, group by user and command 37 --quiet Print less extraneous information 38 --debug Print out sql statements used and other usefuld ebug 39 information 40 --since SINCE Limit results to entries after this data 41 --until UNTIL Limit results to entries before this data 42 }}} 30 43 31 44 === How does it work? === 32 45 33 There are t hree scripts in all:46 There are two python scripts. 34 47 35 ==== mf-resource-hog-collector ====48 ==== resourcehog-collector ==== 36 49 37 When run from a cron job (''not'' a terminal), `mf-resource-hog-collector` runs `pidstat` or `pidstat -d` depending on whether cpu or disk-read/disk-write is passed. It runs for 60 seconds, then totals the usage statistics for each user in the output and writes this output to a file in /var/log/mfpl/resource-hog/minute. 50 This script, written in python, runs via a systemd process and monitors system usage via `pidstat` and then outputs the results every 5 minutes to a sqlite database located on the tempfs /run/resourcehog/rh.db. 38 51 39 When run from a terminal, it outputs the data to standard out instead (and limits output to the top 4 users). 52 ==== resourcehog ==== 40 53 41 This script runs every minute. 42 43 ==== mf-resource-hog-consolidator ==== 44 45 Once an hour, `mf-resource-hog-consolidator` runs. Every hour it averages the totals from /var/log/mfpl/resource-hog/minute and places them in /var/log/mfpl/resource-hog/hour. 46 47 At midnight, it averages the totals from /var/log/mfpl/resource-hog/hour and places them in /var/log/mfpl/resource-hog/day. It also deletes old files that have already been averaged. 48 49 On the first of the month, it averages the totals from /var/log/mfpl/resource-hog/day and places them in /var/log/mfpl/resource-hog/month. 50 51 ==== mf-resource-hog ==== 52 53 The `mf-resource-hog` script is the main user script. It simply displays the output of `head -n4 /var/log/mfpl/resource-hog/[interval]/[resource]`. 54 This script queries the database for you and prints out the results in easy to read format. 54 55 55 56 == sysstat ==