我在puppetdb中存储来自节点的报告。 我想通过以下查询来检查从特定节点收到报告的时间:
curl -sk http://pdb:8080/v3/reports --data-urlencode 'query=["=", "certname", "host.mydomain.com"]' | grep "receive-time"
我得到以下输出:
"receive-time" : "2015-12-05T11:57:13.882Z", "receive-time" : "2015-12-05T11:46:26.826Z", "receive-time" : "2015-12-05T11:17:15.702Z", "receive-time" : "2015-12-05T13:13:56.060Z",
所以我可以得出结论,我有4个报告从09:32:15到11:32:13。 这是错误的(抵消2小时)
另一方面当我查询postgresdb后端直接通过
select certname,puppet_version,start_time, status_id from reports where certname = 'host.mydomain.com' order by start_time desc; i get different times: host.mydomain.com | 3.8.1 | 2015-12-05 13:57:07.079+02 | 2 host.mydomain.com | 3.8.1 | 2015-12-05 13:46:19.658+02 | 2 host.mydomain.com | 3.8.1 | 2015-12-05 13:17:07.056+02 | 2 host.mydomain.dom | 3.8.1 | 2015-12-05 13:13:56.608+02 | 2
这是报告的正确时间。 所有puppetdb运行的服务器时区设置都是正确的。 postgresdb的所有设置都设置为相同的时区。
我怎样才能通过curl查询正确的时间请查询?
2015-12-05T11:32:13.718Z等时间戳之后的首都Z代表祖鲁时间UTC。
其他时间戳2015-12-05 13:57:07.079+02与+ 2是时间更正为您的本地时区,提前两个小时UTC。
因此,它们在绝对意义上都是正确的,但是您需要在UTC中添加两个小时以匹配您的手表。