diff --git a/README.md b/README.md index 683d636..2470b4f 100644 --- a/README.md +++ b/README.md @@ -28,22 +28,14 @@ to use a different directory you may need to modify the scripts to suit. tar zxvf huawei-hg612-munin-1.0.tgz 4. A cron job must be set up to run every 5 minutes and the user running the -plugin must be able to write to /etc/munin/huawei/output.txt: - */5 * * * * /etc/munin/huawei/getstats.sh +plugin must be able to write to `/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt`. + + cp /etc/munin/huawei/crontab /etc/cron.d/huawei-hg612-munin 5. If you wish to enable any of the plugins, create a symlink for each one in the munin plugins directory. Or, copy and paste the following: - cd /etc/munin/plugins - ln -s /etc/munin/huawei/plugins/hg612_attenuation - ln -s /etc/munin/huawei/plugins/hg612_current_speed - ln -s /etc/munin/huawei/plugins/hg612_errors - ln -s /etc/munin/huawei/plugins/hg612_max_speed - ln -s /etc/munin/huawei/plugins/hg612_ptm1 - ln -s /etc/munin/huawei/plugins/hg612_ptm1_uptime - ln -s /etc/munin/huawei/plugins/hg612_pwr - ln -s /etc/munin/huawei/plugins/hg612_snr - ln -s /etc/munin/huawei/plugins/hg612_sync_speed + ln -s /etc/munin/huawei/plugins/hg612_* /etc/munin/plugins 6. The huawei.expect script is configured to connect to 192.168.1.1 and use the default username and password. If this isn't what you want, simply modify diff --git a/crontab b/crontab new file mode 100644 index 0000000..b9c6ad2 --- /dev/null +++ b/crontab @@ -0,0 +1 @@ +*/5 * * * * munin /etc/munin/plugins/huawei-hg612-munin/getstats.sh diff --git a/getstats.sh b/getstats.sh index e9ea8e9..a19a965 100755 --- a/getstats.sh +++ b/getstats.sh @@ -1,2 +1,5 @@ #!/bin/sh -expect /etc/munin/huawei/huawei.expect | tee | tr -d "\015" > /etc/munin/huawei/output.txt + +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} + +expect `dirname $0`/huawei.expect | tee | tr -d "\015" > $statsfile diff --git a/plugins/hg612_attenuation b/plugins/hg612_attenuation index 9927068..f0b25e0 100755 --- a/plugins/hg612_attenuation +++ b/plugins/hg612_attenuation @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_current_speed b/plugins/hg612_current_speed index a92d0c1..2c354f1 100755 --- a/plugins/hg612_current_speed +++ b/plugins/hg612_current_speed @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_errors b/plugins/hg612_errors index a29e60d..b612b9d 100755 --- a/plugins/hg612_errors +++ b/plugins/hg612_errors @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_interleaving b/plugins/hg612_interleaving index 05b3eca..14443cf 100755 --- a/plugins/hg612_interleaving +++ b/plugins/hg612_interleaving @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_max_speed b/plugins/hg612_max_speed index 6b14ec7..f053911 100755 --- a/plugins/hg612_max_speed +++ b/plugins/hg612_max_speed @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_ptm1 b/plugins/hg612_ptm1 index 6fe7d04..1e160ac 100755 --- a/plugins/hg612_ptm1 +++ b/plugins/hg612_ptm1 @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_ptm1_uptime b/plugins/hg612_ptm1_uptime index 251afb1..c018cfe 100755 --- a/plugins/hg612_ptm1_uptime +++ b/plugins/hg612_ptm1_uptime @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_pwr b/plugins/hg612_pwr index 1ae44bb..38c3d23 100755 --- a/plugins/hg612_pwr +++ b/plugins/hg612_pwr @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_snr b/plugins/hg612_snr index 8039229..63ed9a2 100755 --- a/plugins/hg612_snr +++ b/plugins/hg612_snr @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut diff --git a/plugins/hg612_sync_speed b/plugins/hg612_sync_speed index 2defbca..9004f5b 100755 --- a/plugins/hg612_sync_speed +++ b/plugins/hg612_sync_speed @@ -1,7 +1,7 @@ #!/bin/sh # -*- sh -*- -statsfile="/etc/munin/huawei/output.txt" +statsfile=${statsfile:-/var/lib/munin/plugin-state/huawei-hg612-munin-output.txt} : << =cut