Timzone of Foreman-Logs / in MySQL Database Foreman

Hello!

I am searching for a solution to change the timezone of the Foreman-Logs in
the MySQL Database.
The Timezone of MySQL is the right one (UTC +2 / CEST), but I'm not sure if
the problem is in foreman or in puppet or both. The Date/Time entry of the
logs is timezone UTC.

Does anyone has a solution to change the timezone of these reports/logs to
UTC +2 / CEST?

Thank You!
Hoize

> Hello!
>
> I am searching for a solution to change the timezone of the Foreman-Logs in
> the MySQL Database.
> The Timezone of MySQL is the right one (UTC +2 / CEST), but I'm not sure if
> the problem is in foreman or in puppet or both. The Date/Time entry of the
> logs is timezone UTC.

Foreman handles everything in UTC, but on 1.8 every user has a setting
'Timezone' under 'My account' to display dates on the UI/API according
to their timezone. This allows users from different timezones to use the
same foreman database and see the data in their timezone.

What is your use case? If you just want the dates to be in CEST in the
UI, I'd recommend you to upgrade to 1.8 and change the users' timezone
to that.

··· On 05/06, hoize wrote: > > Does anyone has a solution to change the timezone of these reports/logs to > UTC +2 / CEST? > > Thank You! > Hoize > > -- > You received this message because you are subscribed to the Google Groups "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout.


Daniel Lobato Garcia

@eLobatoss
blog.daniellobato.me
daniellobato.me

GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30
Keybase: https://keybase.io/elobato

Thank You!

I want to send the logs/reports to our syslog-system with nxlog.
Additionally I want to grab Error-States like out of sync, error and
disabled from the database to monitor puppetruns with zabbix. And therefore
I need to have the right timezone.

··· Am Donnerstag, 7. Mai 2015 09:39:20 UTC+2 schrieb Daniel Lobato: > > On 05/06, hoize wrote: > > Hello! > > > > I am searching for a solution to change the timezone of the Foreman-Logs > in > > the MySQL Database. > > The Timezone of MySQL is the right one (UTC +2 / CEST), but I'm not sure > if > > the problem is in foreman or in puppet or both. The Date/Time entry of > the > > logs is timezone UTC. > > Foreman handles everything in UTC, but on 1.8 every user has a setting > 'Timezone' under 'My account' to display dates on the UI/API according > to their timezone. This allows users from different timezones to use the > same foreman database and see the data in their timezone. > > What is your use case? If you just want the dates to be in CEST in the > UI, I'd recommend you to upgrade to 1.8 and change the users' timezone > to that. > > > > Does anyone has a solution to change the timezone of these reports/logs > to > > UTC +2 / CEST? > > > > Thank You! > > Hoize > > > > -- > > You received this message because you are subscribed to the Google > Groups "Foreman users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to foreman-user...@googlegroups.com . > > To post to this group, send email to forema...@googlegroups.com > . > > Visit this group at http://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > > > -- > Daniel Lobato Garcia > > @eLobatoss > blog.daniellobato.me > daniellobato.me > > GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30 > Keybase: https://keybase.io/elobato >

I have now a solution for this Problem. I worked with the Date from UTC.
Here is the Solution:

date=$(date -u -d "5minutes ago" "+%Y-%m-%d %H:%M:%S") # -u means UTC
and 5minutes ago takes the actual time minus 5 minutes
date=$(echo "$datum")
# the variable date is now in the format of < "YYYY-MM-DD HH:MM:SS" >

mysql -u$dbuser -p$dbpass $db --skip-column-names -s -B -e "select
CONCAT('ID: ', l.id, ' time |!|!;$| ', l.created_at, ' client |!|!;$|
', h.name , ' ip |!|!;$| ', h.ip , ' level |!|!;$| ', b.name, ' source
>!|!;$| ', s.value, ' message |!|!;$| ', m.value) from logs l, sources
s, messages m, reports r, hosts h, bookmarks b where l.source_id=s.id and
l.message_id=m.id and l.report_id=r.id and r.host_id=h.id and
l.level_id=b.id and l.created_at > ${datum} ORDER BY l.created_at ASC" >>
/var/log/puppet/puppet.log

this Select takes the rows and has some cross joins, but the clue is

l.level_id=b.id and l.created_at > ${datum}: it takes only the last 5
minutes of the table an writes it in /var/log/puppet.log

··· Am Donnerstag, 7. Mai 2015 09:47:22 UTC+2 schrieb hoize: > > Thank You! > > I want to send the logs/reports to our syslog-system with nxlog. > Additionally I want to grab Error-States like out of sync, error and > disabled from the database to monitor puppetruns with zabbix. And therefore > I need to have the right timezone. > > Am Donnerstag, 7. Mai 2015 09:39:20 UTC+2 schrieb Daniel Lobato: >> >> On 05/06, hoize wrote: >> > Hello! >> > >> > I am searching for a solution to change the timezone of the >> Foreman-Logs in >> > the MySQL Database. >> > The Timezone of MySQL is the right one (UTC +2 / CEST), but I'm not >> sure if >> > the problem is in foreman or in puppet or both. The Date/Time entry of >> the >> > logs is timezone UTC. >> >> Foreman handles everything in UTC, but on 1.8 every user has a setting >> 'Timezone' under 'My account' to display dates on the UI/API according >> to their timezone. This allows users from different timezones to use the >> same foreman database and see the data in their timezone. >> >> What is your use case? If you just want the dates to be in CEST in the >> UI, I'd recommend you to upgrade to 1.8 and change the users' timezone >> to that. >> > >> > Does anyone has a solution to change the timezone of these reports/logs >> to >> > UTC +2 / CEST? >> > >> > Thank You! >> > Hoize >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "Foreman users" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an email to foreman-user...@googlegroups.com. >> > To post to this group, send email to forema...@googlegroups.com. >> > Visit this group at http://groups.google.com/group/foreman-users. >> > For more options, visit https://groups.google.com/d/optout. >> >> >> -- >> Daniel Lobato Garcia >> >> @eLobatoss >> blog.daniellobato.me >> daniellobato.me >> >> GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30 >> Keybase: https://keybase.io/elobato >> >