a140fe219bb9f4b152562e20cbe83c66a8850a54
[usb-wde1-tools.git] / README.rst
1 USB-WDE1 Munin plugin
2 =====================
3 Generate graphs for temperature and humidity by utilizing Munin.
4
5
6 Idea
7 ----
8 0. Keep a logfile with the most recent single line
9 1. Use the munin plugin to generate munin-compatible data from the log file
10
11
12 Setup
13 -----
14 0. Checkout the munin plugin code:
15    $ cd /usr/local/src
16    $ git clone git://git.cweiske.de/usb-wde1-tools.git
17    $ cd usb-wde1-tools
18
19 1. A process needs to watch the USB interface and log the last
20    line with temperature data into a log file.
21    You can do that manually with
22    $ socat /dev/ttyUSB0,b9600 STDOUT |./munin/log-single-line.sh test.log
23
24    The most easy way is to run
25    $ cd munin && nohup ./usb-wde1-log-last.sh &
26    once. It backgrounds the logging process and logs into /tmp/usb-wde1-last.
27    This process needs to be started whenever the machine is rebooted.
28
29 2. Link the munin plugin:
30    $ cd /etc/munin/plugins
31    $ ln -s /usr/local/src/usb-wde1-tools/munin/usb-wde1_ usb-wde1_temperature
32    $ ln -s /usr/local/src/usb-wde1-tools/munin/usb-wde1_ usb-wde1_humidity
33
34 3. Configure the plugins
35    Edit /etc/munin/plugin-conf.d/munin-node and add the following lines:
36    [usb-wde1_*]
37    env.logfile /tmp/usb-wde1-last
38    env.host_name House
39    env.sensors 0 1 7
40    env.sensor0 Living room
41    env.sensor1 Kitchen
42    env.sensor7 Outside
43
44 4. Try it:
45    $ munin-run usb-wde1_temperature autoconf
46     - should echo "yes"
47    $ munin-run usb-wde1_temperature config
48     - should display the plugin configuration with all environment variables
49       set
50    $ munin-run usb-wde1_temperature
51    $ munin-run usb-wde1_humidity
52     - should display the current values from the log file
53
54 5. You are done - enjoy.
55
56
57
58 Debugging & Development
59 -----------------------
60 The dummy data generator is a small php script that generates log lines
61 as they would come from the usb-wde1 usb port:
62 $ ./dummy-data-generator.php |./munin/log-single-line.sh test.log
63
64 Local (non-installed) plugin setup:
65 $ cd munin
66 $ ln -s usb-wde1_ usb-wde1_temperature
67 $ ln -s usb-wde1_ usb-wde1_humidity
68 $ cd ..
69
70
71 Running the munin plugin for development purposes is also relatively easy
72 since you can pass the environment configuration variables
73 from the munin configuration on the command line:
74 $ logfile=test.log sensors="0 1 7" ./munin/usb-wde1_temperature
75
76 When you have problems running the munin plugin, try to
77 remove the line 
78  env.host_name House
79 from file usb-wde1_
80
81
82 Permission errors
83 .................
84
85     cu: open (/dev/ttyUSB0): Permission denied
86     cu: /dev/ttyUSB0: Line in use
87
88 Only way that I found to fix this was change ownership of `/dev/ttyUSB0` to uucp::
89
90      $ chown uucp /dev/ttyUSB0