I'm trying to collect Wireless statistics from Access Point (AP) device and view the output using Kafka server. I've added 'exec' plugin in OpenWrt code using 'make menuconfig' (Utilities --> collectd --> collectd-mod-exec). After successful build, I flashed firmware image into AP and now I'm able to see exec plugin. I've given a script file to exec plugin as input.
RRD files are created in '/tmp/rrd'. But, my problem here is, RRD file is not generated constantly. I'm restarting luci and collectd process but still having problem in RRD file creation. Sometime I couldn't see RRD file at all in AP. Please support me to generate RRD files constantly using collectd exec plugin with script. Thanks.
Collectd Config file (/etc/collectd.conf)
BaseDir "/var/run/collectd"
Include "/etc/collectd/conf.d"
PIDFile "/var/run/collectd.pid"
PluginDir "/usr/lib/collectd"
TypesDB "/usr/share/collectd/types.db"
Interval 5
ReadThreads 2
LoadPlugin rrdtool
<Plugin rrdtool>
DataDir "/tmp/rrd"
RRARows 100
RRASingle false
RRATimespan 3600
RRATimespan 86400
RRATimespan 604800
RRATimespan 2678400
RRATimespan 31622400
</Plugin>
LoadPlugin interface
<Plugin interface>
IgnoreSelected false
Interface wifi0
Interface wifi1
</Plugin>
LoadPlugin network
<Plugin network>
Server "192.168.1.192" "25826"
Forward true
</Plugin>
LoadPlugin exec
<Plugin exec>
Exec "nobody:nogroup" "/tmp/rrd/OpenWrt1/wlanstats.sh"
</Plugin>
Script file (/tmp/rrd/OpenWrt1/wlanstats.sh)
#!/bin/sh
HOST=$COLLECTD_HOSTNAME
INTERVAL=$COLLECTD_INTERVAL
#[-z "$INTERVAL"] && INTERVAL=5
INTERVAL=5
INTERVAL=$(awk -v i=$INTERVAL 'BEGIN{print int(i)}')
while sleep $INTERVAL; do
val=$(dd if=/dev/urandom bs=1 count=1 2>/dev/null |apstats | awk '/Rx PHY errors/ {print $5}')
echo "PUTVAL \"$HOST/exec-wlanstats/temperature-rx_phy_errors\" interval=$INTERVAL N:$val"
done
Debugging method followed:
/etc/init.d/luci_statistics restart
/etc/init.d/collectd/ restart
RRD file generated as below:
exec-wlanstats/temperature-rx_phy_errors.rrd