Bug in ss_get_by_ssh.php --type=redis

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:

# Stats

The $data variable in redis_get would end up with:

# Stats

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:

$res = fwrite($sock, “INFO\r\nPING\r\n”);
if (!$res ) {
echo(“Can’t write to socket”);

$data = ‘’;
while (($line = fgets($sock)) && trim($line) != ‘+PONG’) {
$data .= $line;

Which caused a b0rked graph like this:

…to become more reasonable (fix applied 11:31 + graph is zoomed in the avoid the earlier extreme values):

Hope it can help someone. Cheers.