Nagy Károly Gábriel
6 years ago
commit
ea14803794
9 changed files with 104 additions and 0 deletions
@ -0,0 +1,13 @@ |
|||||||
|
# FluXPlug |
||||||
|
|
||||||
|
`fluxplug` is group of shell utilities that makes feeding data to InfluxDB via HTTP easier. |
||||||
|
|
||||||
|
`fluxplug` aspires to be a replacement for telegraf from InfluxData writen in shell and making output only to InfluxDB's HTTP API. |
||||||
|
|
||||||
|
For now FluXPlug has the following plugins (measurements): |
||||||
|
* Chrony - it will feed data from a `chrony` client. |
||||||
|
* Disks - it will parse `df` data and feed it to InfluxDB |
||||||
|
* LoadAVG - parse `/proc/loadavg` and feed InfluxDB with it |
||||||
|
* MemInfo - parse `/proc/meminfo` and feeds the result to InfluxDB |
||||||
|
* Packs - will execute APT and feed InfluxDB with the number of upgradable packages (no modifications to the system will be made) |
||||||
|
|
@ -0,0 +1,10 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
set -o noclobber |
||||||
|
|
||||||
|
HOME=$(dirname $0) |
||||||
|
. "$HOME"/master |
||||||
|
|
||||||
|
LINE=$($CHRONY | "$AWK" -F"," -v myhost="$myhost" -v time=`date -u +%s%N` '{printf "chrony,host=%s,reference_id=%s,stratum=%si,leap_status=%s system_time=%s,last_offset=%s,rms_offset=%s,frequency=%s,residual_frequency=%s,skew=%s,root_delay=%s,root_dispersion=%s,update_interval=%s %s\n",myhost,$2,$3,$13,$4,$5,$6,$7,$8,$9,$10,$11,$12,time}') |
||||||
|
|
||||||
|
writeline "$LINE" "$MAXLINES" |
@ -0,0 +1,11 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
set -o noclobber |
||||||
|
|
||||||
|
HOME=$(dirname $0) |
||||||
|
. "$HOME"/master |
||||||
|
|
||||||
|
LINE=$($DF | $SED | "$AWK" -v myhost="$myhost" -v time=`date -u +%s%N` '{sub(/\%$/,"",$5);printf "disks,host=%s,disk=%s total=%s,available=%s,used=%s,percent=%s %s\n",myhost,$1,$2,$4,$3,$5,time}') |
||||||
|
|
||||||
|
writeline "$LINE" $((2*$MAXLINES)) |
||||||
|
|
@ -0,0 +1,11 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
set -o noclobber |
||||||
|
|
||||||
|
HOME=$(dirname $0) |
||||||
|
. "$HOME"/master |
||||||
|
|
||||||
|
LINE=$("$AWK" -v myhost="$myhost" -v time=`date -u +%s%N` '{load1=$1; load5=$2; load15=$3 } END {printf "loadavg,host=%s load_1=%s,load_5=%s,load_15=%s %s\n",myhost,load1,load5,load15,time}' /proc/loadavg ) |
||||||
|
|
||||||
|
writeline "$LINE" "$MAXLINES" |
||||||
|
|
@ -0,0 +1,35 @@ |
|||||||
|
#!/bin/sh |
||||||
|
myhost=$(/bin/hostname -f) |
||||||
|
CURL="/usr/bin/curl -is -u user:password -XPOST 'http://influxdb.url/write?db=jpi' --data-binary " |
||||||
|
AWK="/usr/bin/awk" |
||||||
|
WC="/usr/bin/wc" |
||||||
|
DF="/bin/df -t ext4 " |
||||||
|
SED="/bin/sed -e 1d" |
||||||
|
CHRONY="/usr/bin/chronyc -nc tracking" |
||||||
|
|
||||||
|
z=$(basename $0) |
||||||
|
IAM="${z%.*}" |
||||||
|
|
||||||
|
tmpfile="$HOME"/tmp/"$IAM" |
||||||
|
datafile="$HOME"/data/"$IAM" |
||||||
|
|
||||||
|
MAXLINES=10 |
||||||
|
|
||||||
|
sendfile() { |
||||||
|
datfile="$1" |
||||||
|
echo $CURL" @$datfile" |
||||||
|
} |
||||||
|
|
||||||
|
writeline() { |
||||||
|
line="$1" |
||||||
|
length="$2" |
||||||
|
echo "$line" >> "$tmpfile" |
||||||
|
lines=$("$WC" -l < "$tmpfile") |
||||||
|
if [ "$lines" -ge $length ]; then |
||||||
|
mv "$tmpfile" "$datafile" |
||||||
|
sendfile "$datafile" |
||||||
|
fi |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,11 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
set -o noclobber |
||||||
|
|
||||||
|
HOME=$(dirname $0) |
||||||
|
. "$HOME"/master |
||||||
|
|
||||||
|
LINE=$("$AWK" -v myhost="$myhost" -v time=`date -u +%s%N` '{if ($1 ~/MemTotal:/) memtotal=$2; if ($1 ~/MemFree:/) memfree=$2; if ($1 ~/MemAvailable:/) memavailable=$2} END {if ( memtotal && memfree && memavailable ) printf "meminfo,host=%s mem_total=%si,mem_free=%si,mem_available=%si %s\n",myhost,memtotal,memfree,memavailable,time}' /proc/meminfo) |
||||||
|
|
||||||
|
writeline "$LINE" "$MAXLINES" |
||||||
|
|
@ -0,0 +1,13 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
set -o noclobber |
||||||
|
|
||||||
|
HOME=$(dirname $0) |
||||||
|
. "$HOME"/master |
||||||
|
|
||||||
|
LINE=$("$APT" | "$AWK" -v myhost="$myhost" -v time=`date -u +%s%N` '{if ($1~/^Inst/) counter=counter+1} END {if (counter) printf "packages,host=%s packs=%si %s\n",myhost,counter,time}') |
||||||
|
|
||||||
|
if [ -n "${LINE##+([[:space:]])}" ]; then # <= FIXME! find a better way. |
||||||
|
writeline "$LINE" "$MAXLINES" |
||||||
|
fi |
||||||
|
|
Loading…
Reference in new issue