Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple script to quickly to monitor pcfdev
#!/bin/bash
date=$(date +%d/%m/%y)
daterev=$(date +%Y%m%d)
timestamp=$(date +%s)
dir=/home/vcap/pcfdev-check
if [ ! -d "$dir" ]; then
mkdir -p $dir
fi
#Global storage status df –k
if [ ! -f "$dir/$daterev.fs-size.csv" ]; then
echo "timestamp;filesystem;1K-blocks;Used;Available;Use%;Mounted on" > $dir/$daterev.fs-size.csv
fi
sudo df -k | grep -v Filesystem | awk -v var="$timestamp" '{print var";"$1";"$2";"$3";"$4";"$5";"$6}' >> $dir/$daterev.fs-size.csv
#Monitoring of persistent folder “du -sh *” on /var/vcap/data/
if [ ! -f "$dir/$daterev.vcapdata-size.csv" ]; then
echo "timestamp;size (ko);directory" > $dir/$daterev.vcapdata-size.csv
fi
sudo du -sk /var/vcap/data/* | awk -v var="$timestamp" '{print var";"$1";"$2}' >> $dir/$daterev.vcapdata-size.csv ; sudo du -sk /var/vcap/data | awk -v var="$timestamp" '{print var";"$1";"$2}' >> $dir/$daterev.vcapdata-size.csv
#Monitoring of persistent folder “du -sh *” on /var/vcap/data/garden/realgraph
if [ ! -f "$dir/$daterev.gardenrealgraph-size.csv" ]; then
echo "timestamp;size (ko);directory" > $dir/$daterev.gardenrealgraph-size.csv
fi
sudo du -sk /var/vcap/data/garden/realgraph/* | awk -v var="$timestamp" '{print var";""realgraph_size"";"$1";"$2}' >> $dir/$daterev.gardenrealgraph-size.csv ; sudo du -sk /var/vcap/data/garden/realgraph | awk -v var="$timestamp" '{print var";"$1";"$2}' >> $dir/$daterev.gardenrealgraph-size.csv
#Monitoring of PCF processes : monit summary
if [ ! -f "$dir/$daterev.monit-summary.csv" ]; then
echo "timestamp;service;state" > $dir/$daterev.monit-summary.csv
fi
sudo -E /var/vcap/bosh/bin/monit summary| awk -v var="$timestamp" '{print var";"$2";"$3}' >> $dir/$daterev.monit-summary.csv
#Api Check
if [ ! -f "$dir/$daterev.api-availability.csv" ]; then
echo "timestamp;api-name" > $dir/$daterev.api-availability.csv
fi
curl -X GET "http://127.0.0.1/v2/info" -H "Host: api.pcfdev.local" -s | jq .name | awk -v var="$timestamp" '{print var";"$1}' >> $dir/$daterev.api-availability.csv
#Number of running containers
if [ ! -f "$dir/$daterev.nozzle-output.csv" ]; then
echo "timestamp;origin;eventType;deployment;job;index;ip;valueMetric-name;valueMetric-value" > $dir/$daterev.nozzle-output.csv
fi
cf nozzle -n | grep LRPsRunning | tee $dir/$daterev.nozzle-output.prev &
sleep 60 && sudo killall ozzle-plugin-linux
cat $dir/$daterev.nozzle-output.prev | tr " " ";" | awk -F '[:;<]' '{print $6";"$2";"$4";"$8";"$10";"$12";"$14";"$16";"$18";"$20}' | sed 's/;;/;/g' >> $dir/$daterev.nozzle-output.csv
rm -rf $dir/$daterev.nozzle-output.prev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.