Last active
September 18, 2016 01:15
-
-
Save onesuper/20e8e9d2c113bb28f1ceacb97cc90ce1 to your computer and use it in GitHub Desktop.
yg-env.sh
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
#!/usr/bin/env sh | |
# | |
# $ echo 'source path_to_env.sh' >> ~/.bashrc | |
# $ yg_install | |
KAFKA_HOST=bj2-storm03:9092 | |
ES_HOST=bj2-storm03:9200 | |
ZK_HOST=bj2-storm03:2181,bj2-storm04:2181,bj2-storm05:2181 | |
STORM_LOG_HOME='/usr/local/storm-default/logs/' | |
TODAY=$(date '+%Y-%m-%d') | |
yg_install() { | |
pip install pygments | |
pip3 install yaoguang-python-client==0.0.9 | |
} | |
# send_mail "chengyichao,kefei,dingguitao" "subject" "content" | |
send_mail() { | |
python -c "tos='${1}'.split(',');toss=', '.join(map(lambda x:x+'@baixing.com', tos));import smtplib; smtplib.SMTP('118.194.51.51').sendmail('[email protected]', tos, 'Subject: $2\r\nTo: '+toss+'\r\n\r\n'+'''$3''')" | |
echo 'sendmail OK' | |
} | |
unix_time() { | |
python -c "import datetime; print datetime.datetime.fromtimestamp(int('$1')).strftime('%Y-%m-%d %H:%M:%S')" | |
} | |
json_indent() { | |
python -c "import json; import sys; s = sys.stdin.readline(); print json.dumps(json.loads(s), sort_keys=True, indent=4, separators=(',', ': '), ensure_ascii=False)" | |
} | |
json_pretty() { | |
python -c "import json; import sys; s = sys.stdin.readline(); s = json.dumps(json.loads(s), sort_keys=True, indent=4, separators=(',', ': '), ensure_ascii=False);from pygments import highlight, lexers, formatters; print highlight(s, lexers.JsonLexer(), formatters.TerminalFormatter())," | |
} | |
json_color() { | |
python -c "from pygments import highlight, lexers, formatters; import sys; s = ''.join(sys.stdin.readlines()); print highlight(s, lexers.JsonLexer(), formatters.TerminalFormatter())," | |
} | |
yg_lead() { | |
python3 -c "from yaoguang import Leads; print(repr(Leads('bj2-storm03').get_v2('$1')))" | |
} | |
yg_contact() { | |
python3 -c "from yaoguang import Entities, Entity; import sys; e=Entities('bj2-storm03'); [print(repr(Entity(e.get_contact(l.strip())))) for l in sys.stdin] " | |
} | |
yg_company() { | |
python3 -c "from yaoguang import Entities, Entity; import sys; e=Entities('bj2-storm03'); [print(repr(Entity(e.get_company(l.strip())))) for l in sys.stdin]" | |
} | |
yg_ad() { | |
python3 -c "from yaoguang import Entities, Entity; import sys; Entities('bj2-storm03'); [print(repr(Entity(e.get_ad(l.strip())))) for l in sys.stdin]" | |
} | |
topic_ls() { | |
kafka-topics.sh --list --zookeeper ${ZK_HOST} | |
} | |
topic_pipe() { | |
yg_kafka_read $1 | tee /dev/stderr | yg_kafka_write $1 | |
} | |
topic_write() { | |
kafka-console-producer.sh --broker-list ${KAFKA_HOST} --topic $1 | |
} | |
topic_read() { | |
kafka-console-consumer.sh --zookeeper ${ZK_HOST} --topic $1 | |
} | |
topic_top() { | |
kafka-console-consumer.sh --zookeeper ${ZK_HOST} --topic $1 --max-messages 10 | |
} | |
offset_read() { | |
kafka-topicsafka-consumer-offset-checker.sh --zookeeper ${ZK_HOST} --group $1 | |
} | |
storm_log_ls() { | |
echo ${STORM_LOG_HOME} | |
echo 'bj2-storm04' | |
ssh deploy@bj2-storm04 "ls -tlr ${STORM_LOG_HOME}" | |
echo 'bj2-storm05' | |
ssh deploy@bj2-storm05 "ls -tlr ${STORM_LOG_HOME}" | |
} | |
storm_log_tail() { | |
echo ${STORM_LOG_HOME} | |
echo 'bj2-storm04' | |
ssh deploy@bj2-storm04 "tail ${STORM_LOG_HOME}/*.log" | |
echo 'bj2-storm05' | |
ssh deploy@bj2-storm05 "tail ${STORM_LOG_HOME}/*.log" | |
} | |
es_shards() { | |
curl "${ES_HOST}/_cat/shards" | |
} | |
# es_match 'index' 'field' 'xxxxx' | |
es_all() { | |
curl "${ES_HOST}/$1/_search?pretty=true&q=*:*&size=100" 2>/dev/null | less | |
} | |
# es_match 'index' 'field' 'xxxxx' | |
es_match() { | |
curl -XPOST "${ES_HOST}/$1/_search" -d "{ \"query\" : { \"match\" : { \"$2\" : \"$3\" }}}" 2>/dev/null | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment