Changes between Version 2 and Version 3 of resource-hog


Ignore:
Timestamp:
Oct 26, 2018, 10:07:10 AM (11 months ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • resource-hog

    v2 v3  
    55Here are some tricks to find that user.
    66
     7== Munin ==
     8
     9See our [wiki:munin munin page] for how to see graphs that show resource usage over time.
     10
    711== Resource Hog ==
    812
    9 The `mf-resource-hog` script will output the top CPU users by minute going back between 1 and 2 days.
     13The `resourcehog` script will output the top CPU, disk and memory users going back up to three days.
    1014
    11 You can modify it's behavior in a number of ways:
     15By default, it shows a summary of usage over the last hour.
    1216
    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).
     17Run `resourcehog -h` to get the full usage:
    1718
    18 The second argument specifies an interval:
     19{{{
     20usage: 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]
    1924
    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.
     25Report on resource usage by user.
    2426
    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.
     27optional 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}}}
    3043
    3144=== How does it work? ===
    3245
    33 There are three scripts in all:
     46There are two python scripts.
    3447
    35 ==== mf-resource-hog-collector ====
     48==== resourcehog-collector ====
    3649
    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.
     50This 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.
    3851
    39 When run from a terminal, it outputs the data to standard out instead (and limits output to the top 4 users).
     52==== resourcehog ====
    4053
    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]`.
     54This script queries the database for you and prints out the results in easy to read format.
    5455
    5556== sysstat ==