objectID = $identifier; $this->type = $type; // Okay, we need to get the name switch($type) { case SV_NAVNODE_HOSTGROUP_CONTAINER: $parameter = "Hostgroups"; break; default: $parameter = $identifier; break; } parent::__construct($parameter); $this->addExpandListener("expand", $this, "expandHandle"); $this->addActionListener("click", $this); $this->timer = new GuavaTimer(0, 5, $this, "refresh"); } public function unregister() { parent::unregister(); $this->timer->disable(); } private function addNavNodeProperties($navNode) { $navNode->setExpandable(true); } public function setObjectID($objectID) { $this->objectID = $objectID; } public function actionPerformed($event) { // the only action that we're looking for at this point is "click" if ($this->isExpanded()) $this->Collapse(); else $this->Expand(); } public function expandHandle($guavaObject, $parameter = null) { global $foundationDB; switch($this->type) { case SV_NAVNODE_HOSTGROUP_CONTAINER: $tempHostGroupQuery = new CollageHostGroupQuery($foundationDB); $tempHostQuery = new CollageHostQuery($foundationDB); $hostgroupList = $tempHostGroupQuery->getHostgroups(); if(count($hostgroupList)) { foreach($hostgroupList as $hostgroup) { $tempNavNode = new SVNavNode(SV_NAVNODE_HOSTGROUP, $hostgroup['Name']); $tempNavNode->updateImage(GUAVA_WS_ROOT . "packages/sv/images/servergroup.gif"); $tempNavNode->setExpandable(true); foreach($this->clickListeners as $listener) { $tempNavNode->addClickListener($listener['name'], $listener['object'], $listener['method'], "hostgroup.". $hostgroup['Name']); } $guavaObject->addNode($tempNavNode); } } break; case SV_NAVNODE_HOSTGROUP: // We're a hostgroup, so let's create our two navnodes for hosts and reports $guavaObject->removeChildren(); $tempNavNode = new SVNavNode(SV_NAVNODE_HOST_CONTAINER, "Hosts"); $tempNavNode->setObjectID($this->objectID); $tempNavNode->setExpandable(true); $tempNavNode->addCollapseListener("collapse", $this, "collapseHandler"); foreach($this->clickListeners as $listener) { $tempNavNode->addClickListener($listener['name'], $listener['object'], $listener['method'], "hosts.". $this->objectID); } $guavaObject->addNode($tempNavNode); break; case SV_NAVNODE_HOST_CONTAINER: // We're at a hostgroup host level, so let's create our list of hosts // We're so far using foundation, so we're gonna stick with that. :) $tempHostGroupQuery = new CollageHostGroupQuery($foundationDB); $tempHostQuery = new CollageHostQuery($foundationDB); $tempMemberList = $tempHostGroupQuery->getHostsForHostGroup($this->objectID); if(count($tempMemberList)) { foreach($tempMemberList as $member) { $tempHostInfo = $tempHostQuery->getHostByID($member['HostID']); $tempNavNode = new SVNavNode(SV_NAVNODE_HOST, $tempHostInfo['HostName']); $tempNavNode->updateImage(GUAVA_WS_ROOT . "packages/sv/images/server-blue.gif"); $tempNavNode->setExpandable(true); $tempNavNode->addCollapseListener("collapse", $this, "collapseHandler"); foreach($this->clickListeners as $listener) { $tempNavNode->addClickListener($listener['name'], $listener['object'], $listener['method'], "host.". $tempHostInfo['HostName']); } $guavaObject->addNode($tempNavNode); } } break; case SV_NAVNODE_HOST: // We're at host level, so let's create our two navnodes for services and reports // We're a hostgroup, so let's create our two navnodes for hosts and reports $guavaObject->removeChildren(); $tempNavNode = new SVNavNode(SV_NAVNODE_SERVICES_CONTAINER, "Services"); $tempNavNode->setExpandable(true); $tempNavNode->setObjectID($this->objectID); $tempNavNode->addCollapseListener("collapse", $this, "collapseHandler"); foreach($this->clickListeners as $listener) { $tempNavNode->addClickListener($listener['name'], $listener['object'], $listener['method'], "services.". $this->objectID); } $guavaObject->addNode($tempNavNode); break; case SV_NAVNODE_SERVICES_CONTAINER: // We are at host service lists, so let's create our list of services $tempHostQuery = new CollageHostQuery($foundationDB); $tempServiceQuery = new CollageServiceQuery($foundationDB); $tempServiceList = $tempHostQuery->getServicesForHost($this->objectID); if(count($tempServiceList)) { foreach($tempServiceList as $member) { $tempServiceInfo = $tempServiceQuery->getServiceByStatusID($member['ServiceStatusID']); $tempNavNode = new SVNavNode(SV_NAVNODE_SERVICE, $tempServiceInfo['ServiceDescription']); $tempNavNode->setObjectID($member['ServiceStatusID']); $tempNavNode->updateImage(GUAVA_WS_ROOT . "packages/sv/images/service-blue.gif"); $tempNavNode->addCollapseListener("collapse", $this, "collapseHandler"); foreach($this->clickListeners as $listener) { $tempNavNode->addClickListener($listener['name'], $listener['object'], $listener['method'], "service.". $member['ServiceStatusID']); } $guavaObject->addNode($tempNavNode); } } break; case SV_NAVNODE_TROUBLED_HOSTS_CONTAINER: // create a list of troubled hosts from the Foundation DB $filterObject = new CollageFilter(); $hostQuery = new CollageHostQuery($foundationDB); $okID = $hostQuery->getMonitorStatusID('OK'); $upID = $hostQuery->getMonitorStatusID('UP'); $filterObject->setFilter('MonitorStatusID','<>', $okID['MonitorStatusID']); $filterObject2 = new CollageFilter(); $filterObject2->setFilter('MonitorStatusID','<>', $upID['MonitorStatusID']); $operation = new CollageFilter(); $operation->setOperation('AND', $filterObject, $filterObject2); // get the list of hosts $hostList = $hostQuery->getHostsByFilter($operation); if (count($hostList)) { foreach($hostList as $host) { // We need to get the name for this host $tempHost = $hostQuery->getHostByID($host['HostStatusID']); $tempNavNode = new SVNavNode(SV_NAVNODE_HOST, $tempHost['HostName']); $tempNavNode->setObjectID($tempHost['HostName']); $tempNavNode->updateImage(GUAVA_WS_ROOT . "packages/sv/images/server-blue.gif"); $tempNavNode->addCollapseListener("collapse", $this, "collapseHandler"); foreach($this->clickListeners as $listener) { $tempNavNode->addClickListener($listener['name'], $listener['object'], $listener['method'], "host.". $tempHost['HostName']); } $guavaObject->addNode($tempNavNode); } } break; case SV_NAVNODE_TROUBLED_SERVICES_CONTAINER: // create a list of troubled hosts from the Foundation DB $filterObject = new CollageFilter(); $serviceQuery = new CollageServiceQuery($foundationDB); $okID = $serviceQuery->getMonitorStatusID('OK'); $upID = $serviceQuery->getMonitorStatusID('UP'); $filterObject->setFilter('MonitorStatusID','<>', $okID['MonitorStatusID']); $filterObject2 = new CollageFilter(); $filterObject2->setFilter('MonitorStatusID','<>', $upID['MonitorStatusID']); $operation = new CollageFilter(); $operation->setOperation('AND', $filterObject, $filterObject2); // get the list of hosts $serviceList = $serviceQuery->getServicesByFilter($operation); if (count($serviceList)) { foreach($serviceList as $service) { $tempServiceInfo = $serviceQuery->getServiceByStatusID($service['ServiceStatusID']); $hostQuery = new CollageHostQuery($foundationDB); $tempHost = $hostQuery->getHostByID($tempServiceInfo['HostID']); $tempNavNode = new SVNavNode(SV_NAVNODE_SERVICE, $tempServiceInfo['ServiceDescription'] . " on " . $tempHost['HostName']); $tempNavNode->setObjectID($service['ServiceStatusID']); $tempNavNode->updateImage(GUAVA_WS_ROOT . "packages/sv/images/service-blue.gif"); $tempNavNode->addCollapseListener("collapse", $this, "collapseHandler"); foreach($this->clickListeners as $listener) { $tempNavNode->addClickListener($listener['name'], $listener['object'], $listener['method'], "service.". $service['ServiceStatusID']); } $guavaObject->addNode($tempNavNode); } } break; } } public function collapseHandler($guavaObject, $parameterList=null) { $guavaObject->removeChildren(); } public function refresh() { global $foundationDB; // Based on what the TYPE is, update the icon, by using updateImage(imageurl). /* Hosts: server-green.gif server-yellow.gif server-red.gif Services: service-green.gif service-yellow.gif service-red.gif Hostgroups: servergroup-red.gif servergroup-green.gif servergroup-red.gif For example: $this->updateImage('images/server-green.gif'); */ switch ($this->type) { case SV_NAVNODE_HOSTGROUP: $hostGroupQuery = new CollageHostGroupQuery($foundationDB); $hostGroup = $hostGroupQuery->getHostGroup($this->objectID); $downID = $hostGroupQuery->getMonitorStatusID('DOWN'); $unreachableID = $hostGroupQuery->getMonitorStatusID('UNREACHABLE'); $criticalID = $hostGroupQuery->getMonitorStatusID('CRITICAL'); $unknownID = $hostGroupQuery->getMonitorStatusID('UNKNOWN'); $pendingID = $hostGroupQuery->getMonitorStatusID('PENDING'); $warningID = $hostGroupQuery->getMonitorStatusID('WARNING'); if($hostGroup) { $redQuery = "SELECT count(*) AS count FROM HostStatus WHERE HostStatus.HostStatusID IN (SELECT HostID FROM HostGroupCollection WHERE HostGroupID = ".$hostGroup['HostGroupID'].") AND (MonitorStatusID = ".$downID['MonitorStatusID']." OR MonitorStatusID = '".$criticalID['MonitorStatusID']."' OR MonitorStatusID = '".$unreachableID['MonitorStatusID']."')"; $blueQuery = "SELECT count(*) AS count FROM HostStatus WHERE HostStatus.HostStatusID IN (SELECT HostID FROM HostGroupCollection WHERE HostGroupID = ".$hostGroup['HostGroupID'].") AND MonitorStatusID = '".$unknownID['MonitorStatusID']."'"; $yellowQuery = "SELECT count(*) AS count FROM HostStatus WHERE HostStatus.HostStatusID IN (SELECT HostID FROM HostGroupCollection WHERE HostGroupID = ".$hostGroup['HostGroupID'].") AND (MonitorStatusID = '".$warningID['MonitorStatusID']."' OR MonitorStatusID = '".$pendingID['MonitorStatusID']."')"; @$redResult = $foundationDB->selectQuery($redQuery); @$blueResult = $foundationDB->selectQuery($blueQuery); @$yellowResult = $foundationDB->selectQuery($yellowQuery); if ($redResult[0]['count']) $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/servergroup-red.gif'); else if ($blueResult[0]['count']) $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/servergroup-blue.gif'); else if ($yellowResult[0]['count']) $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/servergroup-yellow.gif'); else $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/servergroup-green.gif'); } else { $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/servergroup-blue.gif'); } break; case SV_NAVNODE_HOST: $hostQuery = new CollageHostQuery($foundationDB); $host = $hostQuery->getHostStatusForHost($this->objectID); $status = $hostQuery->getMonitorStatus($host['MonitorStatusID']); switch ($status['Name']) { case 'CRITICAL': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-red.gif'); break; case 'OK': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-green.gif'); break; case 'UP': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-green.gif'); break; case 'UNKNOWN': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-blue.gif'); break; case 'DOWN': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-red.gif'); break; case 'UNREACHABLE': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-red.gif'); break; case 'WARNING': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-yellow.gif'); break; case 'PENDING': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-yellow.gif'); break; default: $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-green.gif'); break; } break; case SV_NAVNODE_SERVICE: $serviceQuery = new CollageServiceQuery($foundationDB); $service = $serviceQuery->getServiceByStatusID($this->objectID); $status = $serviceQuery->getMonitorStatus($service['MonitorStatusID']); switch ($status['Name']) { case 'CRITICAL': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/service-red.gif'); break; case 'OK': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/service-green.gif'); break; case 'UP': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/server-green.gif'); break; case 'UNKNOWN': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/service-blue.gif'); break; case 'DOWN': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/service-red.gif'); break; case 'UNREACHABLE': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/service-red.gif'); break; case 'WARNING': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/service-yellow.gif'); break; case 'PENDING': $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/service-yellow.gif'); break; default: $this->updateImage(GUAVA_WS_ROOT . 'packages/sv/images/service-green.gif'); break; } break; } parent::refresh(); } } class HostGroupContainer extends Container { private $componentList; public function __construct($header, $componentList, $initialState = false) { // Copy the component list over $this->componentList = $componentList; $this->numOfMembers = count($this->componentList); parent::__construct($header, $initialState); $this->update(); } public function createComponents($startRange, $endRange) { // We now need to create the components and add them to our children list $this->removeChildren(); // Let's get rid of the children // We're going to IGNORE ranges for now if(count($this->componentList)) { foreach($this->componentList as $component) { $tempComponent = new HostGroupComponent($component, false); $this->addChild($tempComponent); } } } public function add_id($object_id) { $foundFlag = false; if(count($this->componentList)) { foreach($this->componentList as $component) { if($component == $object_id) { $foundFlag = 1; break; } } } if(!$foundFlag) { $this->componentList[] = $object_id; } } public function getComponentIDs() { if (count($this->componentList)) { return $this->componentList; } return null; } public function unregister() { parent::unregister(); $this->componentList = null; } } class HostContainer extends Container { private $componentList; public function __construct($header, $componentList, $initialState = false) { // Copy the component list over $this->componentList = $componentList; $this->numOfMembers = count($this->componentList); parent::__construct($header, $initialState); $this->update(); } public function unregister() { parent::unregister(); $this->componentList = null; } public function createComponents($startRange, $endRange) { // We now need to create the components and add them to our children list $this->removeChildren(); // Let's get rid of the children if(count($this->componentList)) { foreach($this->componentList as $component) { $tempComponent = new HostComponent($component['object_id'], false); $this->addChild($tempComponent); } } } public function add_id($object_id) { $foundFlag = false; if(count($this->componentList)) { foreach($this->componentList as $component) { if($component['object_id'] == $object_id) { $foundFlag = 1; break; } } } if(!$foundFlag) { $this->componentList[] = array("object_id" => $object_id, "initialState" => false); } } public function getComponentIDs() { if (count($this->componentList)) { return $this->componentList; } return null; } } class ServiceContainer extends Container { private $componentList; public function __construct($header, $componentList, $initialState = false) { // Copy the component list over $this->componentList = $componentList; $this->numOfMembers = count($this->componentList); parent::__construct($header, $initialState); } public function unregister() { parent::unregister(); } public function createComponents($startRange, $endRange) { // We now need to create the components and add them to our children list $this->removeChildren(); // Let's get rid of the children if(count($this->componentList)) { foreach($this->componentList as $component) { $tempComponent = new ServiceComponent($component['object_id'], false); $this->addChild($tempComponent); } } } public function add_id($object_id) { $foundFlag = false; if(count($this->componentList)) { foreach($this->componentList as $component) { if($component['object_id'] == $object_id) { $foundFlag = 1; break; } } } if(!$foundFlag) { $this->componentList[] = array("object_id" => $object_id, "initialState" => false); } } public function getComponentIDs() { if (count($this->componentList)) { return $this->componentList; } return null; } } class HostGroupComponent extends Component { private $configInfo; private $memberHostIDs; private $memberSubQuery; private $downQuery; private $unreachableQuery; private $unreachableHosts; private $object_id; private $downHosts; private $containerSetup; private $commandSelect; private $commandForm; private $submitButton; private $extensions; private $myTimer; function __construct($object_id, $initialState = false) { global $foundationDB; global $sv; // Assign our properties $this->object_id = $object_id; $this->componentName = "hostgroup"; $this->statusimage = GUAVA_WS_ROOT . 'packages/sv/images/servergroup.gif'; $this->configInfo = array(); $this->containerSetup = array(); // We need to get our configuration information $tempHostGroupQuery = new CollageHostGroupQuery($foundationDB); $tempHostQuery = new CollageHostQuery($foundationDB); $hgInfo = $tempHostGroupQuery->getHostGroup($object_id); $this->configInfo['hostgroup_name'] = $hgInfo['Name']; //print_r($hgInfo); $this->configInfo['alias'] = $hgInfo['Description']; $tempMemberList = $tempHostGroupQuery->getHostsForHostGroup($object_id); if(count($tempMemberList)) { foreach($tempMemberList as $member) { $tempHostInfo = $tempHostQuery->getHostByID($member['HostID']); $this->configInfo['members'][] = $tempHostInfo['HostName']; $this->containerSetup[] = array("object_id" => $tempHostInfo['HostName'], "initialState" => false); } } // We're now getting our queries to find out what's effected in Foundation regarding this hostgroup $tempQuery = new CollageHostQuery($foundationDB); if(count($this->configInfo['members'])) { foreach($this->configInfo['members'] as $member) { $tempHostInfo = $tempQuery->getHost($member); $this->memberHostIDs[] = $tempHostInfo['HostID']; if(isset($this->memberSubQuery)) { $this->memberSubQuery .= "OR HostStatusID = ".$tempHostInfo['HostID'] ." "; } else { $this->memberSubQuery .= "HostStatusID = ".$tempHostInfo['HostID'] ." "; } } $this->downQuery = "SELECT count(*) FROM HostStatus WHERE (".$this->memberSubQuery .") AND MonitorStatusID = '2'"; $this->unreachableQuery = "SELECT count(*) FROM HostStatus WHERE (".$this->memberSubQuery .") AND MonitorStatusID = '3'"; } $this->shortname = $this->configInfo['hostgroup_name']; parent::__construct($initialState); // Get list of extensions $this->extensions = $sv->getExtensions($this->componentName); $this->update(); $this->myTimer = new GuavaTimer(0, 1, $this, "update"); $this->commandForm = new Form(); $this->commandSelect = new InputSelect(); $this->submitButton = new SubmitButton("Process"); $this->commandSelect->addOption(CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME, "Schedule Downtime For All Hosts"); $this->commandSelect->addOption(CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME, "Schedule Downtime For All Services"); $this->commandSelect->addOption(CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS, "Enable notifications for all Hosts"); $this->commandSelect->addOption(CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS, "Disable notifications for all Hosts"); $this->commandSelect->addOption(CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS, "Enable notifications for all Services"); $this->commandSelect->addOption(CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS, "Disable notifications for all Services"); $this->commandSelect->addOption(CMD_ENABLE_HOSTGROUP_SVC_CHECKS, "Enable checks for all Services"); $this->commandSelect->addOption(CMD_DISABLE_HOSTGROUP_SVC_CHECKS, "Disable checks for all Services"); $this->commandForm->addListener("process", $this, "formHandle"); } public function getConfigInfo($config_name) { if(isset($this->configInfo[$config_name])) { return $this->configInfo[$config_name]; } else { return false; } } public function unregister() { parent::unregister(); $this->myTimer->disable(); if(isset($this->commandForm)) { $this->commandForm->unregister(); } if(isset($this->commandSelect)) { $this->commandSelect->unregister(); } if(isset($this->submitButton)) { $this->submitButton->unregister(); } } function expand() { // Let's create our host container $hostContainer = new HostContainer("Hosts", $this->containerSetup, false); // Let's assign this container to our list $this->addContainer($hostContainer); if(count($this->extensions)) { foreach($this->extensions as $extension) { $tempContainer = new $extension['modname']($extension['description']); $tempContainer->setParent($this); $this->addContainer($tempContainer); } } $this->expanded = true; } function update() { global $foundationDB; // Down Query if($this->downQuery <> "") { $downResult = $foundationDB->selectQuery($this->downQuery); $unreachableResult = $foundationDB->selectQuery($this->unreachableQuery); $this->downHosts = $downResult[0]['count(*)']; $this->unreachableHosts = $unreachableResult[0]['count(*)']; } else { $this->downHosts = 0; $this->unreachableHosts = 0; } // Titlebar Content $titleBarContent = << END; if ($this->configInfo['alias'] != null) { $titleBarContent .= $this->configInfo['hostgroup_name'] . ": ".$this->configInfo['alias']; } else { $titleBarContent .= $this->configInfo['hostgroup_name']; } $titleBarContent .= ""; if($this->unreachableHosts) { $titleBarContent .= " "; $titleBarContent .= (int)$this->unreachableHosts ."/".count($this->configInfo['members']) ." Unreachable "; $titleBarContent .= ""; } if($this->downHosts) { $titleBarContent .= " "; $titleBarContent .= (int)$this->downHosts . "/" . count($this->configInfo['members']) . " Down "; $titleBarContent .= ""; } $titleBarContent .= ""; $this->targetData("titlebar", $titleBarContent); $this->targetData("members", count($this->configInfo['members'])); $this->targetData("downhosts", (int)$this->downHosts); $this->targetData("unreachablehosts", (int)$this->unreachableHosts); $this->targetData("uphosts", (count($this->configInfo['members']) - $this->downHosts - $this->unreachableHosts)); parent::update(); } function formHandle($guavaObject, $parameter = null) { global $guava; // Our form handler // Okay, we were activated to the command form $tempValue = $this->commandSelect->getValue(); // Okay, we've got our value. Let's create our command component, and set it up $tempComponent = new CommandComponent($tempValue, false); $tempComponent->addPreset('hostgroup_name', $this->object_id); // Let's create a message $tempComponent->Expand(); $guava->objectView($tempComponent); } function display() { ?>
images/servergroup.gif" alt="" /> commandForm->Open(); $this->commandSelect->Draw(); $this->submitButton->Draw(); $this->commandForm->Close(); ?>
Number of Hosts: printTarget("members", 1);?> Number Of Hosts In Unreachable State: printTarget("unreachablehosts", 1);?>
Number Of Hosts In Down State: printTarget("downhosts", 1);?> Number Of Hosts In Up State: printTarget("uphosts", 1);?>
object_id, false); // Why not return $newComponent; } function titlebar() { ?>printTarget("titlebar");?> configInfo['members'])) { return true; } else { return false; } } } class HostComponent extends Component { private $configInfo; private $services; private $commentFlag; private $alias; private $object_id; // To match against QOLT variable private $containerSetup; private $informationToggle; private $isInformationToggled; private $commandSelect; private $commandForm; private $submitButton; private $extensions; private $checkToggle; private $commentAddLink; private $commentLinks; private $myTimer; function __construct($object_id, $initialState = false) { global $guava; global $sv; global $foundationDB; $this->object_id = $object_id; $this->commandSelect = new InputSelect(); $this->checkToggle = null; $this->informationToggle = new Button("Show More Information"); $this->informationToggle->addClickListener("infotoggle", $this, "toggleInformation"); $this->isInformationToggled = false; $this->services = array(); $this->containerSetup = array(); $tempHostQuery = new CollageHostQuery($foundationDB); //$tempServiceQuery = new CollageServiceQuery($foundationDB); $tempHostInfo = $tempHostQuery->getHost($object_id); $this->configInfo['host_name'] = $tempHostInfo['HostName']; $this->configInfo['alias'] = $tempHostInfo['Description']; $tempDeviceInfo = $tempHostQuery->getDevice($tempHostInfo['DeviceID']); $this->configInfo['address'] = $tempDeviceInfo[0]['Identification']; $tempServicesList = $tempHostQuery->getServiceIDsForHost($tempHostInfo['HostID']); if(count($tempServicesList)) { foreach($tempServicesList as $service) { //$tempServiceInfo = $tempServiceQuery->getServiceByStatusID($service['ServiceStatusID']); $this->services[] = $service['ServiceStatusID']; $this->containerSetup[] = array("object_id" => $service['ServiceStatusID'], "initialState" => false); } } $this->alias = $this->configInfo['alias']; $this->componentName = "host"; $this->numOfMembers = count($this->services); $this->shortname = $this->configInfo['host_name']; $this->alias = $this->configInfo['alias']; $this->statusimage = GUAVA_WS_ROOT . 'packages/sv/images/server.gif'; $this->subItemHeader = "Services"; // Get list of extensions $this->extensions = $sv->getExtensions($this->componentName); parent::__construct($initialState); if($this->isExpanded()) $this->expand(); $this->update(); $this->myTimer = new GuavaTimer(0, 1, $this, "update"); $this->commandForm = new Form(); $this->submitButton = new SubmitButton("Process"); $this->commandForm->addListener("process", $this, "formHandle"); $this->commentAddLink = new TextLink("Add A New Host Comment"); $this->commentAddLink->AddClickListener("add", $this, "commentAddClickHandler"); } public function getConfigInfo($config_name) { if(isset($this->configInfo[$config_name])) { return $this->configInfo[$config_name]; } else { return false; } } function unregister() { parent::unregister(); if(isset($this->commandSelect)) $this->commandSelect->unregister(); $this->commandSelect = null; if(isset($this->commandForm)) $this->commandForm->unregister(); $this->commandForm = null; if(isset($this->submitButton)) $this->submitButton->unregister(); $this->submitButton = null; if(isset($this->myTimer)) $this->myTimer->disable(); if(is_array($this->commentLinks)) { foreach($this->commentLinks as $link) { $link->unregister(); } } $this->commentAddLink->unregister(); $this->informationToggle->unregister(); } function formHandle($guavaObject, $parameter = null) { global $guava; // Our form handler // Okay, we were activated to the command form $tempValue = $this->commandSelect->getValue(); // Okay, we've got our value. Let's create our command component, and set it up $tempComponent = new CommandComponent($tempValue, true); $tempComponent->addPreset('host_name', $this->object_id); // Let's create a message $tempComponent->expand(); $guava->objectView($tempComponent); } function commentAddClickHandler($guavaObject, $parameter = null) { global $guava; // Let's create our command component and set it up $tempComponent = new CommandComponent(CMD_ADD_HOST_COMMENT, true); $tempComponent->addPreset('host_name', $this->object_id); // Let's create a message $tempComponent->expand(); $guava->objectView($tempComponent); } public function commentDeleteHandler($guavaObject, $parameter = null) { global $guava; // Let's create our command component and set it up $tempComponent = new CommandComponent(CMD_DEL_HOST_COMMENT, true); $tempComponent->addPreset('comment_id', $parameter); // Let's create a message $tempComponent->expand(); $guava->objectView($tempComponent); } function expand() { // Let's create our service container $serviceContainer = new ServiceContainer("Services", $this->containerSetup, false); // Let's assign this container to our list $this->addContainer($serviceContainer); if(!$this->isInformationToggled) { $this->informationToggle->setLabel("Show More Information"); ob_start(); $this->informationToggle->Draw(); $buttonOutput = ob_get_contents(); ob_end_clean(); $this->targetData("information", $buttonOutput); } if(count($this->extensions)) { foreach($this->extensions as $extension) { $tempContainer = new $extension['modname']($extension['description']); $tempContainer->setParent($this); $this->addContainer($tempContainer); } } $this->expanded = true; } function toggleInformation() { if($this->isInformationToggled == true) { /* $this->removeTarget("laststatuscheck"); $this->removeTarget("laststatuscheck"); $this->removeTarget("statusdataage"); $this->removeTarget("monitorstatusname"); $this->removeTarget("laststatechange"); $this->removeTarget("statusinfo"); */ $this->isInformationToggled = false; $this->informationToggle->setLabel("Show More Information"); ob_start(); $this->informationToggle->Draw(); $buttonOutput = ob_get_contents(); ob_end_clean(); $this->targetData("information", $buttonOutput); } else { $this->isInformationToggled = true; $this->update(); ob_start(); ?>
State Duration:
printTarget("currentstateduration", 1);?>
Percent State Change: printTarget("percentstatechange", 1);?>
Last Notification:
printTarget("lastnotification", 1);?>
Current Notification Number: printTarget("currentnotificationnumber", 1);?>
Is Host Flapping: printTarget("ishostflapping", 1);?>  

commentAddLink->Draw(); $this->updateComments(); $this->printTarget("commentData"); ?>

informationToggle->setLabel("Hide Information"); $this->informationToggle->Draw(); $output = ob_get_contents(); ob_end_clean(); $this->targetData("information", $output); } } function componentClone() { $newComponent = new HostComponent($this->object_id, false); // Why not $newComponent->toggleInformation(); return $newComponent; } function display() { global $comment_data; ?>
configInfo['host_name']]['icon_image'])) { ?> <?=$_SESSION['hostextinfo'][$this->configInfo['host_name']]['icon_image_alt'];?> images/server.gif" alt="" /> commandForm->Open(); ?>
printTarget("commandSelect");?> submitButton->Draw();?>
commandForm->Close(); if($this->statusInfo != NULL) { ?>
Host Status: printTarget("monitorstatusname", 1);?>
Since: printTarget("laststatechange", 1);?>
Status Information:
printTarget("statusinfo", 1);?>
Last Status Check:
printTarget("laststatuscheck", 1);?>
Status Data Age:
printTarget("statusdataage", 1);?>
Identification: configInfo['address'];?>  
No Status Information Available
printTarget("information"); ?>
printTarget("titlebar");?> identifier) { // Hey, it's me! if(isset($_GET['comments'])) { $this->commentFlag = $_GET['comments']; } } parent::parseAction(); } function update() { global $foundationDB; global $sv; $tempHostQuery = new CollageHostQuery($foundationDB); $this->statusInfo = $tempHostQuery->getHostStatusForHost($this->shortname); if($this->statusInfo != NULL) { $this->monitorStatus = $tempHostQuery->getMonitorStatus($this->statusInfo['MonitorStatusID']); $this->statusFlag = true; } else { $this->statusFlag = false; } // Content Data if($this->statusFlag == true) { // Calculate Status Data Age if($this->statusInfo['LastCheckTime']) { $lastTimestamp = strtotime($this->statusInfo['LastCheckTime']); } $currentTime = time(); $timeDifference = $currentTime - $lastTimestamp; // Then we have data $this->targetData("laststatuscheck", $this->statusInfo['LastCheckTime']); $sv->get_time_breakdown($timeDifference, $days, $hours, $minutes, $seconds); $this->targetData("statusdataage", $days."d ".$hours."h ".$minutes."m ".$seconds."s"); $this->targetData("monitorstatusname", $this->monitorStatus['Name']); $this->targetData("laststatechange", $this->statusInfo['LastStateChange']); $this->targetData("statusinfo", $this->statusInfo['LastPluginOutput']); } if($this->statusFlag && $this->isInformationToggled) { $currentTime = time(); $laststatechange = strtotime($this->statusInfo['LastStateChange']); $timedifference = $currentTime - $laststatechange; $sv->get_time_breakdown($timedifference, $days, $hours, $minutes, $seconds); $this->targetData("currentstateduration", $days."d ".$hours."h ".$minutes."m ".$seconds."s"); if($this->statusInfo['LastNotificationTime']) { $this->targetData("lastnotification", $this->statusInfo['LastNotificationTime']); } else { $this->targetData("lastnotification", "Unavailable"); } $this->targetData("currentnotificationnumber", $this->statusInfo['CurrentNotificationNumber']); if($this->statusInfo['isHostFlappingEnabled']) { $this->targetData("ishostflapping", "Yes"); } else { $this->targetData("ishostflapping", "No"); } $this->targetData("percentstatechange", $this->statusInfo['PercentStateChange'] . '%'); } $titleBarContent = << END; if ($this->alias != null) { $titleBarContent .= $this->shortname . ": " . $this->alias; } else { $titleBarContent .= $this->shortname; } $titleBarContent .= << END; // ICONS IN TITLEBAR // DOWNTIME if($this->statusInfo['ScheduledDowntimeDepth']) { $titleBarContent .= "getIdentifier() . "downtimeIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/scheduled_downtime.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Currently In Downtime
This host is currently in ".$this->statusInfo['ScheduledDowntimeDepth']." layer(s) of downtime.');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } // ACTIVE CHECKS if($this->statusInfo['isChecksEnabled']) { $titleBarContent .= "getIdentifier() . "activeChecksIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/activeCheck.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Active Checks
Active Checks Are Currently Enabled');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else { $titleBarContent .= "getIdentifier() . "activeChecksIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/activeCheck-off.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Active Checks
Active Checks Are Currently Disabled');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } // NOTIFICATIONS if($this->statusInfo['isNotificationsEnabled']) { $titleBarContent .= "getIdentifier() . "notificationsIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/notifications.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Notifications
Notifications Are Currently Enabled');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else { $titleBarContent .= "getIdentifier() . "notificationsIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/notifications-off.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Notifications
Notifications Are Currently Disabled');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } // PROBLEM ICONS if($this->monitorStatus['Name'] == 'DOWN' && $this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-red.gif\" width=\"13\" height=\"13\" alt=\"Down\" onmouseover=\"guava.core.Tooltip.tooltip('Host Status
This Host is in a Down State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; if($this->statusInfo['isAcknowledged'] == '1') $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-redyes.gif\" width=\"13\" height=\"13\" alt=\"Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this host has been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; else $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-redno.gif\" width=\"13\" height=\"13\" alt=\"Not Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this host has not been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else if($this->monitorStatus['Name'] == 'UNREACHABLE' && $this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-yellow.gif\" width=\"13\" height=\"13\" alt=\"Unreachable\" onmouseover=\"guava.core.Tooltip.tooltip('Host Status
This Host is in an Unreachable State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; if($this->statusInfo['isAcknowledged'] == '1') $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-yellowyes.gif\" width=\"13\" height=\"13\" alt=\"Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this host has been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; else $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-yellowno.gif\" width=\"13\" height=\"13\" alt=\"Not Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this host has not been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else if($this->monitorStatus['Name'] == 'PENDING' && $this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-gray.gif\" width=\"11\" height=\"11\" alt=\"Pending\" onmouseover=\"guava.core.Tooltip.tooltip('Host Status
This Host is in a Pending State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; $titleBarContent .= "\"\"  "; } else if($this->monitorStatus['Name'] == 'UP' && $this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-green.gif\" width=\"13\" height=\"13\" alt=\"Up\" onmouseover=\"guava.core.Tooltip.tooltip('Host Status
This Host is in an Up State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; $titleBarContent .= "\"\"  "; } // PLUGIN OUTPUT $titleBarContent .= "getIdentifier() . "outputIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/text-purple.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Status Information
".htmlentities($this->statusInfo['LastPluginOutput'])."');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; $titleBarContent .= << END; $this->targetData("titlebar", $titleBarContent); if($this->isInformationToggled) { // We need to re-read comment data and update the area $this->updateComments(); } if($this->checkToggle == null || ($this->checkToggle != null && ($this->checkToggle != $this->statusInfo['isChecksEnabled']))) { $this->checkToggle = $this->statusInfo['isChecksEnabled']; $this->commandSelect->removeAll(); if($this->statusInfo['isChecksEnabled']) { $this->commandSelect->addOption(CMD_DISABLE_HOST_CHECK, "Disable Checks On This Host"); $this->commandSelect->addOption(CMD_SCHEDULE_HOST_CHECK, "Re-Schedule the Next Check"); } else { $this->commandSelect->addOption(CMD_ENABLE_HOST_CHECK, "Enable Checks On This Host"); } $this->commandSelect->addOption(CMD_SCHEDULE_HOST_SVC_CHECKS, "Schedule Check For All Services Of This Host"); $this->commandSelect->addOption(CMD_PROCESS_HOST_CHECK_RESULT, "Submit Passive Check Result"); $this->commandSelect->addOption(CMD_ENABLE_PASSIVE_HOST_CHECKS, "Enable Passive Checks"); $this->commandSelect->addOption(CMD_DISABLE_PASSIVE_HOST_CHECKS, "Disable Passive Checks"); $this->commandSelect->addOption(CMD_START_OBSESSING_OVER_HOST, "Start Obsessing Over This Host"); $this->commandSelect->addOption(CMD_STOP_OBSESSING_OVER_HOST, "Stop Obsessing Over This Host"); $this->commandSelect->addOption(CMD_ENABLE_HOST_EVENT_HANDLER, "Enable Event Handler"); $this->commandSelect->addOption(CMD_DISABLE_HOST_EVENT_HANDLER, "Disable Event Handler"); $this->commandSelect->addOption(CMD_ACKNOWLEDGE_HOST_PROBLEM, "Acknowledge This Host Problem"); $this->commandSelect->addOption(CMD_REMOVE_HOST_ACKNOWLEDGEMENT, "Remove Acknowledgement of Problem"); $this->commandSelect->addOption(CMD_DISABLE_HOST_NOTIFICATIONS, "Disable Notifications"); $this->commandSelect->addOption(CMD_ENABLE_HOST_NOTIFICATIONS, "Enable Notifications"); $this->commandSelect->addOption(CMD_DELAY_HOST_NOTIFICATION, "Delay next Notification"); $this->commandSelect->addOption(CMD_ENABLE_HOST_FLAP_DETECTION, "Enable Flap Detection"); $this->commandSelect->addOption(CMD_DISABLE_HOST_FLAP_DETECTION, "Disable Flap Detection"); $this->commandSelect->addOption(CMD_SCHEDULE_HOST_DOWNTIME, "Schedule Downtime"); $this->commandSelect->addOption(CMD_DISABLE_HOST_SVC_NOTIFICATIONS, "Disable Notifications for All Services on Host"); $this->commandSelect->addOption(CMD_ENABLE_HOST_SVC_NOTIFICATIONS, "Enable Notifications for All Services on Host"); $this->commandSelect->addOption(CMD_DISABLE_HOST_SVC_CHECKS, "Disable Active Checks for All Services on Host"); $this->commandSelect->addOption(CMD_ENABLE_HOST_SVC_CHECKS, "Enable Active Checks for All Services on Host"); $this->targetData("commandSelect", $this->commandSelect); } parent::update(); } public function updateComments() { global $sv; // Remove old comment links if(count($this->commentLinks)) { foreach($this->commentLinks as $link) { $link->Destroy(); } } ob_start(); $this->commentLinks = null; $sv->read_comment_data($comment_data); $foundFlag = 0; if(count($comment_data)) { foreach($comment_data as $comment) { if($comment['host_name'] == $this->configInfo['host_name'] && !isset($comment['service_description'])) { // Create the link $tempCommentLink = new TextLink("DELETE"); $tempCommentLink->addClickListener("delete", $this, "commentDeleteHandler", $comment['comment_id']); $this->commentLinks[] = $tempCommentLink; if(!$foundFlag) { ?>
Entry Time Author Comment Persistent  
stringTime($comment['entry_time']);?> Draw(); ?>

There Are No Comments For This Host targetData("commentData", $buffer); } function getHostName() { return $this->shortname; } } class ServiceComponent extends Component { private $configInfo; private $commentFlag; private $object_id; private $informationToggle; private $isInformationToggled; private $commandSelect; private $commandForm; private $submitButton; private $commentAddLink; private $extensions; private $commentLinks; private $checkToggle; private $myTimer; function __construct($object_id, $initialState = false) { global $sv; global $foundationDB; $this->object_id = $object_id; $this->commandSelect = new InputSelect(); $this->checkToggle = null; $tempServiceQuery = new CollageServiceQuery($foundationDB); $tempHostQuery = new CollageHostQuery($foundationDB); $tempServiceInfo = $tempServiceQuery->getServiceByStatusID($object_id); $this->configInfo['service_description'] = $tempServiceInfo['ServiceDescription']; $tempHostInfo = $tempHostQuery->getHostByID($tempServiceInfo['HostID']); $this->configInfo['host_name'] = $tempHostInfo['HostName']; $this->componentName = "service"; // Get list of extensions $this->extensions = $sv->getExtensions($this->componentName); $this->shortname = $this->configInfo['service_description']; $this->statusimage = GUAVA_WS_ROOT . 'packages/sv/images/services.gif'; $this->informationToggle = new Button("Show More Information"); $this->informationToggle->addClickListener("infotoggle", $this, "toggleInformation"); $this->commentFlag = 0; // Do not display comments parent::__construct($initialState); $this->update(); $this->myTimer = new GuavaTimer(0, 1, $this, "update"); $this->commandForm = new Form(); $this->submitButton = new SubmitButton("Process"); $this->commandForm->addListener("process", $this, "formHandle"); $this->commentAddLink = new TextLink("Add A New Service Comment"); $this->commentAddLink->AddClickListener("add", $this, "commentAddClickHandler"); } public function unregister() { parent::unregister(); if(isset($this->commandSelect)) $this->commandSelect->unregister(); $this->commandSelect = null; if(isset($this->commandForm)) $this->commandForm->unregister(); $this->commandForm = null; if(isset($this->submitButton)) $this->submitButton->unregister(); $this->submitButton = null; if(isset($this->myTimer)) $this->myTimer->disable(); if(is_array($this->commentLinks)) { foreach($this->commentLinks as $link) { $link->unregister(); } } $this->commentAddLink->unregister(); $this->informationToggle->unregister(); } public function getConfigInfo($config_name) { if(isset($this->configInfo[$config_name])) { return $this->configInfo[$config_name]; } else { return false; } } function expand() { $this->expanded = true; if(count($this->extensions)) { foreach($this->extensions as $extension) { $tempContainer = new $extension['modname']($extension['description']); $tempContainer->setParent($this); $this->addContainer($tempContainer); } } if(!$this->isInformationToggled) { $this->informationToggle->setLabel("Show More Information"); ob_start(); $this->informationToggle->Draw(); $buttonOutput = ob_get_contents(); ob_end_clean(); $this->targetData("information", $buttonOutput); /* $this->removeTarget("statusdataage"); $this->removeTarget("monitorstatusname"); $this->removeTarget("laststatechange"); $this->removeTarget("statusinfo"); $this->removeTarget("laststatuscheck"); */ } } function formHandle($guavaObject, $parameter = null) { global $guava; global $foundationDB; // Our form handler // Okay, we were activated to the command form $tempValue = $this->commandSelect->getValue(); // Okay, we've got our value. Let's create our command component, and set it up $tempComponent = new CommandComponent($tempValue, true); $tempServiceQuery = new CollageServiceQuery($foundationDB); $tempHostQuery = new CollageHostQuery($foundationDB); $tempServiceInfo = $tempServiceQuery->getServiceByStatusID($this->object_id); $tempHostInfo = $tempHostQuery->getHostByID($tempServiceInfo['HostID']); $tempComponent->addPreset('host_name', $tempHostInfo['HostName']); $tempComponent->addPreset('service_description', $tempServiceInfo['ServiceDescription']); // Let's create a message $tempComponent->expand(); $guava->objectView($tempComponent); } function commentAddClickHandler($guavaObject, $parameter = null) { global $guava; global $foundationDB; // Let's create our command component and set it up $tempComponent = new CommandComponent(CMD_ADD_SVC_COMMENT, true); $tempServiceQuery = new CollageServiceQuery($foundationDB); $tempHostQuery = new CollageHostQuery($foundationDB); $tempServiceInfo = $tempServiceQuery->getServiceByStatusID($this->object_id); $tempHostInfo = $tempHostQuery->getHostByID($tempServiceInfo['HostID']); $tempComponent->addPreset('host_name', $tempHostInfo['HostName']); $tempComponent->addPreset('service_description', $tempServiceInfo['ServiceDescription']); // Let's create a message $tempComponent->expand(); $guava->objectView($tempComponent); } public function commentDeleteHandler($guavaObject, $parameter = null) { global $guava; // Let's create our command component and set it up $tempComponent = new CommandComponent(CMD_DEL_SVC_COMMENT, true); $tempComponent->addPreset('comment_id', $parameter); // Let's create a message $tempComponent->expand(); $guava->objectView($tempComponent); } function toggleInformation() { if($this->isInformationToggled) { $this->removeTarget("statusdataage"); $this->removeTarget("monitorstatusname"); $this->removeTarget("laststatechange"); $this->removeTarget("statusinfo"); $this->removeTarget("laststatuscheck"); $this->isInformationToggled = false; $this->informationToggle->setLabel("Show More Information"); ob_start(); $this->informationToggle->Draw(); $buttonOutput = ob_get_contents(); ob_end_clean(); $this->targetData("information", $buttonOutput); } else { $this->isInformationToggled = true; $this->update(); ob_start(); ?>
State Duration:
printTarget("currentstateduration", 1);?>
Percent State Change: printTarget("percentstatechange", 1);?>
Last Notification:
printTarget("lastnotification", 1);?>
Current Notification Number: printTarget("currentnotificationnumber", 1);?>
Is Service Flapping: printTarget("isserviceflapping", 1);?>  

commentAddLink->Draw(); $this->updateComments(); $this->printTarget("commentData"); ?>

informationToggle->setLabel("Hide Information"); $this->informationToggle->Draw(); $output = ob_get_contents(); ob_end_clean(); $this->targetData("information", $output); } } private function updateComments() { global $sv; $sv->read_comment_data($comment_data); // Let's read comment data (it doesn't get done if called previously) if(count($this->commentLinks)) { foreach($this->commentLinks as $link) { $link->Destroy(); } } $this->commentLinks = null; $foundFlag = 0; ob_start(); if(count($comment_data)) { foreach($comment_data as $comment) { if($comment['host_name'] == $this->configInfo['host_name'] && $comment['service_description'] == $this->configInfo['service_description']) { // Create the link $tempCommentLink = new TextLink("DELETE"); $tempCommentLink->addClickListener("delete", $this, "commentDeleteHandler", $comment['comment_id']); $this->commentLinks[] = $tempCommentLink; if(!$foundFlag) { ?> "); } if(!$foundFlag) { ?>
There Are No Comments For This ServicetargetData("commentData", $buffer); } function componentClone() { $newComponent = new ServiceComponent($this->object_id, false); // Why not $newComponent->toggleInformation(); return $newComponent; } function parseAction() { if($_GET['__componentID'] == $this->getIdentifier()) { // Hey, it's me! if(isset($_GET['comments'])) { $this->commentFlag = $_GET['comments']; } } parent::parseAction(); } function update() { global $foundationDB; global $sv; $tempServiceQuery = new CollageServiceQuery($foundationDB); $this->statusInfo = $tempServiceQuery->getServiceByStatusID($this->object_id); $this->monitorStatus = $tempServiceQuery->getMonitorStatus($this->statusInfo['MonitorStatusID']); if($this->statusInfo != NULL) { $this->statusFlag = true; } else { $this->statusFlag = false; } if($this->statusInfo != NULL) { // Calculate Status Data Age if (!$this->statusInfo['LastCheckTime']) { $lastTimestamp = "Not Yet Checked"; } else { $lastTimestamp = strtotime($this->statusInfo['LastCheckTime']); } $currentTime = time(); $timeDifference = $currentTime - $lastTimestamp; $sv->get_time_breakdown($timeDifference, $days, $hours, $minutes, $seconds); $this->targetData("statusdataage", $days."d ".$hours."h ".$minutes."m ".$seconds."s"); $this->targetData("monitorstatusname", $this->monitorStatus['Name']); $this->targetData("laststatechange", $this->statusInfo['LastStateChange']); $this->targetData("statusinfo", $this->statusInfo['LastPluginOutput']); $this->targetData("laststatuscheck", $this->statusInfo['LastCheckTime']); } if($this->statusFlag && $this->isInformationToggled) { $currentTime = time(); $laststatechange = strtotime($this->statusInfo['LastStateChange']); $timedifference = $currentTime - $laststatechange; $sv->get_time_breakdown($timedifference, $days, $hours, $minutes, $seconds); $this->targetData("currentstateduration", $days."d ".$hours."h ".$minutes."m ".$seconds."s"); if($this->statusInfo['LastNotificationTime']) { $this->targetData("lastnotification", $this->statusInfo['LastNotificationTime']); } else { $this->targetData("lastnotification", "Unavailable"); } $this->targetData("currentnotificationnumber", $this->statusInfo['CurrentNotificationNumber']); if($this->statusInfo['isServiceFlapping']) { $this->targetData("isserviceflapping", "Yes"); } else { $this->targetData("isserviceflapping", "No"); } $this->targetData("percentstatechange", $this->statusInfo['PercentStateChange'] . '%'); } // Titlebar $titleBarContent .= <<
Entry Time Author Comment Persistent  
stringTime($comment['entry_time']);?> Draw();?>
END; $titleBarContent .= $this->configInfo['service_description'] ." on " . $this->configInfo['host_name']; $titleBarContent .= << END; // ICONS // DOWNTIME if($this->statusInfo['ScheduledDowntimeDepth']) { $titleBarContent .= "getIdentifier() . "downtimeIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/scheduled_downtime.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Currently In Downtime
This service is currently in ".$this->statusInfo['ScheduledDowntimeDepth']." layer(s) of downtime.');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } // ACTIVE CHECKS if($this->statusInfo['isChecksEnabled']) { $titleBarContent .= "getIdentifier() . "checksIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/activeCheck.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Active Checks
Active Checks Are Currently Enabled');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else { $titleBarContent .= "getIdentifier() . "checksIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/activeCheck-off.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Active Checks
Active Checks Are Currently Disabled');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } // NOTIFICATIONS if($this->statusInfo['isNotificationsEnabled']) { $titleBarContent .= "getIdentifier() . "notificationsIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/notifications.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Notifications
Notifications Are Currently Enabled');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else { $titleBarContent .= "getIdentifier() . "notificationsIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/notifications-off.gif\" width=\"13\" height=\"13\" onmouseover=\"guava.core.Tooltip.tooltip('Notifications
Notifications Are Currently Disabled');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } if($this->monitorStatus['Name'] == 'CRITICAL' && $this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" border=\"0\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-red.gif\" alt=\"Critical\" onmouseover=\"guava.core.Tooltip.tooltip('Service Status
This Service is in a Critical State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; if($this->statusInfo['isProblemAcknowledged'] == '1') $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-redyes.gif\" alt=\"Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this service has been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; else $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-redno.gif\" alt=\"Not Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this service has not been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else if($this->monitorStatus['Name'] == 'WARNING' && $this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-yellow.gif\" alt=\"Warning\" onmouseover=\"guava.core.Tooltip.tooltip('Service Status
This Service is in a Warning State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; if($this->statusInfo['isProblemAcknowledged'] == '1') $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-yellowyes.gif\" alt=\"Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this service has been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; else $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-yellowno.gif\" alt=\"Not Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this service has not been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else if($this->monitorStatus['Name'] == 'UNKNOWN' && $this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-yellow.gif\" width=\"11\" height=\"11\" alt=\"Unreachable\" onmouseover=\"guava.core.Tooltip.tooltip('Service Status
This Service is in a Unknown State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; if($this->statusInfo['isProblemAcknowledged'] == '1') $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-yellowyes.gif\" alt=\"Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this service has been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; else $titleBarContent .= "getIdentifier() . "acknowledgementIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/acknowledged-yellowno.gif\" alt=\"Not Acknowledged\" onmouseover=\"guava.core.Tooltip.tooltip('Problem Acknowledgement
The problem with this service has not been acknowledged');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; } else if($this->monitorStatus['Name'] == 'PENDING' && $this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-gray.gif\" width=\"11\" height=\"11\" alt=\"Pending\" onmouseover=\"guava.core.Tooltip.tooltip('Service Status
This Service is in a Pending State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; $titleBarContent .= "\"\"  "; } else if($this->statusFlag) { $titleBarContent .= "getIdentifier() . "statusIcon\" src=\"".$path_config['doc_root'].GUAVA_WS_ROOT . "packages/sv/images/status-green.gif\" alt=\"Ok\" onmouseover=\"guava.core.Tooltip.tooltip('Service Status
This Service is in a Ok State');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; $titleBarContent .= "  "; $titleBarContent .= "\"\"  "; } $titleBarContent .= "getIdentifier() . "outputIcon\" src=\"".$path_config['doc_root'] .GUAVA_WS_ROOT . "packages/sv/images/text-purple.gif\" onmouseover=\"guava.core.Tooltip.tooltip('Status Information
". htmlentities($this->statusInfo['LastPluginOutput']) ."');\" onMouseOut=\"guava.core.Tooltip.exit();\"/>  "; $titleBarContent .= <<
END; $this->targetData("titlebar", $titleBarContent); if($this->isInformationToggled) { $this->updateComments(); } if($this->checkToggle == null || ($this->checkToggle != null && ($this->checkToggle != $this->statusInfo['isChecksEnabled']))) { $this->checkToggle = $this->statusInfo['isChecksEnabled']; $this->commandSelect->addOption(CMD_SCHEDULE_SVC_DOWNTIME, "Schedule Downtime For This Service"); if($this->statusInfo['isChecksEnabled']) { $this->commandSelect->addOption(CMD_DISABLE_SVC_CHECK, "Disable Checks On This Service"); $this->commandSelect->addOption(CMD_SCHEDULE_SVC_CHECK, "Reschedule Next Check"); } else { $this->commandSelect->addOption(CMD_ENABLE_SVC_CHECK, "Enable Checks"); } $this->commandSelect->addOption(CMD_PROCESS_SERVICE_CHECK_RESULT, "Submit Passive Check Result"); $this->commandSelect->addOption(CMD_DISABLE_PASSIVE_SVC_CHECKS, "Disable Passive Checks"); $this->commandSelect->addOption(CMD_ENABLE_PASSIVE_SVC_CHECKS, "Enable Passive Checks"); $this->commandSelect->addOption(CMD_ACKNOWLEDGE_SVC_PROBLEM, "Acknowledge Problem"); $this->commandSelect->addOption(CMD_REMOVE_SVC_ACKNOWLEDGEMENT, "Remove Problem Acknowledgement"); $this->commandSelect->addOption(CMD_DISABLE_SVC_NOTIFICATIONS, "Disable Notifications"); $this->commandSelect->addOption(CMD_DELAY_SVC_NOTIFICATION, "Delay Next Notification"); $this->commandSelect->addOption(CMD_ENABLE_SVC_NOTIFICATIONS, "Enable Notifications"); $this->commandSelect->addOption(CMD_DISABLE_SVC_EVENT_HANDLER, "Disable Event Handler"); $this->commandSelect->addOption(CMD_ENABLE_SVC_EVENT_HANDLER, "Enable Event Handler"); $this->commandSelect->addOption(CMD_DISABLE_SVC_FLAP_DETECTION, "Disable Flap Detection"); $this->commandSelect->addOption(CMD_ENABLE_SVC_FLAP_DETECTION, "Enable Flap Detection"); $this->targetData("commandSelect", $this->commandSelect); } parent::update(); } function titlebar() { ?>printTarget("titlebar");?>
configInfo['host_name']][$this->configInfo['service_description']]['icon_image'])) { ?> <?=$_SESSION['serviceextinfo'][$this->configInfo['host_name']][$this->configInfo['service_description']]['icon_image_alt'];?> images/services.gif" alt="" /> commandForm->Open(); ?>
printTarget("commandSelect");?> submitButton->Draw();?>
commandForm->Close(); if($this->statusInfo != NULL) { ?>
Service Status:
printTarget("monitorstatusname", 1);?> Since printTarget("laststatechange", 1);?>

  Status Information:
printTarget("statusinfo", 1);?>
Last Status Check:
printTarget("laststatuscheck", 1);?>

  Status Data Age:
printTarget("statusdataage", 1);?>
No Status Information Available
printTarget("information"); ?>