check_ntp_time ipv6 error

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
joshuawong
Posts: 2
Joined: Fri Apr 30, 2021 2:39 am

check_ntp_time ipv6 error

Post by joshuawong »

When monitoring NTP server by check_ntp_time with -6 option to check ipv6 connection, sometimes show alerts of "can not create new socket". There is no alert when monitoring with "-4" for ipv4 connection. Anyone could suggest solution to this case? Thanks a lot.
joshuawong
Posts: 2
Joined: Fri Apr 30, 2021 2:39 am

Re: check_ntp_time ipv6 error

Post by joshuawong »

Solved: check ai_tmp->ai_family == address_family before creating socket in check_ntp_time.c

source code:
https://github.com/nagios-plugins/nagio ... ntp_time.c

line 354:
//original
socklist=socket(ai_tmp->ai_family, SOCK_DGRAM, IPPROTO_UDP);
if(socklist == -1) {
perror(NULL);
die(STATE_UNKNOWN, "can not create new socket");
}

//Add a 'if' check
if {ai_tmp->ai_family == address_family) {
socklist=socket(ai_tmp->ai_family, SOCK_DGRAM, IPPROTO_UDP);
if(socklist == -1) {
perror(NULL);
die(STATE_UNKNOWN, "can not create new socket");
}
}
Locked