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

dingding use server timezone #2910

Closed
2 tasks done
Lihy6472 opened this issue Mar 9, 2023 · 12 comments
Closed
2 tasks done

dingding use server timezone #2910

Lihy6472 opened this issue Mar 9, 2023 · 12 comments
Labels
area:notifications Everything related to notifications feature-request Request for new features to be added

Comments

@Lihy6472
Copy link

Lihy6472 commented Mar 9, 2023

⚠️ Please verify that this bug has NOT been raised before.

  • I checked and didn't find similar issue

🛡️ Security Policy

Description

  • Use the docker command "docker run -d --restart=always -p 3001:3001 -v /opt/uptime-kuma:/app/data -v /etc/localtime:/etc/localtime --name uptime-kuma louislam/uptime-kuma:1" Start container。

image

👟 Reproduction steps

  • Set the time zone of the web page to Asis/Shanghai

image

  • The new notification channel is pending and passed the test

image

  • Add monitoring items and apply notification channels

image

  • Test the notification channel and find that the trigger time is incorrect

image

👀 Expected behavior

  • dingding The notification time should be consistent with the time zone set by the system

😓 Actual Behavior

  • The time zone set by the system is Asia/Shanghai (CST), and the time zone for notification is UTC

image
image
image

🐻 Uptime-Kuma Version

1

💻 Operating System and Arch

Linux version 5.11.0-25-generic (buildd@lgw01-amd64-044) (gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0, GNU ld (GNU Binutils for Ubuntu) 2.36.1) #27-Ubuntu SMP Fri Jul 9 23:06:29 UTC 2021

🌐 Browser

chrom 110.0.5481.178

🐋 Docker Version

19.03.9

🟩 NodeJS Version

No response

📝 Relevant log output

2023-03-09T13:45:48+08:00 [MONITOR] INFO: Get Monitor: 7 User ID: 1
2023-03-09T13:45:53+08:00 [MANAGE] INFO: Resume Monitor: 7 User ID: 1
2023-03-09T13:45:53+08:00 [MONITOR] INFO: Get Monitor: 7 User ID: 1
2023-03-09T13:46:06+08:00 [MANAGE] INFO: Resume Monitor: 7 User ID: 1
2023-03-09T13:46:06+08:00 [MONITOR] INFO: Get Monitor: 7 User ID: 1
2023-03-09T13:46:06+08:00 [MONITOR] WARN: Monitor #7 '广州域及内网nginx拨测': Failing: Request failed with status code 404 | Interval: 60 seconds | Type: http | Down Count: 0 | Resend Interval: 0
2023-03-09T13:46:12+08:00 [MANAGE] INFO: Resume Monitor: 7 User ID: 1
2023-03-09T13:46:13+08:00 [MONITOR] INFO: Get Monitor: 7 User ID: 1
2023-03-09T13:46:41+08:00 [MONITOR] WARN: Monitor #7 '广州域及内网nginx拨测': Failing: timeout of 48000ms exceeded | Interval: 60 seconds | Type: http | Down Count: 0 | Resend Interval: 0
2023-03-09T13:46:41+08:00 [MONITOR] INFO: [广州域及内网nginx拨测] isStop = true, no next check.
2023-03-09T13:55:49+08:00 [MONITOR] INFO: Get Monitor: 7 User ID: 1
2023-03-09T13:56:14+08:00 [MANAGE] INFO: Resume Monitor: 7 User ID: 1
2023-03-09T13:56:14+08:00 [MONITOR] WARN: Monitor #7 '广州域及内网nginx拨测': Failing: Request failed with status code 404 | Interval: 60 seconds | Type: http | Down Count: 0 | Resend Interval: 0
2023-03-09T13:56:15+08:00 [MONITOR] INFO: Get Monitor: 7 User ID: 1
2023-03-09T13:56:28+08:00 [MANAGE] INFO: Resume Monitor: 7 User ID: 1
2023-03-09T13:56:28+08:00 [MONITOR] INFO: Get Monitor: 7 User ID: 1
@Lihy6472 Lihy6472 added the bug Something isn't working label Mar 9, 2023
@louislam louislam changed the title dingding notice dingding use server timezone Mar 9, 2023
@louislam louislam added feature-request Request for new features to be added and removed bug Something isn't working labels Mar 9, 2023
@su-haris
Copy link

Looking forward to this one!

@jiujiude
Copy link

#文件一
server\routers\api-router.js 63行
bean.time = R.isoDateTimeMillis(dayjs.utc().tz());

#文件二
server\model\monitor.js 241行
bean.time = R.isoDateTimeMillis(dayjs.utc().tz());

@Lihy6472
Copy link
Author

Lihy6472 commented Apr 10, 2023

#文件一 server\routers\api-router.js 63行 bean.time = R.isoDateTimeMillis(dayjs.utc().tz());

#文件二 server\model\monitor.js 241行 bean.time = R.isoDateTimeMillis(dayjs.utc().tz());

  • docker部署的修改完文件后重启即可,钉钉报警通知时区已经为北京时间。非常感谢

@jiujiude
Copy link

@Lihy6472 有点小问题,请先撤回,待我修改好后再发

@jiujiude
Copy link

@Lihy6472
请进行如下修改,讲在通知的时候自动识别获取服务器时间:

\server\notification.js 第1行
// import dayjs from "dayjs";
const dayjs = require("dayjs");

\server\notification.js 第143行
//转换当前服务器时间 By hgq 393210556@qq.com 2023/04/10 12:39
if (heartbeatJSON != null) {
heartbeatJSON['time'] = dayjs.utc(heartbeatJSON['time']).tz().format("YYYY-MM-DD HH:mm:ss.SSS");
}

@Lihy6472
Copy link
Author

Lihy6472 commented Apr 10, 2023

@Lihy6472 请进行如下修改,在告知的时候自动识别别取服务器时间:

\server\notification.js 第1行 //从“dayjs”导入dayjs; const dayjs = require("dayjs");

\server\notification.js 第143行 //转换当前服务器时间 By hgq 393210556@qq.com 2023/04/10 12:39 if (heartbeatJSON != null) { heartbeatJSON['time'] = dayjs.utc(heartbeatJSON ['时间']).tz().format("YYYY-MM-DD HH:mm:ss.SSS"); }

  • 修改的这个需要还原吗?

image

  • 是这么修改吗?

image

@Lihy6472 Lihy6472 reopened this Apr 10, 2023
@jiujiude
Copy link

@Lihy6472 第一次的还原,使用第二次的修改即可

@jiujiude
Copy link

@Lihy6472 位置不对,看截图
image

@Lihy6472
Copy link
Author

@Lihy6472位置不对,看截图 图像

  • 好的,修改完成了,现在使用第二方案已经可以获取到时间。下个版本是否会自带这个配置呢?

@jiujiude
Copy link

@Lihy6472 这个就不知道了,我只是一名使用者

@louislam
Copy link
Owner

不建議這樣改源碼,因為那個Heartbeat Time 是需要儲存 UTC 時區的,這樣改會造成其他錯亂。

9e320dc
昨天我加了 heartbeatJSON["localDateTime"]

我估計只需要改 server/notification-providers/dingding.js 就可以了。如果可行的話亦歡迎貢獻 Pull Request。

@Lihy6472
Copy link
Author

@Lihy6472 这个就不知道了,我只是一名使用者

好的,感谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:notifications Everything related to notifications feature-request Request for new features to be added
Projects
None yet
Development

No branches or pull requests

5 participants