2

I am working on a Raspberry Pi 3 and I am trying to visualize some values of sensors on Munin. I am using Python in order to execute scripts on Munin. I found a script to test and I am trying to execute it but I got the following error :

Traceback (most recent call last):
File "cpu_field", line 23, in munin.main() AttributeError: 'module' object has no attribute 'main'

This is the script : https://github.com/CooledCoffee/python-munin/ Of course, I added at the beginning :

!/usr/bin/env python

But, what I didn't understand is that others scripts are working like this one : https://gist.github.com/tomoconnor/813813

Community
  • 1
  • 1
DjibTgy
  • 65
  • 1
  • 7

2 Answers2

0

Would be nice if you could put the code in the question as well.

Anyways. The python-munin you use is entirely different and provides no main() function (as it called in line 23). Names for python modules are not protected and 'munin' is a obvious choice used by more than one developer. The first script should run with the module you get with

pip install python-munin

The other script uses this python-munin module and you probably get it directly from the git repository. They are not compatible.

  • there is no code nor right/false. you must decide which module you want to use and write/use matching code to it. You can't mix it like you did. – Christoph Bluoss Dec 02 '16 at 14:06
0

So, this is the code I am using :

> #!/usr/bin/env python
> 
> import munin
> 
> category = 'system' fields = [
>     'load1',
>     'load5',
>     'load15', ] vlabel = 'load'
> 
> def values():
>     with open('/proc/loadavg') as f:
>         data = f.read()
>     load1, load5, load15 = [float(s) for s in data.split()[:3]]
>     return {
>         'load1': load1,
>         'load5': load5,
>         'load15': load15,
>     }
> 
> if __name__ == '__main__':
>     munin.main()

This is the answer I got with sudo python xxx, I got the same answer with sudo munin-run xxx :

   pi@dex:/etc/munin/plugins $ sudo python first
    Traceback (most recent call last):
      File "first", line 24, in <module>
        munin.main()
    AttributeError: 'module' object has no attribute 'main'

I thin you are right because when I installed munin with

pip install python-munin

it worked. But, then I installed this python-munin module and it didn't work anymore. I removed the folder python-munin but I still got the same error. How can I remove properly the previous folder ?

DjibTgy
  • 65
  • 1
  • 7