I’ve found that my cacti graph of redis commands executed was jumping around like crazy. After a lot of debugging it turns out that the redis_get function usually will return about half of the INFO response from redis. The crazy thing is it would stop at the second-to-last digit of the total_commands_processed value.
To illustrate; if the actual redis info response was:
(...snip...)
# Stats
total_connections_received:7378492
total_commands_processed:2724014579
instantaneous_ops_per_sec:23
(...snip...)
The $data variable in redis_get would end up with:
(...snip...)
# Stats
total_connections_received:7378492
total_commands_processed:272401457
Every 10th poll or so the implementation would work as intended, causing a huge delta because of the extra digit, and a big spike in the Cacti graph.
I’ve changed the script at line 1307 (in redis_get) to send a PING after the info, and keep reading the response until PONG is received:
[PHP]
$res = fwrite($sock, “INFO\r\nPING\r\n”);
if (!$res ) {
echo(“Can’t write to socket”);
return;
}
$data = ‘’;
while (($line = fgets($sock)) && trim($line) != ‘+PONG’) {
$data .= $line;
}
[/PHP]
Which caused a b0rked graph like this:
[ATTACH=CONFIG]n41053[/ATTACH]
…to become more reasonable (fix applied 11:31 + graph is zoomed in the avoid the earlier extreme values):
[ATTACH=CONFIG]n41054[/ATTACH]
Hope it can help someone. Cheers.