Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion html/api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@


addRoute('post', '/getHost', 'getHost', 'operator');
addRoute('post', '/getAllHostsByElement', 'getAllHostsByElement', 'operator');
addRoute('post', '/getContact', 'getContact', 'operator');
addRoute('post', '/getCommand', 'getCommand', 'operator');
addRoute('post', '/getHostGroup', 'getHostGroup', 'operator');
Expand Down Expand Up @@ -235,4 +236,4 @@ function addRoute($httpMethod, $routeName, $methodName, $right="admin"){

$app->run();

?>
?>
24 changes: 24 additions & 0 deletions include/ObjectManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,30 @@ public function getHost( $hostName){
return "Host named ".$hostName." doesn't exist.";
}
}
/* LILAC - Get All Hosts by Element */
public function getAllHostsByElement($element=" "){
$element = trim($element);
$c = new Criteria();
$c1 = $c->getNewCriterion(NagiosHostPeer::NAME, "%" . $element . "%", Criteria::LIKE); //search by name
$c2 = $c->getNewCriterion(NagiosHostPeer::ALIAS, "%" . $element . "%", Criteria::LIKE); //search by alias
$c3 = $c->getNewCriterion(NagiosHostPeer::ADDRESS, "%" . $element . "%", Criteria::LIKE); //search by ip address
$c2->addOr($c3);
$c1->addOr($c2);
$c->add($c1);
$c->setIgnoreCase(true);
$c->addAscendingOrderByColumn(NagiosHostPeer::NAME);
$hosts = NagiosHostPeer::doSelect($c); //select all hosts if exist
$result = array();
foreach($hosts as $host) {
$answer = $host->toArray();
array_push($result,$answer);
}
if (!$result){
return "No host with this element: $element.";
}else{
return $result;
}
}
/* LILAC - Get Hosts by template name */
public function getHostsBytemplate( $templateHostName){
$nhtp = new NagiosHostTemplatePeer;
Expand Down