qmexnetworks / cmk-pusher-agent

Push Agent for Check_MK
6 stars 2 forks source link

CMK Pusher send wrong time #1

Closed Luca65ZZ closed 6 years ago

Luca65ZZ commented 6 years ago

Hi, I'm starting to use cmk pusher on four test windows 7 and 10 machines and on all of them I have the same problem: inside the file cmk pusher send to nagios server, the hour is wrong. There is a difference of 2 hours between the real time and the time inside the "machine status" file. For example: on a machine with time 9.00 AM with right time get from NTP, the time inside the file sent by cmk pusher is 7.00 AM. Please, take note the server have right time sync with NTP, the same as Windows client machine. Please, may you help me to correct this issue? Thanks in advance LUCA (Italy)

qmex-mp commented 6 years ago

Hi, iam happy to correct this as soon I can understand it. Are there different Time Zones on Server and Client?

Luca65ZZ commented 6 years ago

Hi, many thanks for reply. There arent differences between server and client, are both in the same Time Zone. When the client put info on server, I can see, inside the "dump" file on server, a wrong time, with a delay of two hours. I set on client and server the same NTP server to be sure to have the same date and time and this setting is working fine. I really dont understand why the time is right on both but inside the "dump" file on server I get two hour less. Thanks for your help LUCA

Luca65ZZ commented 6 years ago

There is an additional problem regarding date and time: today, 19 october 2018, I can see on host monitored through cmkpusher this check: datetimeerror It seems there is an issue calculating right time and date. Please, do you have a solution for this? Thanks LUCA

Luca65ZZ commented 6 years ago

Hi qmex-mp, please may you check for this problem? If not, no problems, I can join a different solution ;-) many thanks LUCA

Luca65ZZ commented 6 years ago

The problem should be in the file json.php in the line "$content .= "last_connect ".date("Y-m-d H:i:s")."\n";" I suppose here the software get UTC time instead of real time based on current Time Zone. Another problem should be the "-" as date separator (see my post of 10 days ago where Check_MK gives me only 322 seconds but the real time is 9 days before! (October 10 instead of October 19!) What can I do to solve this problem and get the right time on my Check_MK server? thanks LUCA

Luca65ZZ commented 6 years ago

Good news! Problem partially solved: I add the following line to json.php: "date_default_timezone_set('Europe/Rome');" With this line the system gets the right date and time and write it inside the "dump" file. I still need to solve the calc of date ... it's still wrong.

qmex-mp commented 6 years ago

Hi, this explains why i couldnt replicate the issue. Its not necessary to set the timezone in the PHP File, you should set the correct timezone in your php.ini thats the best solution.

As for the other thing: I will rewrite the whole time calculation code in the check_mk check new, this week.

qmex-mp commented 6 years ago

Can you do me a favor an get me the result of "date" on your check_mk servers CLI?

Luca65ZZ commented 6 years ago

Many thanks! ;-)

I put “date” command in the ssh console of check_mk server and the result is:

Wed Oct 31 17:34:33 CET 2018

Bye

LUCA

Da: qmex-mp notifications@github.com Inviato: lunedì 29 ottobre 2018 18:33 A: qmexnetworks/cmk-pusher-agent cmk-pusher-agent@noreply.github.com Cc: Luca65ZZ luca.lazzaroni@gmail.com; Author author@noreply.github.com Oggetto: Re: [qmexnetworks/cmk-pusher-agent] CMK Pusher send wrong time (#1)

Hi, this explains why i couldnt replicate the issue. Its not necessary to set the timezone in the PHP File, you should set the correct timezone in your php.ini thats the best solution.

As for the other thing: I will rewrite the whole time calculation code in the check_mk check new, this week.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/qmexnetworks/cmk-pusher-agent/issues/1#issuecomment-434002579 , or mute the thread https://github.com/notifications/unsubscribe-auth/AgMQjEevx6uIl_dGsVspP-3SIPMrtBZ-ks5upzvAgaJpZM4XW8rY . https://github.com/notifications/beacon/AgMQjHSbGki54uh1PK7gIbtbC_mfHd5eks5upzvAgaJpZM4XW8rY.gif

qmex-mp commented 6 years ago

Hi, thanks for the data (this was only to confirm correct timezone configuration. Its now fixed and you only have to exchange the check_mk check for the new one.

Luca65ZZ commented 6 years ago

Many thanks again! ;-) It seems all is working fine now :-) Ciao! LUCA