Skip to content
Snippets Groups Projects
Commit e265745f authored by Cristian Weiland's avatar Cristian Weiland
Browse files

Add scripts to rename index and improve create config script.

parent f8e05a81
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
echo "Usage: $0 <user> <password>"
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <user> <password>"
exit
fi
./insert_register_payment.sh 2016 11 30 $1 $2
./insert_register_payment.sh 2016 10 31 $1 $2
......
......@@ -24,8 +24,12 @@ data = {
with open('configs/config-' + sys.argv[1] + '-' + sys.argv[2] + '.json', 'w') as outfile:
json.dump(data, outfile, indent=4, sort_keys=True)
with open('logstash_config.example') as infile:
example = infile.read()
if int(sys.argv[1]) <= 2014 or (int(sys.argv[1]) == 2015 and int(sys.argv[2]) <= 3):
with open('logstash_config_2013.example') as infile:
example = infile.read()
else:
with open('logstash_config.example') as infile:
example = infile.read()
output = example % { "timestamp": sys.argv[3] + '/' + sys.argv[2] + '/' + sys.argv[1] + ' 00:00:00'
, "date": sys.argv[1] + '-' + sys.argv[2]
......
......@@ -59,7 +59,7 @@ output {
user => "%(user)s"
password => "%(password)s"
hosts => "http://node1.c3sl.ufpr.br:9200"
index => "ufpr-csv-%(date)s"
index => "ufpr-servidores-%(date)s"
workers => 1
}
stdout {}
......
input {
stdin {
codec => plain {
charset => "Windows-1252"
}
}
}
filter {
csv {
columns => [ "ID_SERVIDOR_PORTAL", "NOME", "CPF", "MATRICULA", "DESCRICAO_CARGO", "CLASSE_CARGO", "REFERENCIA_CARGO", "PADRAO_CARGO", "NIVEL_CARGO", "SIGLA_FUNCAO", "NIVEL_FUNCAO", "FUNCAO", "CODIGO_ATIVIDADE", "ATIVIDADE", "OPCAO_FUNCAO_TOTAL", "UORG_LOTACAO", "COD_ORG_LOTACAO", "ORG_LOTACAO", "COD_ORGSUP_LOTACAO", "ORGSUP_LOTACAO", "UORG_EXERCICIO", "COD_ORG_EXERCICIO", "ORG_EXERCICIO", "COD_ORGSUP_EXERCICIO", "ORGSUP_EXERCICIO", "TIPO_VINCULO", "SITUACAO_VINCULO", "DATA_INICIO_AFASTAMENTO", "DATA_TERMINO_AFASTAMENTO", "REGIME_JURIDICO", "JORNADA_DE_TRABALHO", "DATA_INGRESSO_CARGOFUNCAO", "DATA_NOMEACAO_CARGOFUNCAO", "DATA_INGRESSO_ORGAO", "DOCUMENTO_INGRESSO_SERVICOPUBLICO", "DATA_DIPLOMA_INGRESSO_SERVICOPUBLICO", "DIPLOMA_INGRESSO_CARGOFUNCAO", "DIPLOMA_INGRESSO_ORGAO", "DIPLOMA_INGRESSO_SERVICOPUBLICO", "UF_EXERCICIO", "ANO", "MES", "REMUNERAÇÃO BÁSICA BRUTA (R$)", "REMUNERAÇÃO BÁSICA BRUTA (U$)", "ABATE-TETO (R$)", "ABATE-TETO (U$)", "GRATIFICAÇÃO NATALINA (R$)", "GRATIFICAÇÃO NATALINA (U$)", "ABATE-TETO DA GRATIFICAÇÃO NATALINA (R$)", "ABATE-TETO DA GRATIFICAÇÃO NATALINA (U$)", "FÉRIAS (R$)", "FÉRIAS (U$)", "OUTRAS REMUNERAÇÕES EVENTUAIS (R$)", "OUTRAS REMUNERAÇÕES EVENTUAIS (U$)", "IRRF (R$)", "IRRF (U$)", "PSS/RPGS (R$)", "PSS/RPGS (U$)", "PENSÃO MILITAR (R$)", "PENSÃO MILITAR (U$)", "FUNDO DE SAÚDE (R$)", "FUNDO DE SAÚDE (U$)", "DEMAIS DEDUÇÕES (R$)", "DEMAIS DEDUÇÕES (U$)", "REMUNERAÇÃO APÓS DEDUÇÕES OBRIGATÓRIAS (R$)", "REMUNERAÇÃO APÓS DEDUÇÕES OBRIGATÓRIAS (U$)", "VERBAS INDENIZATÓRIAS REGISTRADAS EM SISTEMAS DE PESSOAL - CIVIL (R$)(*)", "VERBAS INDENIZATÓRIAS REGISTRADAS EM SISTEMAS DE PESSOAL - CIVIL (U$)(*) ", "VERBAS INDENIZATÓRIAS REGISTRADAS EM SISTEMAS DE PESSOAL - MILITAR (R$)(*)", "VERBAS INDENIZATÓRIAS REGISTRADAS EM SISTEMAS DE PESSOAL - MILITAR (U$)(*)", "TOTAL DE VERBAS INDENIZATÓRIAS (R$)(*)", "TOTAL DE VERBAS INDENIZATÓRIAS (U$)(*)", "TOTAL DE HONORÁRIOS (JETONS)"]
separator => " "
add_field => { "timestamp" => "%(timestamp)s" }
}
mutate {
convert => { "ANO" => "integer" }
convert => { "MES" => "integer" }
convert => { "REMUNERAÇÃO BÁSICA BRUTA (R$)" => "float" }
convert => { "REMUNERAÇÃO BÁSICA BRUTA (U$)" => "float" }
convert => { "ABATE-TETO (R$)" => "float" }
convert => { "ABATE-TETO (U$)" => "float" }
convert => { "GRATIFICAÇÃO NATALINA (R$)" => "float" }
convert => { "GRATIFICAÇÃO NATALINA (U$)" => "float" }
convert => { "ABATE-TETO DA GRATIFICAÇÃO NATALINA (R$)" => "float" }
convert => { "ABATE-TETO DA GRATIFICAÇÃO NATALINA (U$)" => "float" }
convert => { "FÉRIAS (R$)" => "float" }
convert => { "FÉRIAS (U$)" => "float" }
convert => { "OUTRAS REMUNERAÇÕES EVENTUAIS (R$)" => "float" }
convert => { "OUTRAS REMUNERAÇÕES EVENTUAIS (U$)" => "float" }
convert => { "IRRF (R$)" => "float" }
convert => { "IRRF (U$)" => "float" }
convert => { "PSS/RPGS (R$)" => "float" }
convert => { "PSS/RPGS (U$)" => "float" }
convert => { "PENSÃO MILITAR (R$)" => "float" }
convert => { "PENSÃO MILITAR (U$)" => "float" }
convert => { "FUNDO DE SAÚDE (R$)" => "float" }
convert => { "FUNDO DE SAÚDE (U$)" => "float" }
convert => { "DEMAIS DEDUÇÕES (R$)" => "float" }
convert => { "DEMAIS DEDUÇÕES (U$)" => "float" }
convert => { "REMUNERAÇÃO APÓS DEDUÇÕES OBRIGATÓRIAS (R$)" => "float" }
convert => { "REMUNERAÇÃO APÓS DEDUÇÕES OBRIGATÓRIAS (U$)" => "float" }
convert => { "VERBAS INDENIZATÓRIAS REGISTRADAS EM SISTEMAS DE PESSOAL - CIVIL (R$)(*)" => "float" }
convert => { "VERBAS INDENIZATÓRIAS REGISTRADAS EM SISTEMAS DE PESSOAL - CIVIL (U$)(*)" => "float" }
convert => { "VERBAS INDENIZATÓRIAS REGISTRADAS EM SISTEMAS DE PESSOAL - MILITAR (R$)(*)" => "float" }
convert => { "VERBAS INDENIZATÓRIAS REGISTRADAS EM SISTEMAS DE PESSOAL - MILITAR (U$)(*)" => "float" }
convert => { "TOTAL DE VERBAS INDENIZATÓRIAS (R$)(*)" => "float" }
convert => { "TOTAL DE VERBAS INDENIZATÓRIAS (U$)(*)" => "float" }
convert => { "TOTAL DE HONORÁRIOS (JETONS)" => "float" }
}
date {
match => [ "timestamp", "dd/MM/YYYY HH:mm:ss", "ISO8601" ]
target => [ "@timestamp" ]
}
}
output {
elasticsearch {
action => "index"
user => "%(user)s"
password => "%(password)s"
hosts => "http://node1.c3sl.ufpr.br:9200"
index => "ufpr-servidores-%(date)s"
workers => 1
}
stdout {}
}
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <user:password> <old-index> <new-index>"
echo "Example: $0 myuser:mypass ufpr-csv-2016-11 ufpr-servidores-2016-11"
exit
fi
# Copy old index to new index...
curl -u $1 -XPOST 'http://node1.c3sl.ufpr.br:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'
{
"source": {
"index": "'$2'"
},
"dest": {
"index": "'$3'"
}
}
'
# Delete old index...
curl -u $1 -XDELETE "http://node1.c3sl.ufpr.br:9200/$2?pretty"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment