update scripts

This commit is contained in:
mrtg 2024-02-18 13:27:36 +01:00
parent 8b50faa72c
commit ee4dc14625
7 changed files with 25 additions and 24 deletions

View File

@ -35,7 +35,7 @@ $v->{GENERATED} = localtime;
sub getCurrentPrice {
my ($symbol) = @_;
my ($start,$step,$name,$data) = RRDs::fetch("${rrdpath}/crypto-${symbol}.rrd","LAST","--start","-10m");
return($data->[0]->[0]);
return($data->[0]->[0] || 0);
}
sub getLastWeekValue {

View File

@ -4,7 +4,7 @@ RRDDIR="/var/www/localhost/rrd"
RRDPREFIX="crypto-"
TMPLDIR="/var/www/localhost/tmpl"
for c in AAVE ALGO BTC CVC DOGE DNT EOS ETH LRC LTC RAD REN SNX XLM XTZ ZRX;
for c in AAVE ALGO BTC CVC DOGE DNT EOS ETH LRC LTC REN SNX XLM XTZ;
do
if [[ ! -f "${RRDDIR}/${RRDPREFIX}${c}.rrd" ]];
then

16
scripts/getLXD.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
RRDDIR="/var/www/localhost/rrd"
RRDPREFIX="lxc-"
TMPLDIR="/var/www/localhost/tmpl"
/bin/echo -n > /tmp/lxd.stats
lxc list 10.5.0.1: -f json | jq -r '.[] | "\(.name) \(.state.cpu.usage) \(.state.memory.usage) \(.state.network.eth0.counters.bytes_received) \(.state.network.eth0.counters.bytes_sent)"' | while read i;
do
echo "$i" | sed 's/null/0/g' >> /tmp/lxd.stats
done
/usr/bin/lxc_index.sh > /var/www/localhost/htdocs/lxc.html
/usr/bin/lxc_mrtg.sh > /var/www/localhost/config/lxc.cfg
/usr/bin/lxc_rrd-tmpl.sh

View File

@ -1,15 +0,0 @@
#!/bin/sh
DIR=/var/www/lxc-api/htdocs
lxc-ls -1 --running > "$DIR/index.html"
lxc-ls -1 --running | while read c;
do
[ ! -d "$DIR/$c" ] && mkdir "$DIR/$c";
t="$(lxc-info -H -S -n $c)"
for i in CPU Memory RX TX
do
echo -e "$t" | grep "$i " | awk -F: '{print $2}' | sed 's/^[ ]*//g' > "$DIR/$c/$i"
done
done

View File

@ -16,7 +16,7 @@ echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www
<H1><a href="/">home</a>&nbsp;<a href="/lxc.html">lxc</a>&nbsp;<a href="/crypto.html">crypto</a>&nbsp;<a href="/power.html">power</a>&nbspLXC - Monitoring</H1>
<DIV>
'
curl -s http://10.3.0.1 | sort | while read c;
awk '{print $1}' /tmp/lxd.stats | while read c;
do
echo "<DIV>
<B>[$c]</B><BR/>

View File

@ -3,16 +3,16 @@
echo "WorkDir: /var/www/mrtg/rrd"
echo "LogFormat: rrdtool"
curl -s http://10.3.0.1 | while read c;
awk '{print $1}' /tmp/lxd.stats | while read c;
do
echo "# $c"
echo "Target[lxc-$c.cpu]: \`curl -s http://10.3.0.1/$c/CPU; echo 0\`"
echo "Target[lxc-$c.cpu]: \`grep '$c ' /tmp/lxd.stats | awk '{print \$2}'; echo 0\`"
echo "Title[lxc-$c.cpu]: [CPU] $c"
echo "MaxBytes[lxc-$c.cpu]: 42949672950000000"
echo "Target[lxc-$c.memory]: \`curl -s http://10.3.0.1/$c/Memory; echo 0\`"
echo "Target[lxc-$c.memory]: \`grep '$c ' /tmp/lxd.stats | awk '{print \$3}'; echo 0\`"
echo "Title[lxc-$c.memory]: [Memory] $c"
echo "MaxBytes[lxc-$c.memory]: 42949672950000000"
echo "Target[lxc-$c.net]: \`curl -s http://10.3.0.1/$c/RX http://10.3.0.1/$c/TX\`"
echo "Target[lxc-$c.net]: \`grep '$c ' /tmp/lxd.stats | awk '{print \$4 \"\n\" \$5}'\`"
echo "Title[lxc-$c.net]: [Net] $c"
echo "MaxBytes[lxc-$c.net]: 42949672950000000"
echo ""

View File

@ -3,7 +3,7 @@
DIR="/var/www/mrtg/tmpl"
cpuCount=$(grep processor /proc/cpuinfo | wc -l)
curl -s http://10.3.0.1 | while read c;
awk '{print $1}' /tmp/lxd.stats | while read c;
do
echo "-v memory
@ -29,7 +29,7 @@ CDEF:in=i,$cpuCount,/,10000000,/
AREA:in#CC9A5780
LINE1:in#CC9A57" > "$DIR/lxc-$c.cpu.tmpl"
echo "-v in/up bps
echo "-v in/out bps
-t [$c] net
--full-size-mode
--color=BACK#343637