Cacti/Bcache

From fakedWiki
Revision as of 17:24, 5 September 2016 by Jan (talk | contribs) (Created page with "== Host using bcache == Add to your '''/etc/snmp/snmpd.conf''' <pre> exec bcache /usr/bin/cacti-bcache.sh </pre> Create '''/usr/bin/cacti-bcache.sh''' <pre> #!/bin/bash PATH...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Host using bcache

Add to your /etc/snmp/snmpd.conf

exec bcache /usr/bin/cacti-bcache.sh

Create /usr/bin/cacti-bcache.sh

#!/bin/bash

PATH='/sys/fs/bcache/'

if [ ! -d ${PATH} ]; then
  echo "Error: bcache not loaded"
  exit 1
fi

DIRTY_DATA=0

get_dirty_data () {
  local size=$(<${PATH}/${1}/bdev0/dirty_data)
  DIRTY_DATA=$(/usr/bin/numfmt --from=iec ${size})
}

for dir in "${PATH}/*/"; do
  uuid=$(/usr/bin/basename ${dir})
  get_dirty_data ${uuid}
done

echo "dirty_data:${DIRTY_DATA}"

exit 0

Cacti

/usr/share/cacti/resource/scripts/get_bcache.sh

#!/bin/bash

if [ ${#} -ne 3 ]; then
  echo "Usage: $0 <host> <community>"
  exit 0
fi

snmptable -c${2} -v1 ${1} .1.3.6.1.4.1.2021.8 | sed -n "s/\s*[0-9]+*\s*bcache.*\s*0\s*\(.*\)\s*noError/\1/p"

Data Template

tbc