check.sh 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/bash
  2. year=
  3. while getopts ":y:m:" opt; do
  4. case $opt in
  5. y)
  6. year=$OPTARG
  7. ;;
  8. m)
  9. month=$OPTARG
  10. ;;
  11. ?)
  12. echo "usage: dumpdata -y=2019 -m=2"
  13. exit 1
  14. ;;
  15. esac
  16. done
  17. if [ ! -n "$year" ]; then
  18. echo "no year paramerter"
  19. exit 1
  20. fi
  21. if [ ! -n "$month" ]; then
  22. start_day="${year}-01-01"
  23. start_ts=$(date -u -d ${start_day} +%s)000
  24. start_month="${year}-01"
  25. next_year=$(expr ${year} + 1)
  26. end_day="${next_year}-01-01"
  27. end_ts=$(date -u -d ${end_day} +%s)000
  28. end_month="${next_year}-01"
  29. else
  30. start_month=$(printf "%02d" ${month})
  31. start_year=${year}
  32. next_month=$(expr ${month} + 1)
  33. if [ $next_month -gt 12 ]; then
  34. end_month="01"
  35. end_year=$(expr ${year} + 1)
  36. else
  37. end_month=$(printf "%02d" ${next_month})
  38. end_year=${year}
  39. fi
  40. start_day="${start_year}-${start_month}-01"
  41. start_time="${start_year}-${start_month}-01 00:00:00"
  42. start_ts=$(date -u -d ${start_day} +%s)000
  43. end_day="${end_year}-${end_month}-01"
  44. end_ts=$(date -u -d ${end_day} +%s)000
  45. end_time="${end_year}-${end_month}-01 00:00:00"
  46. fi
  47. echo "====================== device_daily_stats begin ============================="
  48. echo "use report;" >temp.js
  49. echo 'db.getCollection("device_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
  50. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
  51. rm temp.js
  52. echo "use report_his;" >temp.js
  53. echo 'db.getCollection("device_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
  54. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
  55. rm temp.js
  56. echo -e "====================== device_daily_stats end =============================\n"
  57. echo "====================== group_daily_stats begin ============================="
  58. echo "use report;" >temp.js
  59. echo 'db.getCollection("group_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
  60. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
  61. rm temp.js
  62. echo "use report_his;" >temp.js
  63. echo 'db.getCollection("group_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
  64. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
  65. rm temp.js
  66. echo -e "====================== group_daily_stats end =============================\n"
  67. echo "====================== dealer_daily_stats begin ============================="
  68. echo "use report;" >temp.js
  69. echo 'db.getCollection("dealer_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
  70. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
  71. rm temp.js
  72. echo "use report_his;" >temp.js
  73. echo 'db.getCollection("dealer_daily_stats").find({"$and": [{"date": {"$gte": "'${start_day}'"}}, {"date": {"$lt": "'${end_day}'"}}]}).count()' >>temp.js
  74. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
  75. rm temp.js
  76. echo -e "====================== dealer_daily_stats end =============================\n"
  77. echo "====================== dealer_income_proxies begin ============================="
  78. echo "use report;" >temp.js
  79. echo 'db.getCollection("dealer_income_proxies").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]}).count()' >>temp.js
  80. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
  81. rm temp.js
  82. echo "use report_his;" >temp.js
  83. echo 'db.getCollection("dealer_income_proxies").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]}).count()' >>temp.js
  84. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
  85. rm temp.js
  86. echo -e "====================== dealer_income_proxies end =============================\n"
  87. echo "====================== ConsumeRecord begin ============================="
  88. echo "use washpay;" >temp.js
  89. echo 'db.getCollection("ConsumeRecord").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]},{"_id":1}).count()' >>temp.js
  90. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
  91. rm temp.js
  92. echo "use washpay_his;" >temp.js
  93. echo 'db.getCollection("ConsumeRecord").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]},{"_id":1}).count()' >>temp.js
  94. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
  95. rm temp.js
  96. echo -e "====================== ConsumeRecord end =============================\n"
  97. echo "====================== RechargeRecord begin ============================="
  98. echo "use washpay;" >temp.js
  99. echo 'db.getCollection("RechargeRecord").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]},{"_id":1}).count()' >>temp.js
  100. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.69.131 --port 27228 -u guanli -p 75558195de6ac016bb15c05d07e08024 <temp.js
  101. rm temp.js
  102. echo "use washpay_his;" >temp.js
  103. echo 'db.getCollection("RechargeRecord").find({"$and": [{"dateTimeAdded": {"$gte":new Date('${start_ts}')}}, {"dateTimeAdded": {"$lt": new Date('${end_ts}')}}]},{"_id":1}).count()' >>temp.js
  104. mongo --authenticationMechanism=SCRAM-SHA-1 --authenticationDatabase=admin --host 172.16.145.62 --port 20000 -u guanli -p 67374030857714990597992655453345 <temp.js
  105. rm temp.js
  106. echo -e "====================== RechargeRecord end =============================\n"