Scripts for gathering wireless statistics
This commit is contained in:
parent
fe98c77c19
commit
e219ca52dd
|
@ -0,0 +1,10 @@
|
||||||
|
Collectd wireless statistics gatherer
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
What is this
|
||||||
|
------------
|
||||||
|
This is set of scritps/utilities to gather wirelss statitics for openfest 2015
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
[usage](usage.md)
|
|
@ -0,0 +1,24 @@
|
||||||
|
collectd plain text protocol
|
||||||
|
============================
|
||||||
|
|
||||||
|
Full protocol spec: https://collectd.org/wiki/index.php/Plain_text_protocol
|
||||||
|
|
||||||
|
We are interested in submitting data (either to local or remote collectd)
|
||||||
|
|
||||||
|
PUTVAL \<Identifier\> \[\<OptionList\>\] Valuelist
|
||||||
|
|
||||||
|
Identifier
|
||||||
|
host "/" plugin \["-" plugin instance\] "/" type \["-" type instance\]
|
||||||
|
https://collectd.org/wiki/index.php/Identifier
|
||||||
|
|
||||||
|
|
||||||
|
Option list
|
||||||
|
interval - interval in seconds
|
||||||
|
|
||||||
|
Value list - comma separated values
|
||||||
|
|
||||||
|
Value - timestamp:val:val (if more)
|
||||||
|
|
||||||
|
Sample:
|
||||||
|
|
||||||
|
PUTVAL "testhost/testplugin/testmetric" 12345678:123:458
|
|
@ -0,0 +1,99 @@
|
||||||
|
How to use this
|
||||||
|
===============
|
||||||
|
|
||||||
|
The tools provided here are to be used for monitoring of OpenFest related infrastructure.
|
||||||
|
|
||||||
|
Current Tools
|
||||||
|
=============
|
||||||
|
`wlstats-gather.sh` - prototype wireless statistics gatherer for collectd infrastructure
|
||||||
|
|
||||||
|
Tools Usage
|
||||||
|
===========
|
||||||
|
|
||||||
|
wlstats-gather.sh
|
||||||
|
-----------------
|
||||||
|
This is intended to be used as an exec plugin for collectd. As such collectd and it's exec plugin are mandatory.
|
||||||
|
|
||||||
|
Please note: Although possible to load collectd plugin multiple times it is not advisable. For best results load a plugin only once
|
||||||
|
|
||||||
|
```
|
||||||
|
LoadPlugin exec
|
||||||
|
<Plugin exec>
|
||||||
|
Exec "username:groupname" "/path/to/wlstats-gather.sh"
|
||||||
|
</Plugin>
|
||||||
|
```
|
||||||
|
|
||||||
|
Please note:
|
||||||
|
* if username:groupname combo is ommitted you have no guarantees on the permissions the user that will execute the plugin will have.
|
||||||
|
|
||||||
|
Full example
|
||||||
|
============
|
||||||
|
Central collector (server)
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
```
|
||||||
|
Hostname central-collectd
|
||||||
|
FQDNLookup false
|
||||||
|
|
||||||
|
# how often data will come ... do not change once set
|
||||||
|
Interval 60
|
||||||
|
|
||||||
|
# timeouts and load optimization
|
||||||
|
Timeout 5
|
||||||
|
#ReadThreads 5
|
||||||
|
#WriteThreads 5
|
||||||
|
|
||||||
|
# logging
|
||||||
|
LoadPlugin syslog
|
||||||
|
<Plugin syslog>
|
||||||
|
LogLevel info
|
||||||
|
</Plugin>
|
||||||
|
|
||||||
|
# now start listening on network / UDP (25826)
|
||||||
|
LoadPlugin network
|
||||||
|
<Plugin Network>
|
||||||
|
Listen "0.0.0.0"
|
||||||
|
ReportStats true
|
||||||
|
</Plugin>
|
||||||
|
|
||||||
|
# and let's save the data
|
||||||
|
LoadPlugin rrdtool
|
||||||
|
<Plugin rrdtool>
|
||||||
|
DataDir /srv/metrics/collectd/rrd
|
||||||
|
# can lead to some data loss
|
||||||
|
CreateFilesAsync true
|
||||||
|
</Plugin>
|
||||||
|
```
|
||||||
|
|
||||||
|
AP (client) sending metrics
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
```
|
||||||
|
Hostname AP-left-1
|
||||||
|
FQDNLookup false
|
||||||
|
|
||||||
|
Interval 60
|
||||||
|
|
||||||
|
# timeouts and load optimization
|
||||||
|
Timeout 5
|
||||||
|
#ReadThreads 5
|
||||||
|
#WriteThreads 5
|
||||||
|
|
||||||
|
# logging
|
||||||
|
LoadPlugin syslog
|
||||||
|
<Plugin syslog>
|
||||||
|
LogLevel info
|
||||||
|
</Plugin>
|
||||||
|
|
||||||
|
# Sending to network / UDP (25826)
|
||||||
|
LoadPlugin network
|
||||||
|
<Plugin Network>
|
||||||
|
Server "central-collectd"
|
||||||
|
</Plugin>
|
||||||
|
|
||||||
|
# some mtrics to collect ...
|
||||||
|
LoadPlugin exec
|
||||||
|
<Plugin exec>
|
||||||
|
Exec "nobody" "/mon/wlstats-gather.sh"
|
||||||
|
</Plugin>
|
||||||
|
```
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Simple wireless statistics gatherer for collectd
|
||||||
|
#
|
||||||
|
# Description: Simple wireless statistics gatherer for collectd
|
||||||
|
# Prereqs: OpenWRT compatible system / wlinfo / wl
|
||||||
|
# Used via: Collectd exec plugin type
|
||||||
|
# Author: Vladimir Vitkov <vvitkov@linux-bg.org>
|
||||||
|
#
|
||||||
|
# Version: 0.1
|
||||||
|
# Date: 2015.05.25
|
||||||
|
#
|
||||||
|
# Changelog: 2015.05.25 - Initial version
|
||||||
|
|
||||||
|
# Variable Definition
|
||||||
|
_HOSTNAME='testhost'
|
||||||
|
_PERIOD=60 # in seconds
|
||||||
|
_PLUGIN='wlstats'
|
||||||
|
|
||||||
|
# Binaries
|
||||||
|
_iwinfo='iwinfo'
|
||||||
|
_iw='iw'
|
||||||
|
|
||||||
|
# main loop
|
||||||
|
while true ; do
|
||||||
|
_start_time=$(date +%s)
|
||||||
|
|
||||||
|
# do work
|
||||||
|
for _interface in $(${_iwinfo} | grep 'ESSID' | awk '{print $1}') ; do
|
||||||
|
#for _interface in wlan0 ; do
|
||||||
|
# get detailed essid info and prep for send
|
||||||
|
${_iwinfo} ${_interface} info > /var/run/${_start_time}_${_interface}
|
||||||
|
_tx_power=$(grep 'Tx-Power' /var/run/${_start_time}_${_interface} | awk '{print $2}')
|
||||||
|
_link_quality=$(grep 'Link Quality' /var/run/${_start_time}_${_interface} | awk '{print $6}' | cut -d'/' -f1)
|
||||||
|
_signal=$(grep 'Signal' /var/run/${_start_time}_${_interface} | awk '{print $2}' | tr -d '-')
|
||||||
|
_noise=$(grep 'Noise' /var/run/${_start_time}_${_interface} | awk '{print $5}' | tr -d '-')
|
||||||
|
_bit_rate=$(grep 'Bit Rate' /var/run/${_start_time}_${_interface} | awk '{print $3}')
|
||||||
|
_clients=$(${_iw} ${_interface} station dump | grep '^Station' | wc -l)
|
||||||
|
|
||||||
|
# start emiting metrics
|
||||||
|
echo -e "PUTVAL ${_HOSTNAME}/${_PLUGIN}-${_interface}/gauge-tx_power ${_start_time}:${_tx_power}"
|
||||||
|
echo -e "PUTVAL ${_HOSTNAME}/${_PLUGIN}-${_interface}/gauge-link_quality ${_start_time}:${_link_quality}"
|
||||||
|
echo -e "PUTVAL ${_HOSTNAME}/${_PLUGIN}-${_interface}/gauge-signal ${_start_time}:${_signal}"
|
||||||
|
echo -e "PUTVAL ${_HOSTNAME}/${_PLUGIN}-${_interface}/gauge-noise ${_start_time}:${_noise}"
|
||||||
|
echo -e "PUTVAL ${_HOSTNAME}/${_PLUGIN}-${_interface}/gauge-bit_rate ${_start_time}:${_bit_rate}"
|
||||||
|
echo -e "PUTVAL ${_HOSTNAME}/${_PLUGIN}-${_interface}/gauge-clients ${_start_time}:${_clients}"
|
||||||
|
|
||||||
|
# now let's pick up the statistics
|
||||||
|
for _metric in $(ls -1 /sys/kernel/debug/ieee80211/*/netdev:${_interface}/../statistics/) ; do
|
||||||
|
echo -e "PUTVAL ${_HOSTNAME}/${_PLUGIN}-${_interface}/counter-$(echo ${_metric}) ${_start_time}:$(cat /sys/kernel/debug/ieee80211/*/netdev:${_interface}/../statistics/${_metric})"
|
||||||
|
done
|
||||||
|
|
||||||
|
# nuke the temp file
|
||||||
|
rm -f /var/run/${_start_time}_${_interface}
|
||||||
|
done
|
||||||
|
|
||||||
|
# now calculate sleep time
|
||||||
|
_end_time=$(date +%s)
|
||||||
|
sleep $(echo ${_PERIOD} ${_end_time} ${_start_time} | awk '{print $1 - $2 + $3 }')
|
||||||
|
done
|
Loading…
Reference in New Issue