Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Conversation

nelbren
Copy link
Contributor

@nelbren nelbren commented Aug 27, 2019

Pull Request Template

Description

librrd creates function has problems with validation that exists with ==v1.5 and higher==

  • v1.4 - rrd_utils.c - NO has this type of validation

  • v1.5 - rrd_utils.c - has a new validation

    241    if (! isdigit(token[0]))
    242      return "value must be (suffixed) positive number";

Fixes on nagiosPerfTrace.pm

  • Elimination of space in scale parameter
  • Adding error condition on creation

Type of change

  • Patch fixing an issue (non-breaking change)

Target serie

  • 19.10.x (master)

How this pull request can be tested?

[root@ndev-vps-05:~]# sudo -u centreon /usr/local/centreon/cron/nagiosPerfTrace --config=/etc/centreon/conf.pm
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_cmd_buffer.rrd': No such file or directory
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_active_service_latency.rrd': No such file or directory
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_active_service_execution.rrd': No such file or directory
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_active_service_last.rrd': No such file or directory
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_services_states.rrd': No such file or directory
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_active_host_latency.rrd': No such file or directory
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_active_host_execution.rrd': No such file or directory
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_active_host_last.rrd': No such file or directory
2019-08-26 20:58:02 - ERROR - opening '/var/lib/centreon/nagios-perf/perfmon-1/nagios_hosts_states.rrd': No such file or directory

Proof of concept for test

#!/usr/bin/perl
#
# librrd_creates_function_has_problems_with_validation_that_exists_with_v1.5_and_higher.pl
#
# 2019-09-26 - nelbren@nelbren.com
#

use RRDs;

my $tempfile = "/tmp/test.rrd";
my $interval = "300";

print("librrd v$RRDs::VERSION\n");

# Version <= 1.4 https://github.com/oetiker/rrdtool-1.x/blob/1.4/src/rrd_utils.c
print("create with -s $interval (this fail in v>=1.5 and works in v<=1.4)\n");
RRDs::create($tempfile, "-s $interval",  "DS:Test:GAUGE:$interval:0:U", "RRA:AVERAGE:0.5:1:".$interval);
print(" +--> ".RRDs::error()."\n") if (RRDs::error());

# Version >= 1.5 https://github.com/oetiker/rrdtool-1.x/blob/1.5/src/rrd_utils.c
# 241    if (! isdigit(token[0]))
# 242       return "value must be (suffixed) positive number";
print("create with -s$interval (this works in v>=1.5 and works in v<=1.4)\n");
RRDs::create($tempfile, "-s$interval",  "DS:Test:GAUGE:$interval:0:U", "RRA:AVERAGE:0.5:1:".$interval);
print(" +--> ".RRDs::error()."\n") if (RRDs::error());

This problem occurs in Debian GNU/Linux 10.0

[nelbren@ndev-vps-05:~]$ uname -a
Linux ndev-vps-05 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux

[nelbren@ndev-vps-05:~]$ ./librrd_creates_function_has_problems_with_validation_that_exists_with_v1.5_and_higher.pl
librrd v1.5001
create with -s 300 (this fail in v>=1.5 and works in v<=1.4)
 +--> step size: value must be (suffixed) positive number
create with -s300 (this works in v>=1.5 and works in v<=1.4)

This problem does not occur in centreon-19.04-0.el7.x86_64.iso

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost ~]# ./librrd_creates_function_has_problems_with_validation_that_exists_with_v1.5_and_higher.pl
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "es_HN.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
librrd v1.4008
create with -s 300 (this fail in v>=1.5 and works in v<=1.4)
create with -s300 (this works in v>=1.5 and works in v<=1.4)

Greetings by Nelbren!

@kduret
Copy link
Contributor

kduret commented Aug 27, 2019

@garnier-quentin could you take a look on this please :)

@SylvestreG
Copy link

If I am not mistaken, this issue is fixed in broker (we were pushing NaN values in rrd). I think that if you use the broker from master this issue will not reproduce (@lpinsivy am I right ?)

@garnier-quentin
Copy link
Contributor

@SylvestreG centreon-broker doesn't manage some RRDs; It's a legacy script.
I don't see the link between the step interval (-s option) and rrd_utils.c

@cgagnaire
Copy link

LGTM, thanks @nelbren!

@garnier-quentin
Copy link
Contributor

Indeed. there is a link. thanks for the patch.

@kduret kduret merged commit ddb7f91 into centreon:master Nov 15, 2019
kduret pushed a commit that referenced this pull request Nov 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants