UserParameter=ddmm,echo "[{\"{#DDMM}\":\"$(date +%d%m)\"}]"
UserParameter=yymmdd,echo "[{\"{#DDMM}\":\"$(date +%Y%m%d)\"}]"
UserParameter=arquivo_carga_atualizado,if [ $(cat /posnet/download/tabelas | cut -c -6) == $(date +%y%m%d) ] ; then echo 1; else  echo 0; fi
UserParameter=horario_pdv,date +%d/%m/%Y\ %H:%M:%S
UserParameter=versao_htcconfig,/harpo/bin/htc_config --version
UserParameter=valor_arquivo_de_cargas,cat /posnet/download/tabelas
UserParameter=sistema_operacional_curto, if [ -e /etc/debian_version ] ; then SO="Ubuntu $(lsb_release -a 2>/dev/null | grep Release | awk {'print $2'})"; else SO="Slackware $(cat /etc/slackware-version | awk {'print $2'})"; fi; ARCH=$(uname -m); echo "$SO ($ARCH)"

UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" -u"$3" -p"$4" ping 2>/dev/null
UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -u"$3" -p"$4" -sNX -e "show global status" 2>/dev/null
UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" -u"$3" -p"$4" version 2>/dev/null
UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -u"$3" -p"$4" -sN -e "show databases" 2>/dev/null
UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -u"$3" -p"$4" -sN -e "SELECT COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$5'" 2>/dev/null
UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -u"$3" -p"$4" -sNX -e "show slave status" 2>/dev/null
UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -u"$3" -p"$4" -sNX -e "show slave status" 2>/dev/null


#UserParameter=pdv.operador_id, ls /posnet/OPER_*.pdv 2>/dev/null | cut -d'_' -f2 | cut -d'.' -f1
UserParameter=pdv.operador_id, find /posnet/ -name 'OPER_*.pdv' -mmin -$((24*60)) ! -name 'OPER_001000.pdv' 2>/dev/null | cut -d'_' -f2 | cut -d'.' -f1
UserParameter=pdv.operadores_ids, echo "[{\"{#OPERADOR_ID}\":\"$(grep "ServicoVenda: JSON de retorno" /posnet/logpdv$(date +%d%m).txt | grep employeeId | cut -d'=' -f2- | sed "s/,/\n/g"| grep employeeId | cut -d':' -f2 | cut -d'"' -f2| sort | uniq)\"}]"
UserParameter=pdv.operador_json[*], grep "ServicoVenda: JSON de retorno" /posnet/logpdv$(date +%d%m).txt | grep "D2 - 14:05" | cut -d"'" -f2 | grep "\"employeeId\":\"$1\""
UserParameter=pdv.sat_ip, grep -i "Resposta com Sucesso" /posnet/logsat$(date +%d%m).txt | awk -F'IPFIX\\|' '{split($2, a, "|"); split(a[1], b, "."); printf "%d.%d.%d.%d\n", b[1], b[2], b[3], b[4]}' | tail -n 1
UserParameter=pdv.sat_ip_ping, IP=$(grep -i "Resposta com Sucesso" $(ls -t /posnet/logsat*.txt | head -n 1) | awk -F'IPFIX\\|' '{split($2, a, "|"); split(a[1], b, "."); printf "%d.%d.%d.%d\n", b[1], b[2], b[3], b[4]}' | tail -n 1); if [ -z "$IP" ]; then echo ""; else ping -c1 $IP > /dev/null 2>&1 && echo "1" || echo "0"; fi
UserParameter=pdv.sat.monitorasat[*],/ariusmonitor/MonitoraSAT.sh --fabricante $1 --codigo $2 --lib $3

UserParameter=pdv.concentrador_ip, grep "PDV_SERVER_LOJA" /posnet/pdv.conf | awk {'print $3'}
UserParameter=pdv.concentrador_ip_ping, IP=$(grep "PDV_SERVER_LOJA" /posnet/pdv.conf | awk {'print $3'}) && ping -c1 $IP > /dev/null 2>&1 && echo "1" || echo "0"

## PAGUEMENOS
UserParameter=pdv.paguemenos_telnet_clube, (timeout 5 bash -c 'echo > /dev/tcp/172.18.1.27/30000' && echo 1) 2> /dev/null || echo 0
UserParameter=concentrador.paguemenos_telnet_clube, (timeout 5 bash -c 'echo > /dev/tcp/172.18.1.27/30000' && echo 1) 2> /dev/null || echo 0

## MLAR
UserParameter=pdv.comparar_operador,/ariusmonitor/comparar_operador.sh

# Exemplo de json no item:
# echo "[{\"{#SAT_IP}\":\"$(<COMANDO_SHELL>)\"}]"

# Exemplo de fping no PDV
# UserParameter=pdv.concentrador_ip_ping, IP=$(<COMANDO_SHELL>) && /ariusmonitor/utilities/bin/fping -q $IP && echo 1 || echo 0


# Teste config Sitef
# UserParameter=sitef.check_config[*], if [ "$(sed -nr "/^\[SiTef\]/ { :l /^EnderecoIP[ ]*=/ { s/[^=]*=[ ]*//; p; q;}; n; b l;}" /posnet/CliSiTef.ini)" == "$1" -o "$(sed -nr "/^\[SiTef\]/ { :l /^HabilitaMultiplasConexoesSitefUnico[ ]*=/ { s/[^=]*=[ ]*//; p; q;}; n; b l;}" /posnet/CliSiTef.ini)" == "$2" ] ; then echo 1; else echo 0; fi


UserParameter=pdv.clisitef.enderecoip,cat /posnet/CliSiTef.ini | grep "EnderecoIP=" | cut -d'=' -f2
UserParameter=pdv.clisitef.habilitamultiplasconexoessitefunico,cat /posnet/CliSiTef.ini | grep "HabilitaMultiplasConexoesSitefUnico=" | cut -d'=' -f2
UserParameter=pdv.clisitef.diretoriobase,if grep -q "^\[SalvaEstado\]" /posnet/CliSiTef.ini && grep -q "^DiretorioBase=/posnet/" /posnet/CliSiTef.ini; then echo 1; else echo 0; fi

UserParameter=pgsql.bgwriter[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.bgwriter.sql"

UserParameter=pgsql.connections.sum[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.connections.sum.sql"

UserParameter=pgsql.dbstat[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.dbstat.sql"

# POSTGRES
UserParameter=pgsql.transactions[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.transactions.sql"
UserParameter=pgsql.config.hash[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.config.hash.sql"
UserParameter=pgsql.wal.stat[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.wal.stat.sql"
UserParameter=pgsql.locks[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.locks.sql"
UserParameter=pgsql.queries[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -v tmax=$6 -f "/ariusmonitor/postgresql/pgsql.query.time.sql"
UserParameter=pgsql.uptime[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.uptime.sql"
UserParameter=pgsql.cache.hit[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.cache.hit.sql"
UserParameter=pgsql.scans[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.scans.sql"
UserParameter=pgsql.frozenxid[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.frozenxid.sql"

UserParameter=pgsql.discovery.db[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.discovery.db.sql"
UserParameter=pgsql.db.size[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -c "SELECT pg_database_size('$6')"
UserParameter=pgsql.ping[*], pg_isready -h "$1" -p "$2"
UserParameter=pgsql.ping.time[*], LC_ALL=C.UTF-8 psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.ping.time.sql"
UserParameter=pgsql.version[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -c "SELECT version();"

UserParameter=pgsql.replication.count[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -c "SELECT count(*) FROM pg_stat_replication"
UserParameter=pgsql.replication.recovery_role[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.replication.recovery_role.sql"
UserParameter=pgsql.replication.lag.sec[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.replication.lag.sql"
UserParameter=pgsql.replication.status[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/ariusmonitor/postgresql/pgsql.replication.status.sql"