Skip to content

Instantly share code, notes, and snippets.

@zircote
Created May 12, 2011 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zircote/969477 to your computer and use it in GitHub Desktop.
Save zircote/969477 to your computer and use it in GitHub Desktop.
Redis status
#!/usr/bin/env php
<?php
/**
*
* Result string for parsing
* @var string
*/
$string = null;
/**
*
* replace hostname with target meteor server
* @var string
*/
$host = "tcp://localhost:6379";
/**
*
* result container
* @var array
*/
$result = array();
/**
*
* socket resource
* @var int
*/
$fp = fsockopen($host);
if (! $fp) {
die('error failed to connect');
}
fwrite($fp, "info\r\n");
while (true) {
$string .= $out = fgets($fp, 512);
if (strlen($out) < 3) {
break;
}
}
fclose($fp);
$lines = explode("\n", $string);
foreach ($lines as $value) {
if (strlen($value) && strstr($value,':')) {
$parts = split(':', $value);
$result[$parts[0]] = trim($parts[1]);
}
}
echo json_encode($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment