Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
refactor(api downtime): clean dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclau committed Oct 3, 2017
1 parent 7d95905 commit e39b33f
Showing 1 changed file with 0 additions and 129 deletions.
129 changes: 0 additions & 129 deletions www/class/centreon-clapi/centreonDowntime.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ public function addspecificperiod($parameters)
$this->insertPeriod($p);
}


/**
* Delete period from downtime
*
Expand Down Expand Up @@ -392,134 +391,6 @@ public function delperiod($parameters)
$this->db->query($sql, $periodParams);
}

/**
* List all Hosts
*
* @param int downtime id
*/
public function listAllHosts($downtimeId)
{
// hosts
$sql = "SELECT host_name
FROM downtime_host_relation dhr, host h
WHERE h.host_id = dhr.host_host_id
AND dhr.dt_id = ?";
$stmt = $this->db->query($sql, array($downtimeId));
$rows = $stmt->fetchAll();
$hosts = array();
foreach ($rows as $row) {
$hosts[] = $row['host_name'];
}

// host groups
$sql = "SELECT hg_id
FROM downtime_hostgroup_relation dhr, hostgroup hg
WHERE hg.hg_id = dhr.hg_hg_id
AND dhr.dt_id = ?";
$stmt = $this->db->query($sql, array($downtimeId));
$rows = $stmt->fetchAll();
foreach ($rows as $row) {
$hosts = array_merge($hosts, $this->listHostsByHg($row['hg_id']));
}

// print header
echo "hosts;\n";
echo implode("|", $hosts) . $this->delim . "\n";
}

/**
* @param $hgId
* @return array
*/
public function listHostsByHg($hgId)
{
$sql = "SELECT host_name
FROM host h, hostgroup_relation hr
WHERE h.host_id = hr.host_host_id
AND hr.hostgroup_hg_id = ?";
$stmt = $this->db->query($sql, array($hgId));
$rows = $stmt->fetchAll();
$hosts = array();
foreach ($rows as $row) {
$hosts[] = $row['host_name'];
}
return $hosts;
}

/**
* List Services
*
* @param int downtime id
*/
public function listAllServices($downtimeId)
{
// services
$sql = "SELECT host_name, service_description
FROM downtime_service_relation dsr, host h, service s
WHERE h.host_id = dsr.host_host_id
AND dsr.service_service_id = s.service_id
AND dsr.dt_id = ?";
$stmt = $this->db->query($sql, array($downtimeId));
$rows = $stmt->fetchAll();
$services = array();
foreach ($rows as $row) {
$services[] = $row['host_name'] . ',' . $row['service_description'];
}

// service groups
$sql = "SELECT sg_id
FROM downtime_servicegroup_relation dsr, servicegroup sg
WHERE sg.sg_id = dsr.sg_sg_id
AND dsr.dt_id = ?";
$stmt = $this->db->query($sql, array($downtimeId));
$rows = $stmt->fetchAll();
foreach ($rows as $row) {
$services = array_merge($services, $this->listServicesBySg($row['sg_id']));
}

// print header
echo "services;\n";
echo implode("|", $services) . $this->delim . "\n";
}

/**
* @param $sgId
* @return array
*/
public function listServicesBySg($sgId)
{
// service groups / host
$sql = "SELECT h.host_name, s.service_description
FROM servicegroup_relation sgr, host h, service s
WHERE ISNULL(sgr.hostgroup_hg_id)
AND sgr.service_service_id = s.service_id
AND sgr.host_host_id = h.host_id
AND sgr.servicegroup_sg_id = ?";
$stmt = $this->db->query($sql, array($sgId));
$rows = $stmt->fetchAll();
$servicegroups = array();
foreach ($rows as $row) {
$servicegroups[] = $row['host_name'] . ',' . $row['service_description'];
}

// service groups / host group
$sql = "SELECT sgr.hostgroup_hg_id, s.service_description FROM servicegroup_relation sgr, service s
WHERE ISNULL(sgr.host_host_id)
AND sgr.service_service_id = s.service_id
AND sgr.servicegroup_sg_id = ?";
$stmt = $this->db->query($sql, array($sgId));
$rows = $stmt->fetchAll();
$servicegroups = array();
foreach ($rows as $row) {
$hosts = $this->listHostsByHg($row['hostgroup_hg_id']);
foreach ($hosts as $host) {
$servicegroups[] = $host . ',' . $row['service_description'];
}
}
return $servicegroups;
}


/**
* @param $downtimeId
* @return string
Expand Down

0 comments on commit e39b33f

Please sign in to comment.