getPortStateService();
$mp = $psmconfig->getPortStateService();
$state = $sp <= 0 ? "Not configured, disabled" : "@ port ".$psmconfig->getPortStateService()." ";
$state .= $sp <= 0 ? "" : $s === null ? "Not accessible at this time. (down, booting or quiting)" : "Running";
$monitor = $mp <= 0 ? "Not configured, disabled" : "@ port ".$psmconfig->getPortMonitorService()." ";
$monitor.= $mp <= 0 ? "" : $m === null ? "Not accessible at this time. (down, booting or quiting)" : "Running";
echo "State Service $state
";
echo "Monitor Service $monitor
";
if ($s === null) {
// Close non-requests
if ($m != null) $m->__destruct();
echo "State service not running, cannot retrieve state report.";
}
else
{
// Close non-requests
if ($s != null) $s->__destruct();
if ($m != null) $m->__destruct();
$portsets = $psmconfig->getPortSets();
echo count($portsets)." portsets
";
foreach ($portsets as $setid => $portset) {
tableStates(PSM_getStateService()->getState($portset->getPorts()), $setid);
}
$portMonitor = $psmconfig->getPortMonitorService();
if ($portMonitor > 0) {
tableStates(PSM_getStateService()->getState($a = array($portMonitor)), "Monitor service");
}
$portState = $psmconfig->getPortStateService();
if ($portState > 0) {
tableStates(PSM_getStateService()->getState($a = array($portState)), "State service");
}
}
function tableStates($states, $title) {
echo "$title
";
echo "";
// Header
tableRow(PSMObjectState::getDisplayTitles(), "font-weight:800");
// Rows
foreach ($states as $port => $state)
tableRow($state->getDisplayFields(),"", formatFields);
echo "
";
}
function formatFields($column, $field) {
$result = $field;
if ($column == 9) {
$result = "";
$entries = explode("*", $field);
foreach ($entries as $index => $part) {
$slash = false;
$slash = strrpos($part, "\\");
if ($slash === false)
$slash = strrpos($part, "/");
if (!($slash === false))
$part = substr($part, $slash + 1, 255);
$result.= "$part".($index < (count($entries)-1) ? "," :"");
}
}
return $result;
}
function tableRow($arrayValues, $style, $columnCallback = null) {
echo "";
foreach ($arrayValues as $column => $field) {
if ($columnCallback != null) {
$field = $columnCallback($column, $field);
}
echo "| ";
echo $field;
echo " | ";
}
echo "
";
}
?>