first commit
This commit is contained in:
70
plugins/ina219
Executable file
70
plugins/ina219
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ina219 - Plugin to measure power consumption.
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Contributed by Florian Klemenz
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Power'
|
||||
echo 'graph_args --base 1 -l 0 '
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_vlabel mW'
|
||||
echo 'graph_category power'
|
||||
echo 'power.label power'
|
||||
echo 'power.draw LINE'
|
||||
print_warning power
|
||||
print_critical power
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ROUNDS=5
|
||||
|
||||
VOLTAGE=0
|
||||
CURRENT=0
|
||||
POWER=0
|
||||
|
||||
for i in $(seq ${ROUNDS}); do
|
||||
RESULT=$(/usr/bin/ina219)
|
||||
|
||||
VOLTAGE_RAW=$(echo $RESULT | /bin/sed 's/\([0-9]\+\)mV \+\([0-9\.]\+\)mA/\1/')
|
||||
VOLTAGE=$(echo "scale=3; $VOLTAGE+$VOLTAGE_RAW" | /usr/bin/bc)
|
||||
|
||||
CURRENT_RAW=$(echo $RESULT | /bin/sed 's/\([0-9]\+\)mV \+\([0-9\.]\+\)mA/\2/')
|
||||
CURRENT=$(echo "scale=3; $CURRENT+$CURRENT_RAW" | /usr/bin/bc)
|
||||
|
||||
done
|
||||
|
||||
VOLTAGE=$(echo "scale=3; $VOLTAGE/$ROUNDS" | /usr/bin/bc)
|
||||
CURRENT=$(echo "scale=3; $CURRENT/$ROUNDS" | /usr/bin/bc)
|
||||
POWER=$(echo "scale=3; $VOLTAGE*$CURRENT/1000000" | /usr/bin/bc)
|
||||
|
||||
|
||||
echo "power.value $POWER"
|
||||
Reference in New Issue
Block a user