root / plugins / funkytown / denon_x311_volume @ 0ddf0181
Historique | Voir | Annoter | Télécharger (2,16 ko)
| 1 | c0c127c9 | Kristian Lyngst?l | #!/usr/bin/gawk -f |
|---|---|---|---|
| 2 | # Denon x311 volume-plugin for munin |
||
| 3 | # Copyright (C) 2010 Kristian Lyngstol |
||
| 4 | # |
||
| 5 | # This program is free software; you can redistribute it and/or modify |
||
| 6 | # it under the terms of the GNU General Public License as published by |
||
| 7 | # the Free Software Foundation; either version 2 of the License, or |
||
| 8 | # (at your option) any later version. |
||
| 9 | # |
||
| 10 | # This program is distributed in the hope that it will be useful, |
||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | # GNU General Public License for more details. |
||
| 14 | # |
||
| 15 | # You should have received a copy of the GNU General Public License along |
||
| 16 | # with this program; if not, write to the Free Software Foundation, Inc., |
||
| 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 18 | |||
| 19 | # This plugin asks a Denon (?) receiver over "telnet" what volume it's |
||
| 20 | # running at and parses the result. It's tested with Denon AVR 4311, but I |
||
| 21 | # suppose it works with the 3311 too, possibly more. It uses 192.168.0.60 |
||
| 22 | # by default - because I'm lazy. |
||
| 23 | |||
| 24 | ### Magic markers |
||
| 25 | # #%# family=manual |
||
| 26 | # #%# capabilities= |
||
| 27 | # |
||
| 28 | # Even if we _could_ do autoconf on ENVIRON["ip"], it's hazardous as you |
||
| 29 | # have little control over timeouts and risk hanging around annoying the |
||
| 30 | # user. |
||
| 31 | |||
| 32 | BEGIN {
|
||
| 33 | if (ARGV[1] == "config") {
|
||
| 34 | print "graph_title Denon AVR-4311 Volume" |
||
| 35 | print "graph_category funkytown" |
||
| 36 | print "volume.label Volume" |
||
| 37 | print "volume.type GAUGE" |
||
| 38 | exit 0 |
||
| 39 | } |
||
| 40 | if (ENVIRON["ip"] == "") {
|
||
| 41 | ip="denon.kristian.int" |
||
| 42 | } else {
|
||
| 43 | ip=ENVIRON["ip"] |
||
| 44 | } |
||
| 45 | Service="/inet/tcp/0/" ip "/23" |
||
| 46 | |||
| 47 | # The AVR-4311 uses just a \r as line/record separator (annoying as |
||
| 48 | # heck). |
||
| 49 | RS="\r" |
||
| 50 | |||
| 51 | # MV? asks for volume. Returned in MVXXZ - the z is optional |
||
| 52 | print "MV?\r" |&Service |
||
| 53 | Service |& getline |
||
| 54 | close(Service) |
||
| 55 | gsub("^MV","")
|
||
| 56 | |||
| 57 | # 445 == 44.5. 44 = 44. So only divide by ten if more than 2 |
||
| 58 | # characters were returned. Note that it also returns 005 for 0.5 |
||
| 59 | if (length >2) {
|
||
| 60 | n=$0/10 |
||
| 61 | } else {
|
||
| 62 | n=$0 |
||
| 63 | } |
||
| 64 | |||
| 65 | # 99 is "0" and 99.5 is "0.5" (somewhat audible). I shift |
||
| 66 | # everything by 1 because I prefer my lists to start at 0, not |
||
| 67 | # -1.... |
||
| 68 | if (n==99 || n == 99.5) {
|
||
| 69 | n-=99 |
||
| 70 | } else {
|
||
| 71 | n+=1 |
||
| 72 | } |
||
| 73 | printf "volume.value %0.1f\n",n |
||
| 74 | } |
