Giter Club home page Giter Club logo

snap-plugin-collector-psutil's Introduction

DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

This project has been identified as having known security escapes.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

DISCONTINUATION OF PROJECT

This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project.

Snap collector plugin - psutil

This plugin collects metrics from psutil which gathers information on running processes and system utilization (CPU, memory, disks, network).

It's used in the Snap framework.

  1. Getting Started
  1. Documentation
  1. Community Support
  2. Contributing
  3. License
  4. Acknowledgements

Getting Started

System Requirements

Note: This plugin does not require Python rather it depends on the go library gopsutil.

Operating systems

All OSs currently supported by snap:

  • Linux/amd64
  • Darwin/amd64

Installation

Download psutil plugin binary:

You can get the pre-built binaries for your OS and architecture under the plugin's release page. For Snap, check here.

To build the plugin binary:

Fork https://github.com/intelsdi-x/snap-plugin-collector-psutil

Clone repo into $GOPATH/src/github.com/intelsdi-x/:

$ git clone https://github.com/<yourGithubID>/snap-plugin-collector-psutil.git

Build the plugin by running make within the cloned repo:

$ make

This builds the plugin in ./build/

Configuration and Usage

Some metrics are platform specific (see gopsutil's current status).

Available configuration option:

  • mount_points - configuration of mount points to monitor, multiple paths should be separated with "|", e.g. "/|/dev|/run", default is set to collect only physical devices (hard disks, cd-rom, USB). Passing * enables collect data from all mount points.

Documentation

There are a number of other resources you can review to learn to use this plugin:

Collected metrics

List of metrics collected by this plugin can be found in METRICS.md file.

Examples

This is an example running psutil and writing data to a file. It is assumed that you are using the latest Snap binary and plugins.

The example is run from a directory which includes snaptel, snapteld, along with the plugins and task file.

In one terminal window, open the Snap daemon (in this case with logging set to 1 and trust disabled):

$ snapteld -l 1 -t 0

In another terminal window: Load psutil plugin

$ snaptel plugin load snap-plugin-collector-psutil

See available metrics for your system

$ snaptel metric list

Create a task manifest file (e.g. task-psutil.json):

{
    "version": 1,
    "schedule": {
        "type": "simple",
        "interval": "1s"
    },
    "workflow": {
        "collect": {
            "metrics": {
                "/intel/psutil/load/load1": {},
                "/intel/psutil/load/load5": {},
                "/intel/psutil/load/load15": {},
                "/intel/psutil/cpu/*/user": {},
                "/intel/psutil/net/*/bytes_sent": {},
                "/intel/psutil/vm/available": {},
                "/intel/psutil/vm/free": {},
                "/intel/psutil/vm/used": {}
            },
            "config": {
                "/intel/mock": {
                    "password": "secret",
                    "user": "root"
                }
            },
            "publish": [
                {                         
                    "plugin_name": "file",
                    "config": {
                        "file": "/tmp/published_psutil"
                    }
                }
            ]
        }
    }
}

Load file plugin for publishing:

$ snaptel plugin load snap-plugin-publisher-file
Plugin loaded
Name: file
Version: 3
Type: publisher
Signed: false
Loaded Time: Fri, 20 Nov 2015 11:41:39 PST

Create task:

$ snaptel task create -t task-psutil.json
Using task manifest to create task
Task created
ID: 02dd7ff4-8106-47e9-8b86-70067cd0a850
Name: Task-02dd7ff4-8106-47e9-8b86-70067cd0a850
State: Running

See file output (this is just part of the file):

2015-11-20 11:46:03.637390565 -0800 PST|[intel psutil load load1]|1.82|username-mac01.jf.intel.com
2015-11-20 11:46:03.641160359 -0800 PST|[intel psutil load load15]|2.09|username-mac01.jf.intel.com
2015-11-20 11:46:03.643858208 -0800 PST|[intel psutil load load5]|2.08|username-mac01.jf.intel.com
2015-11-20 11:46:03.661173851 -0800 PST|[intel psutil vm available]|168882176|username-mac01.jf.intel.com
2015-11-20 11:46:03.67167664 -0800 PST|[intel psutil vm free]|168943616|username-mac01.jf.intel.com
2015-11-20 11:46:03.681965105 -0800 PST|[intel psutil vm used]|17010798592|username-mac01.jf.intel.com
2015-11-20 11:46:04.641244629 -0800 PST|[intel psutil load load1]|1.82|username-mac01.jf.intel.com
2015-11-20 11:46:04.644420189 -0800 PST|[intel psutil load load15]|2.09|username-mac01.jf.intel.com
2015-11-20 11:46:04.647166418 -0800 PST|[intel psutil load load5]|2.08|username-mac01.jf.intel.com
2015-11-20 11:46:04.657065347 -0800 PST|[intel psutil vm available]|168984576|username-mac01.jf.intel.com
2015-11-20 11:46:04.666346721 -0800 PST|[intel psutil vm free]|169054208|username-mac01.jf.intel.com
2015-11-20 11:46:04.676683476 -0800 PST|[intel psutil vm used]|17010716672|username-mac01.jf.intel.com

Stop task:

$ snaptel task stop 02dd7ff4-8106-47e9-8b86-70067cd0a850
Task stopped:
ID: 02dd7ff4-8106-47e9-8b86-70067cd0a850

Roadmap

There isn't a current roadmap for this plugin, but it is in active development. As we launch this plugin, we do not have any outstanding requirements for the next release. If you have a feature request, please add it as an issue and/or submit a pull request.

Community Support

This repository is one of many plugins in Snap, a powerful telemetry framework. See the full project at http://github.com/intelsdi-x/snap To reach out to other users, head to the main framework

Contributing

We love contributions!

There's more than one way to give back, from examples to blogs to code updates. See our recommended process in CONTRIBUTING.md.

License

Snap, along with this plugin, is an Open Source software released under the Apache 2.0 License.

Acknowledgements

And thank you! Your contribution, through code and participation, is incredibly important to us.

snap-plugin-collector-psutil's People

Contributors

candysmurf avatar geauxvirtual avatar izabellaraulin avatar jcooklin avatar katarzyna-z avatar kdembler avatar kindermoumoute avatar marcin-krolik avatar marcin-ol avatar marcintao avatar mkleina avatar mrdarthshoe avatar nanliu avatar nguyenddn avatar patrykmatyjasek avatar rdower avatar sandlbn avatar taotod avatar tiffanyfay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snap-plugin-collector-psutil's Issues

Make should support building a Windows binary

What happened: make produces binaries for Linux and when run on a Mac for Darwin.

What you expected to happen: A Windows binary should be cross compiled.

Steps to reproduce it (as minimally and precisely as possible):

  1. make

Anything else do we need to know (e.g. issue happens only occasionally):

Drop or fix darwin build for psutil

psutil does not load on MacOS because we only support cpu metrics on linux

$ snapctl plugin load snap-plugin-collector-psutil
Error loading plugin:
GetMetricTypes call error : darwin not supported by plugin

Upstream gopsutil have resolved the issue, but requires cgo. At this point we need a decision whether we want to support this plugin for MacOS (which requires cgo and we can't easily generate universal binaries), or drop support and delete the darwin binary in the github release page.

cc @intelsdi-x/snap-maintainers

Update gopsutil package

We currently use gopsutil at a rev level of 1.0.0-64. While the project hasn't released a new release of the package since Dec 2014, there have been numerous commits to the project since 1.0.0-64, one of which change the directory structure of the project.

The issue is that with the recent issues we have been having with godep, if a user uses go get to download the plugin, go get will grab gopsutil at head. When make deps is run, godep tries to restore github.com/shirou/gopsutil/common, which currently does not exist in the project causing godep restore to fail.

The workaround is to use git to clone down the repo, then run make deps where godep restore will succeed.

Add config option to exclude some of the mount points for disk usage metrics

Present use cases supported:

  1. A user wants all metrics from all mount points discovered with psutil.disk_partitions().
  2. A user specifies mount_points in config, and function psutil.disk_usage is called only for these mount points.
    i.e. configuration:
    mount_points: /opt/disks/gke-cluster-1-aa822ff3-pvc-03622b17-196a-11e7-b5db-42010a8a0098
    returns 4 metrics:
/opt/disks/gke-cluster-1-aa822ff3-pvc-03622b17-196a-11e7-b5db-42010a8a0098/free
/opt/disks/gke-cluster-1-aa822ff3-pvc-03622b17-196a-11e7-b5db-42010a8a0098/total
/opt/disks/gke-cluster-1-aa822ff3-pvc-03622b17-196a-11e7-b5db-42010a8a0098/usage
/opt/disks/gke-cluster-1-aa822ff3-pvc-03622b17-196a-11e7-b5db-42010a8a0098/percent

However, this case requires user to know whole mount points paths.

Not supported use case:

A user wants to gather disks usage from few mount points, but doesn't know the exact path. This could be done with case 1. But it does not make sense to collect metrics for all of the available mount points. It can be a very large number, especially when running plugin inside Docker container.

It would be useful to have similar feature to excluded_fs_names in df collector.

add conntrack counter

It possible to add countrack counter for this plugin ?
conntrackCount and conntrackMax values

adding filter capability

for example:
instead of writing the same requirements for cpu0,cpu1,cpu2 etc... simply write:
"/intel/psutil//guest": {},
"/intel/psutil/
/guest_nice": {},
"/intel/psutil//idle": {},
"/intel/psutil/
/iowait": {},
"/intel/psutil//irq": {},
"/intel/psutil/
/nice": {},
"/intel/psutil//softirq": {},
"/intel/psutil/
/steal": {},
"/intel/psutil//stolen": {},
"/intel/psutil/
/system": {},
"/intel/psutil/*/user": {},

the plugin does not load on OSX

Snap daemon version (use snapteld -v):
snapteld (version: master-05cb3ef1)
Environment:

  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release): OSX
  • Kernel (e.g. uname -a):
  • Relevant tools (e.g. plugins used with Snap):
  • Others (e.g. deploying with Ansible):

What happened:
Simply the psutil plugin didn't load

▶ ./build/darwin/x86_64/snaptel plugin load ../snap-plugin-collector-psutil/build/darwin/x86_64/snap-plugin-collector-psutil
Error loading plugin:
timed out waiting for plugin to load

What you expected to happen:

Loads the psutil plugin

Steps to reproduce it (as minimally and precisely as possible):

  1. start the latest Snap daemon
  2. load the latest snap-plugin-collector-psutil

Anything else do we need to know (e.g. issue happens only occasionally):

Error logs from Snap daemon

mgr path=snap-plugin-collector-psutil
DEBU[2017-05-19T09:31:52-07:00] plugin load timeout set to 3s                 _block=load-plugin _module=control-plugin-mgr path=[snap-plugin-collector-psutil]
ERRO[2017-05-19T09:31:55-07:00] timed out waiting for plugin to load          _module=_mgmt-rest-v1
DEBU[2017-05-19T09:31:55-07:00] Removing file (/var/folders/8g/_w1d386d34z29nt8zbzjqv5r0000gp/T/snap-plugin-958456954/snap-plugin-collector-psutil)  _module=_mgmt-rest-v1
DEBU[2017-05-19T09:31:55-07:00] API response                                  _module=_mgmt-rest index=1 method=POST status=Internal Server Error status-code=500 url=/v1/plugins
ERRO[2017-05-19T09:31:55-07:00] error loading plugin                          _module=plugin-exec received_response=
ERRO[2017-05-19T09:31:55-07:00] load plugin error when starting plugin        _block=load-plugin _module=control-plugin-mgr error=timed out waiting for plugin snap-plugin-collector-psutil
^CINFO[2017-05-19T09:35:24-07:00] shutting down modules                         _module=snapteld block=main
INFO[2017-05-19T09:35:24-07:00] stopping module                               _module=snapteld block=main snap-module=control
DEBU[2017-05-19T09:35:24-07:00] stopped                                       _block=start-plugin _module=control-runner
INFO[2017-05-19T09:35:24-07:00] control stopped                               _block=stop _module=control
INFO[2017-05-19T09:35:24-07:00] stopping module                               _module=snapteld block=main snap-module=scheduler
INFO[2017-05-19T09:35:24-07:00] scheduler stopped                             _block=stop-scheduler _module=scheduler
INFO[2017-05-19T09:35:24-07:00] stopping module                               _module=snapteld block=main snap-module=REST
INFO[2017-05-19T09:35:24-07:00] REST stopped                                  _block=stop _module=_mgmt-rest
INFO[2017-05-19T09:35:24-07:00] exiting on signal                             _module=snapteld block=main signal=interrupt


unable to retrieve psutils metrics for Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz architecture

Hi,
I tested the psutil plugin on Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz and it worked fine.
but I receive the following (see below) error when running on Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz.
Is this architecture unsupported?

error received:
Metric not found: /intel/psutil/cpu0/user
Metric not found: /intel/psutil/cpu2/system
Metric not found: /intel/psutil/load/load1
Metric not found: /intel/psutil/load/load15
Metric not found: /intel/psutil/vm/cached
Metric not found: /intel/psutil/vm/wired
Metric not found: /intel/psutil/cpu1/system
Metric not found: /intel/psutil/cpu2/iowait
Metric not found: /intel/psutil/cpu2/irq
Metric not found: /intel/psutil/cpu2/stolen
Metric not found: /intel/psutil/load/load5
Metric not found: /intel/psutil/vm/available
Metric not found: /intel/psutil/cpu0/irq
Metric not found: /intel/psutil/cpu2/guest
Metric not found: /intel/psutil/vm/active
Metric not found: /intel/psutil/vm/buffers
Metric not found: /intel/psutil/vm/used_percent
Metric not found: /intel/psutil/cpu0/idle
Metric not found: /intel/psutil/cpu0/softirq
Metric not found: /intel/psutil/cpu0/system
Metric not found: /intel/psutil/cpu1/irq
Metric not found: /intel/psutil/cpu2/guest_nice
Metric not found: /intel/psutil/vm/free
Metric not found: /intel/psutil/cpu0/guest
Metric not found: /intel/psutil/cpu0/guest_nice
Metric not found: /intel/psutil/cpu0/steal
Metric not found: /intel/psutil/cpu1/nice
Metric not found: /intel/psutil/cpu1/steal
Metric not found: /intel/psutil/cpu2/user
Metric not found: /intel/psutil/cpu0/stolen
Metric not found: /intel/psutil/cpu1/softirq
Metric not found: /intel/psutil/cpu2/steal
Metric not found: /intel/psutil/vm/inactive
Metric not found: /intel/psutil/cpu0/nice
Metric not found: /intel/psutil/cpu1/guest
Metric not found: /intel/psutil/cpu1/idle
Metric not found: /intel/psutil/cpu1/stolen
Metric not found: /intel/psutil/cpu2/idle
Metric not found: /intel/psutil/vm/shared
Metric not found: /intel/psutil/vm/total
Metric not found: /intel/psutil/cpu0/iowait
Metric not found: /intel/psutil/cpu1/guest_nice
Metric not found: /intel/psutil/cpu1/iowait
Metric not found: /intel/psutil/cpu1/user
Metric not found: /intel/psutil/cpu2/nice
Metric not found: /intel/psutil/cpu2/softirq
Metric not found: /intel/psutil/vm/used

psutil does not compile with go1.6

While running the influxdb-grafana example in the framework repo (here) I found psutil does not compile. The error is centered around psutil/mem.go:88: mem.Shared undefined (type *mem.VirtualMemoryStat has no field or method Shared). More complete output is below.

May relate to #12 given the updates. FYI @intelsdi-x/plugin-maintainers

**** snap plugin build  ****

Source Dir = /Users/mjbrende/.gvm/pkgsets/go1.6/global/src/github.com/intelsdi-x/snap-plugin-publisher-influxdb
Building snap plugin: snap-plugin-publisher-influxdb
getting and building snap-plugin-collector-psutil
# github.com/intelsdi-x/snap-plugin-collector-psutil/psutil
../../../snap-plugin-collector-psutil/psutil/mem.go:88: mem.Shared undefined (type *mem.VirtualMemoryStat has no field or method Shared)
bash -c "./scripts/build.sh /Users/mjbrende/.gvm/pkgsets/go1.6/global/src/github.com/intelsdi-x/snap-plugin-collector-psutil"

****  Snap Plugin Build  ****

Source Dir = /Users/mjbrende/.gvm/pkgsets/go1.6/global/src/github.com/intelsdi-x/snap-plugin-collector-psutil
Building Snap Plugin: snap-plugin-collector-psutil
# github.com/intelsdi-x/snap-plugin-collector-psutil/psutil
psutil/mem.go:88: mem.Shared undefined (type *mem.VirtualMemoryStat has no field or method Shared)
make: *** [all] Error 2
/Library/Developer/CommandLineTools/usr/bin/make dips
bash -c "godep restore"
godep: error restoring dep (github.com/shirou/gopsutil/common): cannot find package "github.com/shirou/gopsutil/common" in any of:
    /Users/mjbrende/.gvm/gos/go1.6/src/github.com/shirou/gopsutil/common (from $GOROOT)
    /Users/mjbrende/.gvm/pkgsets/go1.6/global/src/github.com/shirou/gopsutil/common (from $GOPATH)
godep: Error restoring some deps. Aborting check.
make[1]: *** [deps] Error 1
make: *** [default] Error 2
 Error: failed to get and compile psutil plugin

gopsutil

The Readme should be clear that this plugin uses gopsutil and not the Python psutil library (no requirement to install).

metrics under /intel/psutil/cpu are broken

On a Windows platform the metric catalog for /intel/psutil/cpu looks like

....
/intel/psutil/cpu//idle
/intel/psutil/cpu//system
/intel/psutil/cpu//user
....

Collecting on these metrics fails.

missing some metrics for intel/psutil/vm/

I use snap-plugin-collector-psutil with snap version v0.13.0 for Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz. I missing the metric "intel/psutil/vm/shared".

/opt/snap/bin/snapctl metric list | grep /intel/psutil/vm
/intel/psutil/vm/active                      6
/intel/psutil/vm/available                   6
/intel/psutil/vm/buffers                     6
/intel/psutil/vm/cached                      6
/intel/psutil/vm/free                        6
/intel/psutil/vm/inactive                    6
/intel/psutil/vm/total                       6
/intel/psutil/vm/used                        6
/intel/psutil/vm/used_percent                6
/intel/psutil/vm/wired                       6

Too expensive collects from go-psutil

When trying to collect a few metrics from all my 24 cores as such:

        "metrics": {
            "/intel/psutil/*/idle": {},
            "/intel/psutil/*/iowait": {},
            "/intel/psutil/*/irq": {},
            "/intel/psutil/*/softirq": {},
            "/intel/psutil/*/stolen": {},
            "/intel/psutil/*/system": {},
            "/intel/psutil/*/user": {}
        },

This plugin uses 100% of one core when CollectMetrics is called. This is too expensive for me to use in production.

Not sure where this is coming from, maybe the go-psutil requirement...but seems excessive. Please @intelsdi-x/plugin-maintainers take a look, because this info is important to a lot of people :)

Metric Namespace Error while loading plugin snap-plugin-collector-psutil

I am getting the error while loading snap plugin snap-plugin-collector-psutil. The error is as below -
Error loading plugin:
Metric namespace /intel/psutil/net/ens513f1.226/errout contains not allowed characters. Avoid using punctuations [. , ; ? !], slashes [| \ /], carets [^], quotations [" ` '], brackets [( ) [ ] { }], spaces [ ]

My tasks file looks like below-


version: 1
schedule:
type: "simple"
interval: "1s"
max-failures: 10
workflow:
collect:
metrics:
/intel/psutil/*: {}
config:
/intel/mock:
name: "root"
password: "secret"
publish:
-
plugin_name: "influx"
config:
host: "10.19.226.68"
port: 8086
database: "test"
user: "root"
password: "P@ssw0rd"

The OS details are as below -
CentOS Linux release 7.2.1511 (Core)
Kernel -
3.10.0-327.28.3.el7.x86_64

Let me know how to resolve this error?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.