aarnaud / collectd-lxc Goto Github PK
View Code? Open in Web Editor NEWCollectd metrics of lxc container
Collectd metrics of lxc container
Hi, might be of use, my script collecting basic data via LXD API.
https://gist.github.com/ser/4e3fdef3d87cda94676f004ed0954ee6
the script crashes with the following error, after outputting lots of good statistics :
{'values': [436], 'plugin_instance': '0__prod-main-pg2', 'type_instance': 'ops_read', 'type': 'gauge', 'plugin': 'lxc_blkio'}
{'values': [0], 'plugin_instance': '0__prod-main-pg2', 'type_instance': 'ops_write', 'type': 'gauge', 'plugin': 'lxc_blkio'}
Traceback (most recent call last):
File "./collectd_lxc.py", line 167, in <module>
reader()
File "./collectd_lxc.py", line 118, in reader
with Namespace(container_PID, 'net'):
File "/usr/local/lib/python2.7/dist-packages/nsenter/__init__.py", line 69, in __init__
self.target_fd = Path(pid).open()
File "/usr/local/lib/python2.7/dist-packages/pathlib.py", line 1077, in open
return io.open(str(self), mode, buffering, encoding, errors, newline)
IOError: [Errno 21] Is a directory: '.'
I've tracked the origin of the bug here, it tries to find the container's pid, which no longer resides in tasks
but in init.scope/tasks
(IHMO)
The plugin seems to work with the following crude hack :
--- collectd_lxc.py 2016-09-07 16:51:49.040269863 +0200
+++ /etc/collectd/plugins/collectd_lxc.py 2016-09-07 16:48:13.570307507 +0200
@@ -112,7 +112,7 @@
### Network
#PID lxc: cat /sys/fs/cgroup/devices/lxc/CONTAINER-NAME/tasks | head -n 1
- with open(os.path.join(metrics[user_id][container_name][metric], 'tasks'), 'r') as f:
+ with open(os.path.join(metrics[user_id][container_name][metric], 'init.scope/tasks'), 'r') as f:
# The first line is PID of container
container_PID = f.readline().rstrip()
with Namespace(container_PID, 'net'):
Hello.
Trying to install your plugin. Have an error:
python plugin: Error importing module "collectd_lxc".
Unhandled python exception in importing module: ImportError: No module named collectd_lxc
python plugin: Found a configuration for the "collectd_lxc" plugin, but the plugin isn't loaded or didn't register a configuration callback.
Ubuntu 18.04.1, collectd 5.7.2.git
Any suggestions please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.