I am working on using piwik as a tracker for vm usage. Thr plan is that every time a VM starts or shuts down, a custom request will be send to a piwik server and report a UUID and a few other variables. I downloaded the https://github.com/piwik/piwik-python-api project that is supposed to allow a python script creation but I am preety stuck after that.
All the vms have an ip (something like 10.0.5.15 in my localhost for example) and I will have to use this access to send the requests.
Can anyone provide a link to a simple example of how to send anything to piwik?
This piwik library is intended for a python web server such as Django. Unless you're planning on running a web server in your VMs, it will be of no use. That said, running a web server to send tracks to piwik seems to be overdoing it.
Piwik is simply calling a URL when it sends data to the server. It doesn't use POST, only GET. Therefore, it is simple enough to replicate the call in Python using a script that will call a URL: https://docs.python.org/2/howto/urllib2.html
The actual piwik URLs can be as simple as:
http://piwik.example.org/piwik.php?idsite={$IDSITE}amp;rec=1
This will start a single session in the piwik DB. The ID Site is the piwik ID of the website you're tracking.
Additional variables can be passed using this session tracker.
I would recommend passing the user id in the uid parameter or alternatively in _cvar if you need additional custom variables.
uid — defines the User ID for this request. User ID is any non empty unique string identifying the user (such as an email address or a username). To access this value, users must be logged-in in your system so you can fetch this user ID from your system, and pass it to Piwik. The User ID appears in the visitor log, the Visitor profile, and you can Segment reports for one or several User ID (userId segment). When specified, the User ID will be "enforced". This means that if there is no recent visit with this User ID, a new one will be created. If a visit is found in the last 30 minutes with your specified User ID, then the new action will be recorded to this existing visit.
Hopefully this helps.