Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ntp-client not doing it job [fixed - found workaround]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Fri Aug 28, 2015 5:13 am    Post subject: ntp-client not doing it job [fixed - found workaround] Reply with quote

Code:
Knight roman # /etc/init.d/ntp-client restart
 * Setting clock via the NTP client 'ntpdate' ...                                                                                          [ ok ]
Knight roman # rc-update show
                acpid | boot                                         
            alsasound |      default                                 
               binfmt | boot                                         
             bootmisc | boot                                         
          consolefont | boot                                         
                cupsd |      default                                 
                 dbus | boot                                         
                devfs |                                        sysinit
        device-mapper | boot                                         
              dmcrypt | boot                                         
                dmesg |                                        sysinit
                 fsck | boot                                         
             hostname | boot                                         
              hotplug |      default                                 
              hwclock | boot                                         
              keymaps | boot                                         
            killprocs |                        shutdown               
    kmod-static-nodes |                                        sysinit
                local |      default nonetwork                       
           localmount | boot                                         
             loopback | boot                                         
                  lvm | boot                                         
              modules | boot                                         
             mount-ro |                        shutdown               
                 mtab | boot                                         
               net.lo | boot                                         
             netmount |      default                                 
           ntp-client |      default                                 
               procfs | boot                                         
                 root | boot                                         
            savecache |                        shutdown               
            swapfiles | boot                                         
               sysctl | boot                                         
                sysfs |                                        sysinit
            syslog-ng | boot default                                 
         termencoding | boot                                         
         tmpfiles.dev |                                        sysinit
       tmpfiles.setup | boot                                         
                 udev | boot                                   sysinit
         udev-trigger |                                        sysinit
              urandom | boot


I forgot to plugin the network cable in the morning. So the network cable was connected after I realized my webbrowser does not have any network connection.
The issue is that npt-client got started with runlevel default, see above, but it does not sync really after the network comes up / network ip adress changed.

my router hands out class a adresses in 10.x.x.x range, and the default adress given by dhcp is class c, in 169.x.x.x

I may need to hardcode a rule for the 10. range but thats a dirty approach, because the real trigger is when the network changed.

After issuing ... restart it does it job.

The expected behaviour is to sync my time after a network is available. Therefore I say the shipped config files are really not that well configured.

I will look into that myself later, if htere is some way to force sync after the network was changed.

My hardware sadly has the issue, that for around two years, the time gets an offset and I hardly bothered to find out why, could be the watchdog or whatever. I think its more kernel related. As I do not plan to keep that box for more than 2 years and an easy workaround is ntp-client, i hope the software does its job soon as it should.
The hours only get an offet in random from 1-3 hours and thats not really a fixed offset, more a random offet.


Last edited by Roman_Gruber on Wed Sep 02, 2015 12:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
ianw1974
Guru
Guru


Joined: 18 Oct 2006
Posts: 387
Location: UK and Poland

PostPosted: Fri Aug 28, 2015 5:49 am    Post subject: Reply with quote

Any reason why you don't start your network connection at bootup?

Code:
 gentoo64 ian # rc-update show | grep net
           net.enp0s3 |      default


Code:
gentoo64 ian # ls -lh /etc/init.d/net*
lrwxrwxrwx 1 root root    6 May 28  2014 /etc/init.d/net.enp0s3 -> net.lo
-rwxr-xr-x 1 root root  18K Apr  3 21:00 /etc/init.d/net.lo


Code:
gentoo64 ian # ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+pool.ntp.org   213.199.225.30   3 u   40   64    3    0.283   -0.202   0.251
*pool.ntp.org   87.239.223.35    3 u   31   64    7    0.291   -0.388   0.253


perhaps the reason your network isn't starting when you boot the computer, is the reason why. Mine is working with the above setup. If I was to start ntp without the network and then connect it, I would also experience the same problem as you. As NTP couldn't resolve DNS, nor connect to a server anyway without a network connection.
_________________
Ian Walker

Light travels faster than sound. This is why some people appear bright until you hear them speak.........

Linux Systems Limited | Masternode Monitoring
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Fri Aug 28, 2015 12:04 pm    Post subject: Reply with quote

Thanks for your reply

Code:
Knight roman # ls -lh /etc/init.d/n*
-rwxr-xr-x 1 root root  346 Aug 24 01:57 /etc/init.d/nas
lrwxrwxrwx 1 root root    6 Sep  3  2009 /etc/init.d/net.eth0 -> net.lo
-rwxr-xr-x 1 root root  18K Aug 23 18:25 /etc/init.d/net.lo
-rwxr-xr-x 1 root root 1,2K Aug 24 20:55 /etc/init.d/netmount
-rwxr-xr-x 1 root root  787 Jan 11  2015 /etc/init.d/ntop
-rwxr-xr-x 1 root root  827 Jul  6 22:04 /etc/init.d/ntp-client
-rwxr-xr-x 1 root root  593 Jul  6 22:04 /etc/init.d/ntpd
-rwxr-xr-x 1 root root  715 Aug 24 20:55 /etc/init.d/numlock
-rwxr-xr-x 1 root root  656 Aug 23 00:32 /etc/init.d/nvidia-persistenced
-rwxr-xr-x 1 root root  551 Aug 23 00:32 /etc/init.d/nvidia-smi


Code:
Knight roman # rc-update|grep net.lo
               net.lo | boot   


In my point of view I haven net.lo at the runlevel boot. That seems to be the earliest point available.


net.lo seems to be a softlink to the weird interface, ethernet, 1gbit, eth0.

Something is mayor broken.
Even now as the ethernet cable was connected and the modem was active still the date was incorrect. after i started ntp-client my date and hour was instantly corrected.

edit:
Quote:
noquery is important to prevent dumping status data from ntpd (also with ntpq or ntpdc).

Therefore the next behaviour that ntpq refuses an output is correct ...

Well You showed me a difference as superuser and ordinary user:
Code:
Knight roman # ntpq -p
ntpq: read: Connection refusedKnight roman # exit
roman@Knight ~ $ ntpq -p
ntpq: read: Connection refusedroman@Knight ~ $


Seems something is misconfigured or has wrong permission. Most annoyingly even user root gets a connection refused.

The only difference is that you use the new network names and i boot up the kernel with ifnames=0 or so to get the old behaviour.
nevertheless you get an output from ntpq -p and I do not get anything.

But my time is corrected with restart or start with /etc/init.d/ntpclient ...

Do you mind comparing mine with yours and tell me if you got different useflags for this package, thank you:
Quote:
emerge -av ntp

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild R ] net-misc/ntp-4.2.8_p3::gentoo USE="ipv6 readline ssl threads -caps -debug -openntpd -parse-clocks -samba (-selinux) -snmp -vim-syntax -zeroconf" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB


Last edited by Roman_Gruber on Fri Aug 28, 2015 12:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Fri Aug 28, 2015 12:11 pm    Post subject: Reply with quote

Code:
 cat /etc/conf.d/ntp-client
# /etc/conf.d/ntp-client

# Command to run to set the clock initially
# Most people should just leave this line alone ...
# however, if you know what you're doing, and you
# want to use ntpd to set the clock, change this to 'ntpd'
NTPCLIENT_CMD="ntpdate"

# Options to pass to the above command
# This default setting should work fine but you should
# change the default 'pool.ntp.org' to something closer
# to your machine.  See http://www.pool.ntp.org/ or
# try running `netselect -s 3 pool.ntp.org`.
NTPCLIENT_OPTS="-s -b -u \
   0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org \
   2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org"

# If you use hostnames above, then you should depend on dns
# being up & running before we try to run.  Otherwise, you
# can disable this.
rc_use="dns"


just comparing my box with https://wiki.gentoo.org/wiki/Ntp the gentoo wiki suggestions, maybe i find something which differs

Code:
cat /etc/ntp.conf
# NOTES:
# DHCP clients can append or replace NTP configuration files.
# You should consult your DHCP client documentation about its
# default behaviour and how to change it.

# Name of the servers ntpd should sync with
# Please respect the access policy as stated by the responsible person.
#server      ntp.example.tld      iburst

# Common pool for random people
#server pool.ntp.org

# Pools for Gentoo users
server 0.gentoo.pool.ntp.org
server 1.gentoo.pool.ntp.org
server 2.gentoo.pool.ntp.org
server 3.gentoo.pool.ntp.org

##
# A list of available servers can be found here:
# http://www.pool.ntp.org/
# http://www.pool.ntp.org/#use
# A good way to get servers for your machine is:
# netselect -s 3 pool.ntp.org
##

# you should not need to modify the following paths
driftfile   /var/lib/ntp/ntp.drift

#server ntplocal.example.com prefer
#server timeserver.example.org

# Warning: Using default NTP settings will leave your NTP
# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)
# from accessing the NTP server, uncomment:
restrict default ignore


# Default configuration:
# - Allow only time queries, at a limited rate, sending KoD when in excess.
# - Allow all local queries (IPv4, IPv6)
restrict default nomodify nopeer noquery limited kod
restrict 127.0.0.1
restrict [::1]


# To allow machines within your network to synchronize
# their clocks with your server, but ensure they are
# not allowed to configure the server or used as peers
# to synchronize against, uncomment this line.
#
#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap


Last edited by Roman_Gruber on Fri Aug 28, 2015 12:12 pm; edited 1 time in total
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Fri Aug 28, 2015 12:12 pm    Post subject: Reply with quote

/usr/share/doc/netifrc-version/net.example.bz2
Code:
#postup() {
...blahblahblah, dyndns register, bhlabhalbha, ntp-client restart?
#}

Combine with ifplugd, and you have nothing to do except plugin the cable :)
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Fri Aug 28, 2015 12:13 pm    Post subject: Reply with quote

thanks krinn, i am still reading the gentoo wiki and checking if i see a difference somewhere...

As far as I can see it seems I have nothing wrong on the config files. the

wiki wants this:
Quote:
/etc/ntp.conf

# To allow machines within the local network to synchronize
# their clocks with this server, but ensure they are
# not allowed to configure the server or used as peers
# to synchronize against, uncomment this line.
#
restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap


and i have that

Code:
restrict default nomodify nopeer noquery limited kod
restrict 127.0.0.1
restrict [::1]


Arch linux: https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon
Quote:
You can also add other options:

restrict default kod nomodify notrap nopeer noquery


Quote:
Next, define the rules that will allow clients to connect to your service (localhost is considered a client too) using the restrict command; you should already have a line like this in your file:

restrict default nomodify nopeer noquery


The only difference to the arch linux thing is that i have additionally limited in it with everythign else in one line.


Which seems to be the same ...[/code]

and the line of

restict ::1 seems similar to arch linuy =>
Quote:
restrict -6 ::1 # ::1 is the IPv6 equivalent for 127.0.0.1
and therefore i just assume it is just another way of writing ipv6 stuff https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon


I think the really culprit is here
Code:
cat /etc/init.d/ntp-client
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

depend() {
   before cron portmap
   after net
   use dns logger
}

checkconfig() {
   if ! type "${NTPCLIENT_CMD}" >/dev/null 2>&1 ; then
      eerror "Please edit /etc/conf.d/ntp-client"
      eerror "Unable to locate the client command ${NTPCLIENT_CMD}!"
      return 1
   fi
   if [ -z "${NTPCLIENT_OPTS}" ] ; then
      eerror "Please edit /etc/conf.d/ntp-client"
      eerror "I need to know what server/options to use!"
      return 1
   fi
   return 0
}

start() {
   checkconfig || return $?

   ebegin "Setting clock via the NTP client '${NTPCLIENT_CMD}'"
   "${NTPCLIENT_CMD}" ${NTPCLIENT_OPTS}
   eend $? "Failed to set clock"
}


especially:

Quote:
depend() {
before cron portmap
after net
use dns logger
}


Dhcpcd gives me a Class C network address when the modem has not finished establishing a connection (using adsl, some sort of xdsl thing here)

The best way seems to be to hardcode a ping to a nameserver like 4.4.4.4 or something like that or a traceroute / path to some common node, so when this requirement is met the nptclient is for sure started.
The only feasable solution should be to hardcode a ping to the ntp-servers in the config files and should these fails, the ntp-client will not yield anything anyway.


Last edited by Roman_Gruber on Fri Aug 28, 2015 12:30 pm; edited 1 time in total
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Fri Aug 28, 2015 12:30 pm    Post subject: Reply with quote

tw04l124 wrote:

Even now as the ethernet cable was connected and the modem was active still the date was incorrect. after i started ntp-client my date and hour was instantly corrected.

openrc start service when openrc is run (so when booting), once done, openrc is not doing anything and so, no way it itself would restart a service.
So you could read all you wish with ntp, openrc will never restart it, until someone ask for that : with ifplugd, it is ifplugd that will detect the cable state, ask net.whatever to start, and then openrc is run to start net.whatever and will see after up, it should start ntp-client...

Or use s2 or similar, or systemd (that will also send a gift to your wife for her birthday, do the coffee, refill your fridge, do the dishes, take your dog out, assume your neighbour is an ass for you because you don't know better than sytemd, insult your neighbour that is an ass, broke the logs so the police cannot get evidence of what "you" did, and block your keyboard as you are lame and systemd knows better what should be done, after kicking you out from your house, connect itself to the net (finally!), rename your host to skynet and start building robots).
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Fri Aug 28, 2015 12:32 pm    Post subject: Reply with quote

hehe krinn, cool. Thanks for your input.

I am still writing down my mind, collecting info, checking which / where / what is done...

yes ifplugd, or i correct the depend on net line above.

When I am bored i need to read the syntax for this and than try to code something.

AFAIK, the code sample above starts with runscript

Code:
Knight roman # runscript
openrc-run should not be run directly
Knight roman # runscript --help
openrc-run should not be run directly
Knight roman # man openrc-run


Whihc means the real culprit is openrc-run, and after i have dealt with that man-page and maybe some other examples. I may learnt something and than may know where to start.

I may want to critize the config file, because it works flawless for those server / university farms where you always have instantly computers up and running with services, including the ntp service. For those home users where the modem goes into some sort of inactivity sleep mode and silenty restarts everything, establish a connection and such, that approach fails.

I assume / expect.

My modem hands out a network address from the valid dhcpcd request according to RFC XYXY whatever.
At that point the modem silently synchronizes the adsl connection, lets say establish, start connecting to the telecom servers.
My modem says, hello, i am 10.0.0.138 and use my gateway 10.0.0.0 and be happy.
I assume / I think at that point the name resolution fails silently and than the clock is not corrected.

LAter when i, have opened a browser and restart / start the service ntp-client the name service is functioning and the time gets corrected.

Could be
a) no name service, but dhcpcd works to the modem at bootup. Silently failing the name resolution to the ntp servers
b) something else
c) race condition,

The really bad thing is that there is no real check if the dns to the ntp-servers is available or works and no complaints in that direction because the shell gets instaly reset and you do not see the old behaviour anymore if somethings fails / warning or other way. in the old days the first tty1 had the last lines of the bootup things, with [okay] or [error] or what it was called ...

...

Okay:

Code:
tail -1000 /var/log/messages |grep ntp
Aug 25 21:28:33 Knight ntpdate[4088]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 25 21:28:33 Knight /etc/init.d/ntp-client[4073]: ERROR: ntp-client failed to start
Aug 25 20:09:20 Knight ntpdate[4271]: step time server 212.186.250.154 offset -4971.277111 sec
Aug 25 22:55:54 Knight /etc/init.d/ntp-client[19808]: WARNING: ntp-client has already been started
Aug 26 12:28:24 Knight ntpdate[4081]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 26 12:28:24 Knight /etc/init.d/ntp-client[4066]: ERROR: ntp-client failed to start
Aug 26 11:06:50 Knight ntpdate[4255]: step time server 193.171.23.163 offset -4994.422546 sec
Aug 27 09:18:41 Knight ntpdate[4084]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 27 09:18:41 Knight /etc/init.d/ntp-client[4069]: ERROR: ntp-client failed to start
Aug 27 07:55:47 Knight ntpdate[4278]: step time server 193.171.23.163 offset -5026.743349 sec
Aug 27 12:00:31 Knight ntpdate[4081]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 27 12:00:31 Knight /etc/init.d/ntp-client[4066]: ERROR: ntp-client failed to start
Aug 27 12:00:47 Knight ntpdate[4238]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 27 12:00:47 Knight /etc/init.d/ntp-client[4222]: ERROR: ntp-client failed to start
Aug 28 09:33:45 Knight ntpdate[4084]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 28 09:33:45 Knight /etc/init.d/ntp-client[4069]: ERROR: ntp-client failed to start
Aug 28 07:06:47 Knight ntpdate[5231]: step time server 131.130.251.107 offset -10094.027612 sec
Aug 28 14:09:40 Knight ntpdate[4084]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 28 14:09:40 Knight /etc/init.d/ntp-client[4069]: ERROR: ntp-client failed to start
Aug 28 14:09:52 Knight ntpdate[4229]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 28 14:09:52 Knight /etc/init.d/ntp-client[4213]: ERROR: ntp-client failed to start
Aug 28 16:49:03 Knight ntpdate[4084]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 28 16:49:03 Knight /etc/init.d/ntp-client[4069]: ERROR: ntp-client failed to start
Aug 28 16:49:11 Knight ntpdate[4229]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 28 16:49:11 Knight /etc/init.d/ntp-client[4213]: ERROR: ntp-client failed to start
Aug 28 14:01:43 Knight ntpdate[5128]: step time server 131.130.251.107 offset -10145.062157 sec


Seems the ntp-client does not check regularly after once the dns failed

was this morning as i had to check a route on google maps:
Quote:
Aug 28 09:33:45 Knight ntpdate[4084]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 28 09:33:45 Knight /etc/init.d/ntp-client[4069]: ERROR: ntp-client failed to start
Aug 28 07:06:47 Knight ntpdate[5231]: step time server 131.130.251.107 offset -10094.027612 sec


this afternoon.
Code:
Aug 28 16:49:11 Knight ntpdate[4229]: name server cannot be used: Temporary failure in name resolution (-3)
Aug 28 16:49:11 Knight /etc/init.d/ntp-client[4213]: ERROR: ntp-client failed to start
Aug 28 14:01:43 Knight ntpdate[5128]: step time server 131.130.251.107 offset -10145.062157 sec


Summary, my box does not have a proper dns, name resolution at bootup / during bootup and the ntp-client fails silently and does never try again.


Last edited by Roman_Gruber on Fri Aug 28, 2015 12:45 pm; edited 1 time in total
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Fri Aug 28, 2015 12:42 pm    Post subject: Reply with quote

tw04l124 wrote:
hehe krinn, cool. Thanks for your input.

I am still writing down my mind, collecting info, checking which / where / what is done...

yes ifplugd, or i correct the depend on net line above.

When I am bored i need to read the syntax for this and than try to code something.


You'll see fixing the config is better, or you will have to watch your next etc-update because "fixing" in the start script will be trash on next update.
But you may ask depend fix in bugzilla, while i don't think myself it need fixing as your problem is not with ntp, but the connection.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Fri Aug 28, 2015 12:50 pm    Post subject: Reply with quote

I always respect your replies.

Well dns error. I know more as I wanted to know at start.

The thing now is to think about a smart way to force ntp-client to sync.

I may be a bit oldfashioned. to
boot up only init 3. and

use the following usually

lxdm -d; ifconfig wlan0 down; cpupower frequency-set -g ondemand; exit;

I should add all that stuff to config files and thats it,

The reason why i start lxdm by hand is for example when the mouse / keyboard module is not functioning as i had in the past several times, i can not press anyting except the power button which annoyed me like hell. And i prefer managing network by hand. therefore i see instantly if pptp works, eth0 works, wlan0 works. maybe i am too oldfashioned and i should use jsut /etc/xorg.conf or xdm.conf what its called and some ifplugd or something to handle all that stuff... It may be solved with those helper programms / config files maybe and just my oudated oldfashioned behaviour, where i used to type everything since i used dos 6.2
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Fri Aug 28, 2015 2:12 pm    Post subject: Reply with quote

tw04l124 wrote:

The reason why i start lxdm by hand is for example when the mouse / keyboard module is not functioning as i had in the past several times, i can not press anyting except the power button which annoyed me like hell.

I think i'm old fashion, but automated things is not something i consider not to be use.
If really i would start lxdm by hands to fear of missing mouse, i would still autostart lxdm and add a script in it:
head -c 2 /dev/input/mouse0 & sleep 15 && kill $(pidof head)

So you read 2 char from /dev/input/mouse0
- head will wait until it could read them: so if mouse is not working (or not moving), head will stay running forever

So if head succeed, it cannot be kill and you'll get the $? error from kill that pidof return nothing
And if head doesn't succeed, $? will be 0 because kill succeed at killing head

Got it?
If $? = 0 -> kill lxdm because your mouse didn't answer
You only need to tune up the timing of sleep, too short and it will kill lxdm fast and maybe way too fast, too long and you'll wait all that time before lxdm get killed
For me i would put a high value, if mouse works, it doesn't matter as the script will end, i don't care it need a minute to end
And if mouse is not working, i suppose i could wait a minute before lxdm get killed, as it should still be rare case.

You could be both old school and lazzy at the same time :)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54232
Location: 56N 3W

PostPosted: Fri Aug 28, 2015 8:51 pm    Post subject: Reply with quote

tw04l124,

A few things,

That 169. IP address is a link local address. dhcpcd ran, failed to reach a dhcp server because your network was unplugged, then self assigned a link local address.
The only use for link local IPs is on ad hoc networks.

ntp-client runs once then exits. It puts you clock right even if a big step is required.
ntpd should also be in the default runlevel to keep your clock correct.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sat Aug 29, 2015 6:37 am    Post subject: Reply with quote

Today:

Grub => reboot instantly with three fringer salute to the bios.

bios => date 06:31:51
time synced table clock => 08:31:57

=> so, after a coldboot of my box, with only grub in action and instnaly back to the bios the clock is alright

=> startup => 09:57:51

=> /etc/init.d/ntp-client => corrected back to 08:36:00

=> it seems I have to build a kernel from scatch and see if this issue will be gone.

my initramfs is quite old and could be an issue too, but i think its more a kernel related issue.

the core issue is, that something after grub2 from linux mint till init 3 ruins my time base.

---

@@ neddy.

absolutely correct,

quote man:

Quote:
The ntpd utility is an operating system daemon which sets and maintains the system time of day in synchronism with Internet
standard time servers. It is a complete implementation of the Network Time Protocol (NTP) version 4, as defined by
RFC-5905, but also retains compatibility with version 3, as defined by RFC-1305, and versions 1 and 2, as defined by
RFC-1059 and RFC-1119, respectively.


I will build a kernel soon and check i can sort out some things.
The main thing is that the bios keeps the clock correct during powering town / power off state. it does not matter if the power source is taken from the laptop battery or the bios battery, the clock is still correct but gets corrupted during mdev initramfs from genkernel 2012 or openrc/eudev/kernel 4.1 => the thing is the issue dates back to kernel 3.4 or 3.10 afaik but just recently annoyed me a lot to check why the clock was not corrected.

still the issue that some of the log files are always incorrect because the clock is corrupted during bootup. Therefore some entries for syslogn uses a wrongtime code and that could be bothersome for forensic analysis or other issues when the time code is not correct.

First step is to build a kernel from scratch, just use the needed gentoo-sources + loaded modules and thats it.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sat Aug 29, 2015 7:49 am    Post subject: Reply with quote

Well

Removed ntp-client from rc-update runlevels

rebuild a kernel without any rtc / watchdog features.

I have to see what impact this change has and if it resolve anything.

the date and time stays as it should now after a warmboot from my previous kernel.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54232
Location: 56N 3W

PostPosted: Sat Aug 29, 2015 9:53 am    Post subject: Reply with quote

tw04l124,

Lets consider the sequence of events.

While power is off, a battery backed real time clock keeps time.
For Linux users, this is set to UTC, regardless of your timezone (no daylight saving time corrections)
Windows users, or dual boot users, will have this clock set to local time, including daylight saving.

At boot, the battery backed real time clock time is copied to system time and plays no further part in timekeeping until shutdown.
As the system contines to boot, the timezone becomes known. The system clock is still in UTC but the timezone correction is applied to times unless you ask for UTC.
When the network is available ntp-client way be run which may step the UTC system time.
When ntp-client exits, ntpd may be started to keep system time aligneh with network time.
ntpd alone may do nothing, as it gives up for large time errors.

All the while the system is running, BIOS time and system time will diverge. There is no reason to keep them together.
During shutdown, you can choose to update BIOS time from system time, or not. This is generally a good thing as its the only time the BIOS clock is corrected, unless you go into the BIOS at boot.

It would be rare for the initrd to play any part in this sequence, as there is normally no network setup and no timezone setting in the initrd.
You could if you wanted but most people don't.

Things to look at.
Is the BIOS clock correct at shutdown?
If its not, it will still be wrong at power up.
Is the BIOS clock correct at startup?
Unless the battery has failed totally, you need at least overnight power off to test

Is /etc/timezone set correctly?
This is used at every boot to copy /usr/share/zoneinfo/... to /etc/localtime
More subtly, is /usr mounted when this happens?
If not /etc/localtime will not be updated.
If /usr is on root /etc/localtime may be a symlink into /usr/share/zoneinfo/... but this is old fashioned and discouraged.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sun Aug 30, 2015 8:42 am    Post subject: Reply with quote

well.

in the following correct means utc time or the current time zone i am in when the box is booted.

the clock is correct in the bios during cold boot.
in grub2 from linux mint when I use the rescue shell in grub2. date command => weird only date is supported not time.
my initramfs uses mdev / busybox => 2012 genkernel => resuce shell => also date command => correct

Same kernel sources without any rtc and watchdog => clock is correct
Same kernel sources with rtc and watchdog (previous kernel config before i removed rtc and watchdog) => weird behaviour

I also removed the file in /etc which is responsible to keep the deviation of the clock. something like adjtime => adjust time config file for ntp or the hwclock ...

For some reason my box gets hot now without rtc and watchdog => could be dust in the fans / in the cooling path. my gpu says it has 110 degrees, and than i see a clock rate of 37 mhz instead of 600 at full performance mode using the tool nvidia-settings from the nvidia-binary.

My question is, do i really need that rtc thing in the kernel because now i do not have /proc/rtc (was the parth afaik)

I learnt a bit about rtc and those timezones and stuff.

too bad the timezone thing here was copied in the past from myself, i never made a hardlink and it is garbage text, it need some hex editor or something else to may realize what it really is... My timezone was in the past always set accordingly as it should be by my box itself.. So I assume except the missing softlink / hardlink, the timezone seems to be correct, afaik.

---

I have to clean the notebook soon and than I will measure the voltage of the backup cmos battery when it is a standard crxxxx lithum cell, if not i doubt i can measure it.

I also suspect that maybe the cmos battery maybe dead now after more than 6 years, even on laptop battery.

Quote:
If /usr is on root /etc/localtime may be a symlink into /usr/share/zoneinfo/... but this is old fashioned and discouraged.

It seems i did copy that timezone data to /etc/localtime


hole / without boot is on an lvm container which contails luks, which uses ext4.
distfiles are on a separate partition with DISTDIR in make.conf
boot is boot partition from linux mint,
so /usr should be always useable when / is useable..
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54232
Location: 56N 3W

PostPosted: Sun Aug 30, 2015 8:56 am    Post subject: Reply with quote

tw04l124,

You should have the rtc entry in the kernel.
Its used at least twice. Once to read the BIOS clock at boot ando once to set it on shutdown.

A few other programs, (mplayer comes to mind) use it for timing if they can read it.
If not, they fall back to busy waits. mplayer used to tell you about this.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sun Aug 30, 2015 8:58 am    Post subject: Reply with quote

Hmm,

very silly question, but still

How do i know which RTC do i need to choose.

I tried to find out yesterday with lshw and such but I was really clueless.

Thank you for reading such carefully my stuff.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54232
Location: 56N 3W

PostPosted: Sun Aug 30, 2015 9:17 am    Post subject: Reply with quote

tw04l124,

You need the PC one but it looks like things have changed since I delved this deeply into kernel RTC support.

I have.
Code:
Symbol: RTC_LIB [=y]                                                                                     │ 
  │ Type  : boolean                                                                                          │ 
  │   Defined at drivers/rtc/Kconfig:5                                                                       │ 
  │   Selected by: X86 [=y] || RTC_CLASS [=y] && !S390 && !UML 

Notice that its forced on by X86 [=y], which is all 32 or 64 bit AMD/Intel and in turn, thus all RTCs are not selectable
Code:
  │ │                - - Enhanced Real Time Clock Support (legacy PC RTC driver)                           │ │ 
  │ │                - - Enhanced Real Time Clock Support                                                  │ │ 
  │ │                - - Generic /dev/rtc emulation                                                        │ │ 
  │ │                - -   Extended RTC operation                                                          │ │ 
  │ │                - - EFI Real Time Clock Services                                                      │ │ 
  │ │                - - DS1302 RTC support                                                                │ │ 
  │ │                - - Double Talk PC internal speech card support                                       │ │ 
  │ │                - - Xilinx HWICAP Support

Press z to see everything in menuconfig. Its a toggle.
I was going to say you need
Code:
Enhanced Real Time Clock Support (legacy PC RTC driver) 
but it looks like RTC_LIB has taken over and you can't turn it off.

For completness
Code:
  │ Symbol: RTC [=n]                                                                                         │ 
  │ Type  : tristate                                                                                         │ 
  │ Prompt: Enhanced Real Time Clock Support (legacy PC RTC driver)                                          │ 
  │   Location:                                                                                              │ 
  │     -> Device Drivers                                                                                    │ 
  │       -> Character devices                                                                               │ 
  │   Defined at drivers/char/Kconfig:280                                                                    │ 
  │   Depends on: !RTC_LIB [=y] && !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !\         │ 
  │ SUPERH && !S390 && !AVR32 && !BLACKFIN && !UML
so you only see Enhanced Real Time Clock Support (legacy PC RTC driver), if !RTC_LIB is true and thats only true for non AMD/Intel systems.

Your RTC support is no longer under your control.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sun Aug 30, 2015 11:50 am    Post subject: Reply with quote

Code:
lsmod
Module                  Size  Used by
nvidia              10471593  30
uvcvideo               62079  0
videobuf2_vmalloc       4085  1 uvcvideo
videobuf2_memops        1503  1 videobuf2_vmalloc
videobuf2_core         26971  1 uvcvideo
coretemp                5260  0
pcspkr                  1675  0
lpc_ich                13761  0
iwl4965                72905  0
iwlegacy               38492  1 iwl4965
rtc_cmos                8052  0
Knight roman # date
So 30. Aug 13:45:40 CEST 2015
Knight roman # qlist -Iv ntp
x11-proto/presentproto-1.0
x11-proto/printproto-1.0.5-r1
x11-proto/xf86bigfontproto-1.2.0-r1
Knight roman # uname -a
Linux Knight 4.1.6-gentoo_08_31_2015 #4 SMP PREEMPT Sun Aug 30 11:05:33 CEST 2015 x86_64 Intel(R) Core(TM)2 Duo CPU T9500 @ 2.60GHz GenuineIntel GNU/Linux


Basically its the same kernel config as before but without watchdogs and any build in rtc stuff. I have build now all rtc things as much as possible as modules.

Quote:
rtc_cmos 8052 0

and it seems only the cmos thing gets selected and the clock is correct. afaik

Code:
zcat /proc/config.gz |grep rtc
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
Knight roman # zcat /proc/config.gz |grep RTC
CONFIG_HPET_EMULATE_RTC=y
CONFIG_RTC_LIB=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_HCTOSYS=y
# CONFIG_RTC_SYSTOHC is not set
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
CONFIG_RTC_DEBUG=y
# RTC interfaces
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
# CONFIG_RTC_DRV_TEST is not set
# I2C RTC drivers
CONFIG_RTC_DRV_ABB5ZES3=m
CONFIG_RTC_DRV_ABX80X=m
CONFIG_RTC_DRV_DS1307=m
CONFIG_RTC_DRV_DS1374=m
# CONFIG_RTC_DRV_DS1374_WDT is not set
CONFIG_RTC_DRV_DS1672=m
CONFIG_RTC_DRV_DS3232=m
CONFIG_RTC_DRV_MAX6900=m
CONFIG_RTC_DRV_RS5C372=m
CONFIG_RTC_DRV_ISL1208=m
CONFIG_RTC_DRV_ISL12022=m
CONFIG_RTC_DRV_ISL12057=m
CONFIG_RTC_DRV_X1205=m
CONFIG_RTC_DRV_PCF2127=m
CONFIG_RTC_DRV_PCF8523=m
CONFIG_RTC_DRV_PCF8563=m
CONFIG_RTC_DRV_PCF85063=m
CONFIG_RTC_DRV_PCF8583=m
CONFIG_RTC_DRV_M41T80=m
# CONFIG_RTC_DRV_M41T80_WDT is not set
CONFIG_RTC_DRV_BQ32K=m
CONFIG_RTC_DRV_TWL4030=m
CONFIG_RTC_DRV_S35390A=m
CONFIG_RTC_DRV_FM3130=m
CONFIG_RTC_DRV_RX8581=m
CONFIG_RTC_DRV_RX8025=m
CONFIG_RTC_DRV_EM3027=m
CONFIG_RTC_DRV_RV3029C2=m
# SPI RTC drivers
CONFIG_RTC_DRV_M41T93=m
CONFIG_RTC_DRV_M41T94=m
CONFIG_RTC_DRV_DS1305=m
CONFIG_RTC_DRV_DS1343=m
CONFIG_RTC_DRV_DS1347=m
CONFIG_RTC_DRV_DS1390=m
CONFIG_RTC_DRV_MAX6902=m
CONFIG_RTC_DRV_R9701=m
CONFIG_RTC_DRV_RS5C348=m
CONFIG_RTC_DRV_DS3234=m
CONFIG_RTC_DRV_PCF2123=m
CONFIG_RTC_DRV_RX4581=m
CONFIG_RTC_DRV_MCP795=m
# Platform RTC drivers
CONFIG_RTC_DRV_CMOS=m
CONFIG_RTC_DRV_DS1286=m
CONFIG_RTC_DRV_DS1511=m
CONFIG_RTC_DRV_DS1553=m
CONFIG_RTC_DRV_DS1685_FAMILY=m
CONFIG_RTC_DRV_DS1685=y
# CONFIG_RTC_DRV_DS1689 is not set
# CONFIG_RTC_DRV_DS17285 is not set
# CONFIG_RTC_DRV_DS17485 is not set
# CONFIG_RTC_DRV_DS17885 is not set
# CONFIG_RTC_DS1685_PROC_REGS is not set
# CONFIG_RTC_DS1685_SYSFS_REGS is not set
CONFIG_RTC_DRV_DS1742=m
CONFIG_RTC_DRV_DS2404=m
CONFIG_RTC_DRV_STK17TA8=m
CONFIG_RTC_DRV_M48T86=m
CONFIG_RTC_DRV_M48T35=m
CONFIG_RTC_DRV_M48T59=m
CONFIG_RTC_DRV_MSM6242=m
CONFIG_RTC_DRV_BQ4802=m
CONFIG_RTC_DRV_RP5C01=m
CONFIG_RTC_DRV_V3020=m
CONFIG_RTC_DRV_PCF50633=m
# on-CPU RTC drivers
CONFIG_RTC_DRV_XGENE=m
# HID Sensor RTC drivers
CONFIG_RTC_DRV_HID_SENSOR_TIME=m
# CONFIG_INTEL_SMARTCONNECT is not set


It seems one of the build in stuff before caused troubles or the watchdog itself...

I will watch for quite a while now and when its really gone I will add ntpd (reemerge ntp package) and than mark the topic as solved.

As of now I am in the wait state and verify for the next bootup in the following weeks if the thing really is gone.

What I can tell is that some of the build in RTC / watchdog thing caused troubles but to narrow it down, it is too much efforts.

I do not know if there is a way on what is used and what is not used for build in stuff in a kernel.

for a kernel module afaik you use lsmod ...

--

Code:
zcat /proc/config.gz |grep RTC_LIB
CONFIG_RTC_LIB=y
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Sun Aug 30, 2015 12:19 pm    Post subject: Reply with quote

tw04l124 wrote:
I do not know if there is a way on what is used and what is not used for build in stuff in a kernel.
for a kernel module afaik you use lsmod ...

It's in dmesg, it will always works, even it do nothing.
Build some aacraid (adapatec sas driver) in kernel, even without the card, the stuff will works, doing nothing

So it is hard to tell what really is doing something and what is just load for no reason and do nothing, as everything is always working/running.
Generally you get another message (dmesg add the module name that is telling the message), giving a clue the stuff is doing really something (showing some name or state).

But it's a weak clue, as it may do something without giving any message itself as:
Code:
[    0.316895] pcieport 0000:00:01.0: irq 24 for MSI/MSI-X


But if you dig really, you'll see this is even worst for module in fact:
"Used by" is not telling you the module is doing anything, it tells you the module is use by another module.
Look at your coretemp: Used By 0, it doesn't tell you coretemp is doing anything, it just tells you coretemp is loaded, and no other module is using it.

If again you build the aacraid but as module, it may be used by another module (per example, "sd" the scsi disk module) will use it, so you have no adaptec card, the module is load, the module is use by another one and the "Used By" will not be 0. But still what it do: nothing, you don't have the card.

People trust lsmod, because modules are loaded by devmanager when it find the hardware, but if you load it yourself, or autoload it on boot, you have no way to really tells if it do anything just by looking at lsmod output.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54232
Location: 56N 3W

PostPosted: Sun Aug 30, 2015 1:25 pm    Post subject: Reply with quote

tw04l124,

There is
Code:
lspci -k
for your pci drivers but I don't know of anythisg for USB devices.
Debian has a website for doing hardware lookups too
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Wed Sep 02, 2015 12:26 pm    Post subject: Reply with quote

As far as I can tell now, the culprit was kinda the watchdog in my kernel or that the rtc were all build in the kernel.
I uninstalled ntp related stuff from my box.
Than i build any rtc stuff as module and without any ntp in the system, teh clock is correct again after a long time which this issue has bugged me.

I learnt a lot regarding that date / time thing on linux.

It may be the ntp adjustime file also be the culprit but the main reason I started this topic was that the time was incorrect, got corrupted during booting, and I got entries with false date code in my /var/log/messages which is kinda bad for future maintenance ...

Thanks for your attention everyone... I mark this topic as solved as it seems the issue is gone after a few days now after i made these changes
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum