Created
May 20, 2020 15:55
-
-
Save jaimevalero/0473d363e24e40735a9a5dbf2c6c92a7 to your computer and use it in GitHub Desktop.
measure curl times and send it to graphite
This file contains 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
[root@prod-epg-icimas-01 plugins]# cat /usr/lib64/nagios/plugins/check_times/check_times.sh | |
# Measure times and send it to graphite" | |
# time_appconnect The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0) | |
# | |
# time_connect The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed. | |
# | |
# time_namelookup The time, in seconds, it took from the start until the name resolving was completed. | |
# | |
# time_pretransfer The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved. | |
# time_redirect The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3) | |
# time_starttransfer The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result. | |
# time_total The total time, in seconds, that the full operation lasted. The time will be displayed with millisecond resolution. | |
# url_effective The URL that was fetched last. This is most meaningful if you've told curl to follow location: headers. | |
SSH_OPTIONS=" -i /var/spool/icinga/.ssh/id_rsa2 -l epg " | |
source /usr/lib64/nagios/plugins/check_times/.credentials | |
export GRAPHITE_SERVER=prod-epg-graph-01 | |
export GRAPHITE_PORT=2003 | |
BASE_METRIC=stats.icinga.load_times | |
VMLIST="BCN:puppet-code.aislada:puppet MAD:ci-epg-vmwar-01:puppet BOE:test-epg-misc-01:puppet" | |
URL="https://$CRED@jirapdi.tid.es/browse/JIRA" | |
DATE=`date +%s` | |
for line in `echo $VMLIST` | |
do | |
SEDE=`echo $line | cut -d: -f1 ` | |
VM=`echo $line | cut -d: -f2 ` | |
CHECK=`echo $line | cut -d: -f3 ` | |
echo "curl -k -L -o /dev/null -s -w '\n | |
time_namelookup: %{time_namelookup}\n | |
time_connect: %{time_connect}\n | |
time_appconnect: %{time_appconnect}\n | |
time_pretransfer: %{time_pretransfer}\n | |
time_redirect: %{time_redirect}\n | |
time_starttransfer: %{time_starttransfer}\n | |
time_total: %{time_total}\n' $URL " | ssh $SSH_OPTIONS ${VM} | grep : | tr ',' '.' | sed -e "s/^/${BASE_METRIC}\.${CHECK}\.${SEDE}\./g" | sed -e 's/\t/ /g' | sed -e 's/ \. /\./g' | tr -d : | sed -e "s/$/ $DATE/g" | nc $GRAPHITE_SERVER $GRAPHITE_PORT | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment