| 1 | # python.d.plugin |
| 2 | |
| 3 | `python.d.plugin` is a Netdata external plugin. It is an **orchestrator** for data collection modules written in `python`. |
| 4 | |
| 5 | 1. It runs as an independent process `ps fax` shows it |
| 6 | 2. It is started and stopped automatically by Netdata |
| 7 | 3. It communicates with Netdata via a unidirectional pipe (sending data to the `netdata` daemon) |
| 8 | 4. Supports any number of data collection **modules** |
| 9 | 5. Allows each **module** to have one or more data collection **jobs** |
| 10 | 6. Each **job** is collecting one or more metrics from a single data source |
| 11 | |
| 12 | ## Disclaimer |
| 13 | |
| 14 | All third party libraries should be installed system-wide or in `python_modules` directory. |
| 15 | Module configurations are written in YAML and **pyYAML is required**. |
| 16 | |
| 17 | Every configuration file must have one of two formats: |
| 18 | |
| 19 | - Configuration for only one job: |
| 20 | |
| 21 | ```yaml |
| 22 | update_every : 2 # update frequency |
| 23 | priority : 20000 # where it is shown on dashboard |
| 24 | |
| 25 | other_var1 : bla # variables passed to module |
| 26 | other_var2 : alb |
| 27 | ``` |
| 28 | |
| 29 | - Configuration for many jobs (ex. mysql): |
| 30 | |
| 31 | ```yaml |
| 32 | # module defaults: |
| 33 | update_every : 2 |
| 34 | priority : 20000 |
| 35 | |
| 36 | local: # job name |
| 37 | update_every : 5 # job update frequency |
| 38 | other_var1 : some_val # module specific variable |
| 39 | |
| 40 | other_job: |
| 41 | priority : 5 # job position on dashboard |
| 42 | other_var2 : val # module specific variable |
| 43 | ``` |
| 44 | |
| 45 | `update_every` and `priority` are always optional. |
| 46 | |
| 47 | ## How to debug a python module |
| 48 | |
| 49 | ```bash |
| 50 | # become user netdata |
| 51 | sudo su -s /bin/bash netdata |
| 52 | ``` |
| 53 | |
| 54 | Depending on where Netdata was installed, execute one of the following commands to trace the execution of a python module: |
| 55 | |
| 56 | ```bash |
| 57 | # execute the plugin in debug mode, for a specific module |
| 58 | /opt/netdata/usr/libexec/netdata/plugins.d/python.d.plugin <module> debug trace |
| 59 | /usr/libexec/netdata/plugins.d/python.d.plugin <module> debug trace |
| 60 | ``` |
| 61 | |
| 62 | Where `[module]` is the directory name under <https://github.com/netdata/netdata/tree/master/src/collectors/python.d.plugin> |