-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
novos comandos e gerador de metricas
- Loading branch information
1 parent
e7b9baa
commit a92c48b
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
cat << EOF | ||
# HELP http_requests_total The total number of HTTP requests. | ||
# TYPE http_requests_total counter | ||
EOF | ||
|
||
# Data/Hora atual | ||
AGORA=$(date +"%s") | ||
# Numero de datapoints historicos | ||
NUMERO_DE_MINUTOS=60 | ||
# As metricas vao comecar a surgir aqui | ||
PONTO_DE_PARTIDA=$(($AGORA - ($NUMERO_DE_MINUTOS * 60))) | ||
|
||
NUMERO_DE_ERROS=0 | ||
MINUTO_EM_QUE_ERROS_COMECAM_A_OCORRER=10 | ||
|
||
for i in $( seq 1 $NUMERO_DE_MINUTOS ) | ||
do | ||
PROXIMA_DATA=$(($PONTO_DE_PARTIDA + ($i * 60))) | ||
echo "http_requests_total{code=\"200\",service=\"servicoX\"} 1000 $PROXIMA_DATA" | ||
echo "http_requests_total{code=\"500\",service=\"servicoX\"} $NUMERO_DE_ERROS $PROXIMA_DATA" | ||
if [[ $i -ge $MINUTO_EM_QUE_ERROS_COMECAM_A_OCORRER ]]; then | ||
# Entramos na janela de erros, vamos incrementar o num de erros a cada minuto | ||
NUMERO_DE_ERROS=$((NUMERO_DE_ERROS+1)) | ||
fi | ||
done | ||
|
||
echo "# EOF" |