{"id":16686381,"url":"https://github.com/yoheimuta/linux-getpidstat","last_synced_at":"2025-04-10T00:16:26.557Z","repository":{"id":56836394,"uuid":"59872994","full_name":"yoheimuta/Linux-GetPidstat","owner":"yoheimuta","description":"Monitor each process metrics avg using each pidfile","archived":false,"fork":false,"pushed_at":"2019-03-28T09:17:42.000Z","size":102,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T00:16:17.902Z","etag":null,"topics":["linux","mackerel","monitor","perl5","pidstat","process-monitor"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoheimuta.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-28T02:09:21.000Z","updated_at":"2019-09-26T00:16:53.000Z","dependencies_parsed_at":"2022-09-09T20:02:11.210Z","dependency_job_id":null,"html_url":"https://github.com/yoheimuta/Linux-GetPidstat","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2FLinux-GetPidstat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2FLinux-GetPidstat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2FLinux-GetPidstat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2FLinux-GetPidstat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoheimuta","download_url":"https://codeload.github.com/yoheimuta/Linux-GetPidstat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131315,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["linux","mackerel","monitor","perl5","pidstat","process-monitor"],"created_at":"2024-10-12T15:05:41.750Z","updated_at":"2025-04-10T00:16:26.534Z","avatar_url":"https://github.com/yoheimuta.png","language":"Perl","readme":"\u003cdiv\u003e\n    \u003ca href=\"https://travis-ci.org/yoheimuta/Linux-GetPidstat\"\u003e\u003cimg src=\"https://travis-ci.org/yoheimuta/Linux-GetPidstat.svg?branch=master\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n# NAME\n\nLinux::GetPidstat - Monitor each process metrics avg using each pidfile\n\n# SYNOPSIS\n\n    use Linux::GetPidstat;\n\n    my $stat = Linux::GetPidstat-\u003enew;\n    $stat-\u003erun(%opt);\n\n# DESCRIPTION\n\nRun `pidstat -h -u -r -s -d -w -p $pid $interval $count` commands in parallel to monitor each process metrics avg/1min.\n\nOutput to a specified file \\[and|or\\] `mackerel service` https://mackerel.io.\n\n## Motivation\n\nA batch server runs many batch scripts at the same time.\n\nWhen this server suffers by a resource short, it's difficult to grasp which processes are heavy quickly.\n\nRunning pidstat manually is not appropriate in this situation, because\n\n- the target processes are changed by starting each job.\n- the target processes may run child processes recursively.\n\n## Requirements\n\npidstat\npstree\n\n## Usage\n\nPrepare pid files in a specified directory.\n\n    $ mkdir /tmp/pid_dir\n    $ echo 1234 \u003e /tmp/pid_dir/target_script\n    $ echo 1235 \u003e /tmp/pid_dir/target_script2\n    # In production, this file is made and removed by the batch script itself for instance.\n\nRun the script every 1 mininute.\n\n    # vi /etc/cron.d/linux-get-pidstat\n    * * * * * user carton exec -- linux-get-pidstat --no-dry_run --pid_dir=/tmp/pid_dir --res_dir=/tmp/bstat.log\n\nDone, you can monitor the result.\n\n    $ tail -f /tmp/bstat.log\n    # start(datetime),start(epoch),pidfilename,name,value\n    2016-04-02T19:49:32,1459594172,target_script,cswch_per_sec,19.87\n    2016-04-02T19:49:32,1459594172,target_script,stk_ref,25500\n    2016-04-02T19:49:32,1459594172,target_script,memory_percent,34.63\n    2016-04-02T19:49:32,1459594172,target_script,memory_rss,10881534000\n    2016-04-02T19:49:32,1459594172,target_script,stk_size,128500\n    2016-04-02T19:49:32,1459594172,target_script,nvcswch_per_sec,30.45\n    2016-04-02T19:49:32,1459594172,target_script,cpu,21.2\n    2016-04-02T19:49:32,1459594172,target_script,disk_write_per_sec,0\n    2016-04-02T19:49:32,1459594172,target_script,disk_read_per_sec,0\n    2016-04-02T19:49:32,1459594172,target_script2,memory_rss,65289204000\n    2016-04-02T19:49:32,1459594172,target_script2,memory_percent,207.78\n    2016-04-02T19:49:32,1459594172,target_script2,stk_ref,153000\n    2016-04-02T19:49:32,1459594172,target_script2,cswch_per_sec,119.22\n    2016-04-02T19:49:32,1459594172,target_script2,nvcswch_per_sec,182.7\n    2016-04-02T19:49:32,1459594172,target_script2,cpu,127.2\n    2016-04-02T19:49:32,1459594172,target_script2,disk_read_per_sec,0\n    2016-04-02T19:49:32,1459594172,target_script2,disk_write_per_sec,0\n    2016-04-02T19:49:32,1459594172,target_script2,stk_size,771000\n\n### Mackerel\n\nPost the results to service metrics.\n\n    $ carton exec -- linux-get-pidstat \\\n    --no-dry_run \\\n    --pid_dir=/tmp/pid_dir \\\n    --mackerel_api_key=yourkey \\\n    --mackerel_service_name=yourservice\n\n### Help\n\nDisplay how to use.\n\n    $ carton exec -- linux-get-pidstat --help\n    Usage:\n            linux-get-pidstat - command description\n              Usage: command [options]\n              Options:\n                --pid_dir                     A directory path for pid files\n                --res_file                    A file path to be stored results\n                --interval                    Interval second to be given as a pidstat argument (default:1)\n                --count                       Count number to be given as a pidstat argument (default:60)\n                --dry_run                     Dry run mode. not run the side-effects operation (default:1) (--no-dry_run is also supported)\n                --datetime                    Datetime (ex. '2016-06-10 00:00:00') to be recorded\n                --include_child               Flag to be enabled to include child process metrics (default:1) (--no-include_child is also suppoted)\n                --max_child_limit             Number to be used for limiting pidstat multi processes (default:30) (skip this limit if 0 is specified)\n                --mackerel_metric_type        Metric type of mackerel (default:service) (only use one of 'service' or 'host')\n                --mackerel_api_key            An api key to be used for posting to mackerel\n                --mackerel_service_name       An mackerel service name\n                --mackerel_metric_key_prefix  Key prefix of mackerel metric name (default:batch_)\n                --mackerel_host_id            An mackerel host id\n              Requirement Programs: pidstat and pstree commands\n\n# LICENSE\n\nCopyright (C) yoheimuta.\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n\n# AUTHOR\n\nyoheimuta \u003cyoheimuta@gmail.com\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoheimuta%2Flinux-getpidstat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoheimuta%2Flinux-getpidstat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoheimuta%2Flinux-getpidstat/lists"}