Last active
August 29, 2015 14:08
-
-
Save bahamat/5622ed184d251921092e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright 2014 Brian Bennett <[email protected]> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# psum2graphite.sh graphite-server [graphite-server...] | |
# Send the promise summary of the last successful, non-update cf-agent run to | |
# one or more graphite carbon servers. | |
# Enter the hostname of your graphite server here. | |
GRAPHITE_SERVERS="$*" | |
# Graph only the last normal run | |
PROMISE_SUMMARY=($(tail -2 /var/cfengine/promise_summary.log | grep -v update.cf)) | |
LENGTH=${#PROMISE_SUMMARY[@]} | |
TIME=${PROMISE_SUMMARY[0]/,*/} | |
KEPT=${PROMISE_SUMMARY[$((${LENGTH}-8))]/%%,/} | |
REPAIRED=${PROMISE_SUMMARY[$((${LENGTH}-5))]/%%,/} | |
NOT_KEPT=${PROMISE_SUMMARY[$((${LENGTH}-1))]/%%/} | |
for graphite_server in ${GRAPHITE_SERVERS}; do | |
socat -t 1 STDIN TCP:${graphite_server}:2003 << __SUMMARY__ & | |
cf-agent.${HOSTNAME}.kept $KEPT $TIME | |
cf-agent.${HOSTNAME}.repaired $REPAIRED $TIME | |
cf-agent.${HOSTNAME}.not_kept $NOT_KEPT $TIME | |
__SUMMARY__ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment