/**
  * Get the correct version of a configurator from a socket
  *
  * @param  Nexcessnet_Turpentine_Model_Varnish_Admin_Socket $socket
  * @return Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract
  */
 public static function getFromSocket($socket)
 {
     try {
         $version = $socket->getVersion();
     } catch (Mage_Core_Exception $e) {
         Mage::getSingleton('core/session')->addError('Error determining Varnish version: ' . $e->getMessage());
         return null;
     }
     switch ($version) {
         case '3.0':
             return Mage::getModel('turpentine/varnish_configurator_version3', array('socket' => $socket));
         case '2.1':
             return Mage::getModel('turpentine/varnish_configurator_version2', array('socket' => $socket));
         default:
             Mage::throwException('Unsupported Varnish version');
     }
 }
<?php

$probe_file = "/fb_host_probe.txt";
class Mage
{
    public static function throwException($msg)
    {
        die($msg);
    }
}
require "/credis.php";
$redis = new Credis_Client("clusterdata");
require "/varnish.php";
$varnish = new Nexcessnet_Turpentine_Model_Varnish_Admin_Socket(array("host" => "varnish", "auth_secret" => file_get_contents("/varnish.secret")));
// get first VCL (there should be always only one)
$vcl = $varnish->vcl_list();
if ($vcl["code"] != Nexcessnet_Turpentine_Model_Varnish_Admin_Socket::CODE_OK) {
    die("Unable to read VCLs from Varnish");
}
$vcl = explode("\n", trim($vcl["text"]))[0];
$vcl = explode(" ", $vcl);
$vcl = $vcl[sizeof($vcl) - 1];
$vcl = $varnish->vcl_show($vcl);
if ($vcl["code"] != Nexcessnet_Turpentine_Model_Varnish_Admin_Socket::CODE_OK) {
    die("Unable to read latest VCL from Varnish");
}
$vcl = $vcl["text"];
$vcl = preg_replace("/#AUTOGENERATED_START.*#AUTOGENERATED_END/ms", "#AUTOGENERATED_START\n#AUTOGENERATED_END", $vcl);
$vcl = explode("\n", $vcl);
$apaches = array();
$hosts = array_keys($redis->hGetAll("fb_apache_containers"));