Add ./validate.php -m rrdcheck #2908

Merged
merged 5 commits into from Feb 7, 2016

Projects

None yet

4 participants

@khobbits
Contributor
khobbits commented Feb 2, 2016

This adds a little tool to list unreadable rrd files in your rrd folder.

Scanning 9656 rrd files in /opt/librenms/rrd...
[FAIL]    Error parsing "/opt/librenms/rrd/nexus-c/port-5.rrd" RRD ERROR: '/opt/librenms/rrd/nexus-c/port-5.rrd.old' is not an RRD file
[FAIL]    Error parsing "/opt/librenms/rrd/nexus-c/ucd_diskio-dm-1.rrd" RRD ERROR: mmaping file '/opt/librenms/rrd/nexus-c/ucd_diskio-dm-1.rrd': Invalid argument
[FAIL]    Error parsing "/opt/librenms/rrd/nexus-c/ucd_diskio-dm-0.rrd" RRD ERROR: mmaping file '/opt/librenms/rrd/nexus-c/ucd_diskio-dm-0.rrd': Invalid argument
Status: 9656/9656 - Complete
@khobbits khobbits Add ./validate.php -m rrdcheck
This will loop through rrd files and highlight any corrupt files.
92a7e57
@khobbits khobbits Code clean up
5ebe6b4
@khobbits khobbits Attempt to scare away scrutinizer issues.
f2bad98
@f0o
Member
f0o commented Feb 2, 2016

Looks good from a brief view. Will test it on the CI after lunch

@khobbits
Contributor
khobbits commented Feb 2, 2016

To test the tool with output, just create some empty rrd files using touch.

@f0o f0o commented on the diff Feb 2, 2016
includes/functions.php
+ $process = proc_open(
+ $command,
+ array (
+ 0 => array('pipe', 'r'),
+ 1 => array('pipe', 'w'),
+ 2 => array('pipe', 'w'),
+ ),
+ $pipes
+ );
+
+ if (!is_resource($process)) {
+ throw new \RuntimeException('Could not create a valid process');
+ }
+
+ $status = proc_get_status($process);
+ while($status['running']) {
@f0o
f0o Feb 2, 2016 Member

This loop is very cpu heavy, please add a sleep in it. A couple of ms is fine

@khobbits
khobbits Feb 2, 2016 Contributor

Did a couple of benchmarks here on my vm librenms:
Anything below 2ms increases the cpu usage time without speeding up the process.
Anything above 3ms increases run time without significantly decreasing cpu usage time.

@khobbits khobbits Slow polling loop
028b430
@khobbits
Contributor
khobbits commented Feb 2, 2016

Need me to rebase?

@laf
Member
laf commented Feb 2, 2016

Nope, only need to do that if it has a conflict.

@khobbits
Contributor
khobbits commented Feb 2, 2016

Okie, some people don't like large number of small commits ^^

@laf
Member
laf commented Feb 2, 2016

Ah you mean squash. It's fine, we'd probably ask you to if it was 50+ but it keeps history so no big deal.

@laf
Member
laf commented Feb 2, 2016

Looks good to me so 👍

Seems to spike the cpu but only at the start when I assume it's finding all rrd files to check.

Would you mind updating the http://docs.librenms.org/Support/Install%20Validation/ docs?

@khobbits khobbits Update validation docs
078c323
@khobbits
Contributor
khobbits commented Feb 6, 2016

Need anything else from me for this?

@f0o
Member
f0o commented Feb 7, 2016

Nevermind.

Works, had a typo.

@f0o f0o merged commit e2151bf into librenms:master Feb 7, 2016

2 checks passed

Auto-Deploy Build finished. No test results found.
Details
Scrutinizer 2 updated code elements
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment