<commit_before>#!/bin/bash

RHIZO_DIR="/var/rhizomatica/rrd"

loadaverage=`cat /proc/loadavg | awk '{print $1":"$2":"$3}'`
rrdtool update $RHIZO_DIR/loadaverage.rrd N:$loadaverage

cpustat=`cat /proc/stat|head -1| sed "s/^cpu\ \+\([0-9]*\)\ \([0-9]*\)\ \([0-9]*\)\ \([0-9]*\).*/\1:\2:\3:\4/"`
rrdtool update $RHIZO_DIR/cpu.rrd N:$cpustat

temperature=`sensors 2>/dev/null | grep temp1: | head -1 | awk '{print $2}' | sed -e 's/°C//g' -e 's/\+//g'`
if [ -n "$temperature" ]; then
  rrdtool update $RHIZO_DIR/temperature.rrd N:$temperature
fi

linev=`/sbin/apcaccess status 2>/dev/null | grep LINEV | head -1 | awk '{print $3}'`
if [ -n "$linev" ]; then
  /usr/bin/rrdtool update $RHIZO_DIR/voltage.rrd N:$linev
  echo $linev > /tmp/voltage
fi


C=$(egrep ^Cached /proc/meminfo|awk '{print $2}')
B=$(egrep ^Buffers /proc/meminfo|awk '{print $2}')
F=$(egrep ^MemFree /proc/meminfo|awk '{print $2}')
T=$(egrep ^MemTotal /proc/meminfo|awk '{print $2}')
ST=$(egrep ^SwapTotal /proc/meminfo|awk '{print $2}')
SF=$(egrep ^SwapFree /proc/meminfo|awk '{print $2}')
memupdate="${C}:${B}:${F}:${T}:${ST}:${SF}"
rrdtool update $RHIZO_DIR/memory.rrd N:$memupdate

DF=$(df -m|grep /var |awk '{print $2":"$3}')
#DI=$(cat /proc/partitions|grep sda1| awk '{print $5":"$6":"$7":"$8":"$9":"$10":"$11":"$12":"$13":"$14":"$15}'
rrdtool update $RHIZO_DIR/disk.rrd N:$DF

ethstats=`cat /proc/net/dev | grep eth0 | cut -d: -f2 | awk '{print $1":"$2":"$3":"$4":"$6":"$9":"$10":"$11":"$12":"$13":"$14 }'`
rrdtool update $RHIZO_DIR/eth0.rrd N:$ethstats

$RHIZO_DIR/../bin/platform_graph_rrd.sh > /dev/null<commit_msg>platform stats: Make some of the varying data sources configurable<commit_after>#!/bin/bash

RHIZO_DIR="/var/rhizomatica/rrd"

. /home/rhizomatica/bin/vars.sh

loadaverage=`cat /proc/loadavg | awk '{print $1":"$2":"$3}'`
rrdtool update $RHIZO_DIR/loadaverage.rrd N:$loadaverage

cpustat=`cat /proc/stat|head -1| sed "s/^cpu\ \+\([0-9]*\)\ \([0-9]*\)\ \([0-9]*\)\ \([0-9]*\).*/\1:\2:\3:\4/"`
rrdtool update $RHIZO_DIR/cpu.rrd N:$cpustat

temperature=`sensors 2>/dev/null | grep temp1: | head -1 | awk '{print $2}' | sed -e 's/°C//g' -e 's/\+//g'`
if [ -n "$temperature" ]; then
  rrdtool update $RHIZO_DIR/temperature.rrd N:$temperature
fi

linev=`/sbin/apcaccess status 2>/dev/null | grep LINEV | head -1 | awk '{print $3}'`
if [ -n "$linev" ]; then
  /usr/bin/rrdtool update $RHIZO_DIR/voltage.rrd N:$linev
  echo $linev > /tmp/voltage
fi


C=$(egrep ^Cached /proc/meminfo|awk '{print $2}')
B=$(egrep ^Buffers /proc/meminfo|awk '{print $2}')
F=$(egrep ^MemFree /proc/meminfo|awk '{print $2}')
T=$(egrep ^MemTotal /proc/meminfo|awk '{print $2}')
ST=$(egrep ^SwapTotal /proc/meminfo|awk '{print $2}')
SF=$(egrep ^SwapFree /proc/meminfo|awk '{print $2}')
memupdate="${C}:${B}:${F}:${T}:${ST}:${SF}"
rrdtool update $RHIZO_DIR/memory.rrd N:$memupdate

if [ -n "$STAT_DISK" ]; then
  DF=$(df -m|grep $STAT_DISK |awk '{print $2":"$3}')
  rrdtool update $RHIZO_DIR/disk.rrd N:$DF
fi

if [ -n "$STAT_IF" ]; then
  ethstats=`cat /proc/net/dev | grep $STAT_IF | cut -d: -f2 | awk '{print $1":"$2":"$3":"$4":"$6":"$9":"$10":"$11":"$12":"$13":"$14 }'`
  rrdtool update $RHIZO_DIR/eth0.rrd N:$ethstats
fi
$RHIZO_DIR/../bin/platform_graph_rrd.sh > /dev/null
{'fraction_non_alphanumeric': 0.2620668316831683, 'fraction_numerical': 0.03620049504950495, 'mean_word_length': 4.622608695652174, 'pattern_counts': {'":': 36, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2942647', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1417, 'n_words': 285}