Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

客户端到服务器的网络不稳定时,大量重复错误日志 #47

Open
void285 opened this issue Dec 7, 2019 · 1 comment
Open

Comments

@void285
Copy link

void285 commented Dec 7, 2019

观察到两台位于大陆地区的客户端无法稳定地向海外服务器报送数据,日志文件中有大量错误记录行。

基本都是以下两类:

 334807行
ERROR] send stat failed, Post https://1.2.3.4:15944/api/stat: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

  67706行
ERROR] send stat failed, Post https://1.2.3.4:15944/api/stat: dial tcp 1.2.3.4:15944: connect: connection refused

因为我有一段时间没关注软件的运行情况,没及时发现并排查解决问题,所以日志增长很快。也许其他用户也可能有网络不稳定的问题,软件是否可考虑降低网络不稳定情况下的重试频率,或合并错误日志行并定时清除?

以下为错误日志的排查详情:

ubuntu@client:/usr/local/stathub$ ll -h log/
total 72M
drwxr-xr-x 2 nobody nogroup 4.0K Sep  6 11:58 ./
drwxr-xr-x 4 nobody nogroup 4.0K Sep  5 16:50 ../
-rw-r--r-- 1 nobody nogroup  72M Dec  7 20:56 stathub.log
-rw-r--r-- 1 root   root       6 Sep  6 11:58 stathub.pid

ubuntu@client:/usr/local/stathub$ awk '{print $1}' log/stathub.log | sort | uniq -c
   1283 2019-09-05
   4318 2019-09-06
   4320 2019-09-07
   4320 2019-09-08
   4320 2019-09-09
   4320 2019-09-10
   4320 2019-09-11
   4320 2019-09-12
   4320 2019-09-13
   4320 2019-09-14
   4320 2019-09-15
   4320 2019-09-16
   4320 2019-09-17
   4320 2019-09-18
   4320 2019-09-19
   4320 2019-09-20
   4320 2019-09-21
   4320 2019-09-22
   4320 2019-09-23
   4320 2019-09-24
   4320 2019-09-25
   4320 2019-09-26
   4320 2019-09-27
   4320 2019-09-28
   4320 2019-09-29
   4320 2019-09-30
   4320 2019-10-01
   4320 2019-10-02
   4320 2019-10-03
   4320 2019-10-04
   4320 2019-10-05
   4320 2019-10-06
   4320 2019-10-07
   4320 2019-10-08
   4320 2019-10-09
   4320 2019-10-10
   4320 2019-10-11
   4320 2019-10-12
   4320 2019-10-13
   4320 2019-10-14
   4320 2019-10-15
   4320 2019-10-16
   4320 2019-10-17
   4320 2019-10-18
   4320 2019-10-19
   4320 2019-10-20
   4320 2019-10-21
   4320 2019-10-22
   4320 2019-10-23
   4320 2019-10-24
   4320 2019-10-25
   4320 2019-10-26
   4320 2019-10-27
   4320 2019-10-28
   4320 2019-10-29
   4320 2019-10-30
   4320 2019-10-31
   4320 2019-11-01
   4320 2019-11-02
   4320 2019-11-03
   4320 2019-11-04
   4320 2019-11-05
   4320 2019-11-06
   4320 2019-11-07
   4320 2019-11-08
   4320 2019-11-09
   4320 2019-11-10
   4320 2019-11-11
   4320 2019-11-12
   4320 2019-11-13
   4320 2019-11-14
   4320 2019-11-15
   4320 2019-11-16
   4320 2019-11-17
   4320 2019-11-18
   4320 2019-11-19
   4322 2019-11-20
   4320 2019-11-21
   4320 2019-11-22
   4320 2019-11-23
   4320 2019-11-24
   4320 2019-11-25
   4320 2019-11-26
   4320 2019-11-27
   4320 2019-11-28
   4320 2019-11-29
   4320 2019-11-30
   4320 2019-12-01
   4320 2019-12-02
   4320 2019-12-03
   4320 2019-12-04
   4320 2019-12-05
   4315 2019-12-06
   3774 2019-12-07

ubuntu@client:/usr/local/stathub$ sudo grep "cancel" log/stathub.log > ~/a.log

ubuntu@client:/usr/local/stathub$ sudo grep "refused" log/stathub.log > ~/b.log

ubuntu@client:/usr/local/stathub$ sudo grep -v "refused" log/stathub.log > ~/c.log

ubuntu@client:/usr/local/stathub$ sudo grep -v "cancel" ~/c.log > ~/d.log

ubuntu@client:/usr/local/stathub$ ll -h ~/*.log
-rw-r--r-- 1 ubuntu ubuntu  63M Dec  7 21:18 /home/ubuntu/a.log
-rw-r--r-- 1 ubuntu ubuntu 9.7M Dec  7 21:18 /home/ubuntu/b.log
-rw-r--r-- 1 ubuntu ubuntu  63M Dec  7 21:19 /home/ubuntu/c.log
-rw-r--r-- 1 ubuntu ubuntu 5.4K Dec  7 21:19 /home/ubuntu/d.log

ubuntu@client:/usr/local/stathub$ rm ~/c.log

ubuntu@client:/usr/local/stathub$ cd

ubuntu@client:~$ awk '{print $1}' a.log | uniq -c
   1281 2019-09-05
   4314 2019-09-06
   4320 2019-09-07
   4320 2019-09-08
   4320 2019-09-09
   4320 2019-09-10
   4320 2019-09-11
   4320 2019-09-12
   4320 2019-09-13
   4320 2019-09-14
   4320 2019-09-15
   4320 2019-09-16
   4320 2019-09-17
   4320 2019-09-18
   4320 2019-09-19
   4320 2019-09-20
   4320 2019-09-21
   4320 2019-09-22
   4320 2019-09-23
   4320 2019-09-24
   4320 2019-09-25
   4320 2019-09-26
   4320 2019-09-27
   4320 2019-09-28
   4320 2019-09-29
   4320 2019-09-30
   4320 2019-10-01
   4320 2019-10-02
   4320 2019-10-03
   4320 2019-10-04
   4320 2019-10-05
   4320 2019-10-06
   4320 2019-10-07
   4311 2019-10-08
   4320 2019-10-09
   4320 2019-10-10
   4320 2019-10-11
   4320 2019-10-12
   4320 2019-10-13
   4320 2019-10-14
   4320 2019-10-15
   4320 2019-10-16
   4320 2019-10-17
   4320 2019-10-18
   4318 2019-10-19
   4320 2019-10-20
   4320 2019-10-21
   4320 2019-10-22
   4320 2019-10-23
   4320 2019-10-24
   4320 2019-10-25
   4320 2019-10-26
   4320 2019-10-27
   4320 2019-10-28
   4320 2019-10-29
   4320 2019-10-30
   4320 2019-10-31
   4320 2019-11-01
   4320 2019-11-02
   4320 2019-11-03
   4320 2019-11-04
   4320 2019-11-05
   4320 2019-11-06
   4320 2019-11-07
   4320 2019-11-08
   4320 2019-11-09
   4318 2019-11-10
   4320 2019-11-11
   4320 2019-11-12
   4320 2019-11-13
   4307 2019-11-14
   4320 2019-11-15
   4317 2019-11-16
   4320 2019-11-17
   4320 2019-11-18
   4320 2019-11-19
   2307 2019-11-20
     23 2019-11-21
      3 2019-11-22
     46 2019-11-23
   1323 2019-11-24
     62 2019-11-25
      8 2019-11-26
      8 2019-11-27
      5 2019-11-28
      1 2019-11-29
      1 2019-11-30
      2 2019-12-01
      7 2019-12-02
     17 2019-12-03
     22 2019-12-04
     52 2019-12-05
   1844 2019-12-06
   3830 2019-12-07

ubuntu@client:~$ awk '{print $1}' b.log | uniq -c
      2 2019-09-06
   2015 2019-11-20
   4297 2019-11-21
   4317 2019-11-22
   4272 2019-11-23
   2997 2019-11-24
   4257 2019-11-25
   4312 2019-11-26
   4312 2019-11-27
   4315 2019-11-28
   4319 2019-11-29
   4319 2019-11-30
   4318 2019-12-01
   4313 2019-12-02
   4299 2019-12-03
   4298 2019-12-04
   4268 2019-12-05
   2471 2019-12-06
      5 2019-12-07

ubuntu@client:~$ sed 's/.*\[//g' a.log | uniq -c
 334807 ERROR] send stat failed, Post https://1.2.3.4:15944/api/stat: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

ubuntu@client:~$ sed 's/.*\[//g' b.log | uniq -c
  67706 ERROR] send stat failed, Post https://1.2.3.4:15944/api/stat: dial tcp 1.2.3.4:15944: connect: connection refused

@likexian
Copy link
Owner

likexian commented Dec 7, 2019

我看看怎么优化下这个,目前100M会滚动日志文件,一共保留3个滚动。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants