first commit
commit
ee27384fa3
@ -0,0 +1 @@
|
||||
Please refer to www.lilacplatform.com for documentation on installation and bug reporting.
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*
|
||||
Lilac - A Nagios Configuration Tool
|
||||
Copyright (C) 2007 Taylor Dondich
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
// Lilac About Page
|
||||
|
||||
require_once('includes/config.inc');
|
||||
print_header();
|
||||
|
||||
print_window_header("About Lilac Configurator", "100%");
|
||||
?>
|
||||
<p>
|
||||
<h2>Lilac Configurator <?php echo LILAC_VERSION;?></h2>
|
||||
Lilac Configurator is part of the Lilac Platform. The community site is available at <a href="http://www.lilacplatform.com">www.lilacplatform.com</a>. Lilac Configurator is a project developed by <a href="http://www.lilacnetworks.com">Lilac Networks</a>.
|
||||
</p>
|
||||
<p>
|
||||
<h2>Services & Support</h2>
|
||||
Lilac Networks can help support your implementation of Lilac & Nagios. For commercial support of your open source monitoring infrastructure, review our service offerings at <a href="http://www.lilacnetworks.com/services/">www.lilacnetworks.com</a>. For community support for Lilac Configurator, refer to the community site at <a href="http://www.lilacplatform.com">www.lilacplatform.com</a>.
|
||||
</p>
|
||||
<p>
|
||||
<h2>Statistics</h2>
|
||||
<table class="statistics">
|
||||
<tr>
|
||||
<td><strong>Total Nagios Commands:</strong></td>
|
||||
<td><?php echo NagiosCommandPeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td><strong>Total Nagios Time Periods:</strong></td>
|
||||
<td><?php echo NagiosTimeperiodPeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Total Nagios Contacts:</strong></td>
|
||||
<td><?php echo NagiosContactPeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td><strong>Total Nagios Contact Groups:</strong></td>
|
||||
<td><?php echo NagiosContactGroupPeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Total Nagios Host Groups:</strong></td>
|
||||
<td><?php echo NagiosHostgroupPeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td><strong>Total Nagios Service Groups:</strong></td>
|
||||
<td><?php echo NagiosServiceGroupPeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Total Nagios Host Templates:</strong></td>
|
||||
<td><?php echo NagiosHostTemplatePeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td><strong>Total Nagios Service Templates:</strong></td>
|
||||
<td><?php echo NagiosServiceTemplatePeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Total Nagios Hosts:</strong></td>
|
||||
<td><?php echo NagiosHostPeer::doCount(new Criteria());?></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td><strong>Total Nagios Services:</strong></td>
|
||||
<td><?php echo NagiosServicePeer::doCountAll();?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<?php
|
||||
print_window_footer();
|
||||
|
||||
print_footer();
|
||||
|
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/*
|
||||
Lilac - A Nagios Configuration Tool
|
||||
Copyright (C) 2007 Taylor Dondich
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* host_template.php
|
||||
* Author: Taylor Dondich (tdondich at gmail.com)
|
||||
* Description:
|
||||
* Provides interface to maintain host templates
|
||||
*
|
||||
*/
|
||||
include_once('includes/config.inc');
|
||||
|
||||
if(isset($_GET['host_template_id'])) {
|
||||
$tempSource = NagiosHostTemplatePeer::retrieveByPK($_GET['host_template_id']);
|
||||
$link = "host_template.php";
|
||||
$fieldName = "host_template_id";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "hosttemplate";
|
||||
$title = "Host Template";
|
||||
}
|
||||
else if(isset($_GET['host_id'])) {
|
||||
$tempSource = NagiosHostPeer::retrieveByPK($_GET['host_id']);
|
||||
$fieldName = "host_id";
|
||||
$link = "hosts.php";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "host";
|
||||
$title = "Host";
|
||||
}
|
||||
else if(isset($_GET['service_template_id'])) {
|
||||
$tempSource = NagiosServiceTemplatePeer::retrieveByPK($_GET['service_template_id']);
|
||||
$fieldName = "service_template_id";
|
||||
$link = "service_template.php";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "servicetemplate";
|
||||
$title = "Service Template";
|
||||
}
|
||||
else if(isset($_GET['service_id'])) {
|
||||
$tempSource = NagiosServicePeer::retrieveByPK($_GET['service_id']);
|
||||
$fieldName = "service_id";
|
||||
$link = "service.php";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "service";
|
||||
$title = ""; // This can be ignored later on.
|
||||
}
|
||||
else if(isset($_GET['hostgroup_id'])) {
|
||||
$tempSource = NagiosHostgroupPeer::retrieveByPK($_GET['hostgroup_id']);
|
||||
$fieldName = "hostgroup_id";
|
||||
$link = "hostgroups.php";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "hostgroup";
|
||||
$title = "Hostgroup";
|
||||
}
|
||||
|
||||
if(isset($_POST['request'])) {
|
||||
if($_POST['request'] == "add_dependency") {
|
||||
// Error checking
|
||||
if(trim($_POST['name']) == '') {
|
||||
$error = "Dependency name cannot be blank.";
|
||||
}
|
||||
else {
|
||||
// Creating dependency.
|
||||
$dependency = new NagiosDependency();
|
||||
switch($type) {
|
||||
case 'host':
|
||||
$dependency->setNagiosHost($tempSource);
|
||||
break;
|
||||
case 'service':
|
||||
$dependency->setNagiosService($tempSource);
|
||||
break;
|
||||
case 'hostgroup':
|
||||
$dependency->setNagiosHostgroup($tempSource);
|
||||
break;
|
||||
}
|
||||
$dependency->setName($_POST['name']);
|
||||
$dependency->save();
|
||||
header("Location: dependency.php?id= " . $dependency->getId());
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($type == "service") {
|
||||
$textTitle = $tempSource->getOwnerDescription() . " : " . $tempSource->getDescription();
|
||||
}
|
||||
else {
|
||||
$textTitle = $tempSource->getName();
|
||||
}
|
||||
|
||||
print_header("Add Dependency To " . $title . " " . $textTitle);
|
||||
|
||||
print_window_header("Add Dependency To " . $title . " " . $textTitle, "100%");
|
||||
?>
|
||||
<strong>Provide A Name for this Dependency</strong>
|
||||
<form action="add_dependency.php?<?php echo $fieldName;?>=<?php echo $tempSource->getId();?>" method="post">
|
||||
<input type="hidden" name="request" value="add_dependency" />
|
||||
<input id="name" type="text" size="20" name="name" value="" /><br />
|
||||
<input type="submit" value="Create Dependency" />
|
||||
<br />
|
||||
<br /><a href="<?php echo $link;?>?id=<?php echo $tempSource->getId();?>">Cancel And Return To <?php echo $title;?> <?php echo $textTitle;?></a>
|
||||
</form>
|
||||
<?php
|
||||
print_window_footer();
|
||||
|
||||
?>
|
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/*
|
||||
Lilac - A Nagios Configuration Tool
|
||||
Copyright (C) 2007 Taylor Dondich
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* host_template.php
|
||||
* Author: Taylor Dondich (tdondich at gmail.com)
|
||||
* Description:
|
||||
* Provides interface to maintain host templates
|
||||
*
|
||||
*/
|
||||
include_once('includes/config.inc');
|
||||
|
||||
if(isset($_GET['host_template_id'])) {
|
||||
$tempSource = NagiosHostTemplatePeer::retrieveByPK($_GET['host_template_id']);
|
||||
$link = "host_template.php";
|
||||
$fieldName = "host_template_id";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "hosttemplate";
|
||||
$title = "Host Template";
|
||||
}
|
||||
else if(isset($_GET['host_id'])) {
|
||||
$tempSource = NagiosHostPeer::retrieveByPK($_GET['host_id']);
|
||||
$fieldName = "host_id";
|
||||
$link = "hosts.php";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "host";
|
||||
$title = "Host";
|
||||
}
|
||||
else if(isset($_GET['hostgroup_id'])) {
|
||||
$tempSource = NagiosHostgroupPeer::retrieveByPK($_GET['hostgroup_id']);
|
||||
$fieldName = "hostgroup_id";
|
||||
$link = "hostgroups.php";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "hostgroup";
|
||||
$title = "Hostgroup";
|
||||
|
||||
}
|
||||
else if(isset($_GET['service_template_id'])) {
|
||||
$tempSource = NagiosServiceTemplatePeer::retrieveByPK($_GET['service_template_id']);
|
||||
$fieldName = "service_template_id";
|
||||
$link = "service_template.php";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "servicetemplate";
|
||||
$title = "Service Template";
|
||||
}
|
||||
else if(isset($_GET['service_id'])) {
|
||||
$tempSource = NagiosServicePeer::retrieveByPK($_GET['service_id']);
|
||||
$fieldName = "service_id";
|
||||
$link = "service.php";
|
||||
if(!$tempSource) {
|
||||
header("Location: welcome.php");
|
||||
}
|
||||
$type = "service";
|
||||
$title = "Service";
|
||||
}
|
||||
if(isset($_POST['request']) && $_POST['request'] == 'add_escalation') {
|
||||
// Check to see what kind of escalation we've got
|
||||
if(trim($_POST['escalation_description']) == '') {
|
||||
$errorMsg = "Description cannot be blank.";
|
||||
}
|
||||
else {
|
||||
$escalation = new NagiosEscalation();
|
||||
if($type == "host") {
|
||||
$escalation->setHost($tempSource->getId());
|
||||
}
|
||||
if($type == "hostgroup") {
|
||||
$escalation->setHostgroup($tempSource->getId());
|
||||
}
|
||||
else if($type == "hosttemplate") {
|
||||
$escalation->setHostTemplate($tempSource->getId());
|
||||
}
|
||||
else if($type == "service") {
|
||||
$escalation->setService($tempSource->getId());
|
||||
}
|
||||
else if($type == "servicetemplate") {
|
||||
$escalation->setServiceTemplate($tempSource->getId());
|
||||
}
|
||||
$escalation->setDescription(trim($_POST['escalation_description']));
|
||||
$escalation->save();
|
||||
header("Location: escalation.php?id=" . $escalation->getId());
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if($type == "service") {
|
||||
$textTitle = $tempSource->getNagiosHost()->getName() . " : " . $tempSource->getDescription();
|
||||
}
|
||||
else {
|
||||
$textTitle = $tempSource->getName();
|
||||
}
|
||||
|
||||
print_header("Add Escalation To " . $title . " " . $textTitle);
|
||||
|
||||
print_window_header("Add A Escalation", "100%");
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<a href="<?php echo $link;?>?id=<?php echo $tempSource->getId();?>">Return To <?php echo $title;?> <?php echo $textTitle;?></a>
|
||||
<?php
|
||||
if(isset($errorMsg)) {
|
||||
?>
|
||||
<div style="color: red;"><?php echo $errorMsg;?></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<br />
|
||||
<br />
|
||||
<form name="escalation_add_form" method="post" action="add_escalation.php?<?php echo $fieldName;?>=<?php echo $tempSource->getId();?>">
|
||||
<input type="hidden" name="request" value="add_escalation" />
|
||||
<?php
|
||||
double_pane_form_window_start(); ?>
|
||||
<tr bgcolor="eeeeee">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Description:</b><br />
|
||||
<input type="text" size="40" name="escalation_description" value="" /><br />
|
||||
<?php echo $lilac->element_desc("escalation_description", "nagios_escalations_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php double_pane_form_window_finish(); ?>
|
||||
<input type="submit" value="Add Escalation" />
|
||||
<br /><br />
|
||||
</form>
|
||||
<?php
|
||||
print_window_footer();
|
||||
?>
|
||||
<br />
|
||||
<?php
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/*
|
||||
Lilac - A Nagios Configuration Tool
|
||||
Copyright (C) 2007 Taylor Dondich
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Filename: add_host.php
|
||||
*/
|
||||
include_once('includes/config.inc');
|
||||
|
||||
if(isset($_POST['request']) && $_POST['request'] == 'add_host') {
|
||||
// Check for pre-existing host template with same name
|
||||
if($lilac->host_exists($_POST['host_manage']['host_name'])) {
|
||||
$error = "A host with that name already exists!";
|
||||
}
|
||||
else {
|
||||
// Field Error Checking
|
||||
if(count($_POST['host_manage'])) {
|
||||
foreach($_POST['host_manage'] as $tempVariable)
|
||||
$tempVariable = trim($tempVariable);
|
||||
}
|
||||
if($_POST['host_manage']['host_name'] == '' || $_POST['host_manage']['alias'] == '' || $_POST['host_manage']['address'] == '') {
|
||||
$error = "Fields shown are required and cannot be left blank.";
|
||||
}
|
||||
else {
|
||||
// All is well for error checking, add the host into the db.
|
||||
$tempHost = new NagiosHost();
|
||||
$tempHost->setName($_POST['host_manage']['host_name']);
|
||||
$tempHost->setAlias($_POST['host_manage']['alias']);
|
||||
if(isset($_GET['parent_id'])) {
|
||||
// Get the host by that parent_id
|
||||
$host = NagiosHostPeer::retrieveByPk($_GET['parent_id']);
|
||||
if($host) {
|
||||
// valid host, add parent
|
||||
$tempHost->addParentByName($host->getName());
|
||||
}
|
||||
}
|
||||
$tempHost->setAddress($_POST['host_manage']['address']);
|
||||
if(isset($_POST['host_manage']['display_name'])) {
|
||||
$tempHost->setDisplayName($_POST['host_manage']['display_name']);
|
||||
}
|
||||
$tempHost->save();
|
||||
header("Location: hosts.php?id=" . $tempHost->getId());
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$add_template_list[] = array("host_template_id" => '', "template_name" => "None");
|
||||
$lilac->get_host_template_list( $template_list);
|
||||
|
||||
if(count($template_list)) {
|
||||
foreach($template_list as $tempTemplate) {
|
||||
$add_template_list[] = array('host_template_id' => $tempTemplate->getId(), 'template_name' => $tempTemplate->getName());
|
||||
}
|
||||
}
|
||||
|
||||
print_header("Add New Host");
|
||||
|
||||
|
||||
$title = "Add A Top-Level Host";
|
||||
if(isset($_GET['parent_id'])) {
|
||||
$tempHostInfo = NagiosHostPeer::retrieveByPK($_GET['parent_id']);
|
||||
if($tempHostInfo) {
|
||||
$title = "Add A Host Under " . $tempHostInfo->getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
print_window_header($title, "100%");
|
||||
?>
|
||||
<form name="host_add_form" method="post" action="add_host.php<?php if(isset($_GET['parent_id'])) print("?parent_id=" . $_GET['parent_id']);?>">
|
||||
<input type="hidden" name="request" value="add_host" />
|
||||
<?php
|
||||
if(isset($_GET['parent_id']) && $_GET['parent_id'] != 0) {
|
||||
?>
|
||||
<input type="hidden" name="host_manage[parents]" value="<?php echo $_GET['parent_id'];?>">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php double_pane_form_window_start(); ?>
|
||||
<tr bgcolor="f0f0f0">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Host Name:</b><br />
|
||||
<input type="text" size="40" name="host_manage[host_name]" value=""><br />
|
||||
<?php echo $lilac->element_desc("host_name", "nagios_hosts_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="eeeeee">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Host Description:</b><br />
|
||||
<input type="text" size="40" name="host_manage[alias]" value=""><br />
|
||||
<?php echo $lilac->element_desc("alias", "nagios_hosts_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="f0f0f0">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Address:</b><br />
|
||||
<input type="text" size="40" name="host_manage[address]" value=""><br />
|
||||
<?php echo $lilac->element_desc("address", "nagios_hosts_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="f0f0f0">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Display Name (Optional):</b><br />
|
||||
<input type="text" size="40" name="host_manage[display_name]" value=""><br />
|
||||
<?php echo $lilac->element_desc("display_name", "nagios_hosts_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php double_pane_form_window_finish(); ?>
|
||||
<input type="submit" value="Add Host" /> [ <a href="hosts.php">Cancel</a> ]
|
||||
<br /><br />
|
||||
</form>
|
||||
|
||||
<?php
|
||||
print_window_footer();
|
||||
?>
|
||||
<br />
|
||||
<?php
|
||||
print_footer();
|
||||
?>
|
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/*
|
||||
Lilac - A Nagios Configuration Tool
|
||||
Copyright (C) 2007 Taylor Dondich
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* host_templates.php
|
||||
* Author: Taylor Dondich (tdondich at gmail.com)
|
||||
* Description:
|
||||
* Provides interface to maintain host templates
|
||||
*
|
||||
*/
|
||||
include_once('includes/config.inc');
|
||||
|
||||
if(isset($_POST['request'])) {
|
||||
if($_POST['request'] == 'add_host_template') {
|
||||
// Check for pre-existing host template with same name
|
||||
if($lilac->host_template_exists($_POST['template_name'])) {
|
||||
$error = "A host template with that name already exists!";
|
||||
}
|
||||
else {
|
||||
// Field Error Checking
|
||||
if($_POST['template_name'] == '' || $_POST['template_description'] == '') {
|
||||
$addError = 1;
|
||||
$error = "Fields shown are required and cannot be left blank.";
|
||||
}
|
||||
else {
|
||||
$template = new NagiosHostTemplate();
|
||||
$template->setName($_POST['template_name']);
|
||||
$template->setDescription($_POST['template_description']);
|
||||
$template->save();
|
||||
header("Location: host_template.php?id=" . $template->getId());
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_header("Host Template Editor");
|
||||
|
||||
print_window_header("Add Host Template", "100%");
|
||||
?>
|
||||
<form name="host_template_add_form" method="post" action="add_host_template.php">
|
||||
<input type="hidden" name="request" value="add_host_template" />
|
||||
<?php double_pane_form_window_start(); ?>
|
||||
<tr bgcolor="f0f0f0">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Template Name:</b><br />
|
||||
<input type="text" size="40" name="template_name" value=""><br />
|
||||
<?php echo $lilac->element_desc("template_name", "nagios_hosts_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="eeeeee">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Template Description:</b><br />
|
||||
<input type="text" size="40" name="template_description" value=""><br />
|
||||
<?php echo $lilac->element_desc("template_description", "nagios_hosts_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php double_pane_form_window_finish(); ?>
|
||||
<input type="submit" value="Add Host Template" /> [ <a href="templates.php">Cancel</a> ]
|
||||
<br /><br />
|
||||
</form>
|
||||
<?php
|
||||
print_window_footer();
|
||||
?>
|
||||
<br />
|
||||
<?php
|
||||
print_footer();
|
||||
?>
|
@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/*
|
||||
Lilac - A Nagios Configuration Tool
|
||||
Copyright (C) 2007 Taylor Dondich
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* add_service_template.php
|
||||
* Author: Taylor Dondich (tdondich at gmail.com)
|
||||
* Description:
|
||||
* Provides interface to maintain service templates
|
||||
*
|
||||
*/
|
||||
include_once('includes/config.inc');
|
||||
|
||||
if(isset($_GET['host_template_id'])) {
|
||||
$hostTemplate = NagiosHostTemplatePeer::retrieveByPK($_GET['host_template_id']);
|
||||
if(!$hostTemplate) {
|
||||
header("Location: welcome.php");
|
||||
die();
|
||||
}
|
||||
else {
|
||||
$title = " for Host Template " . $hostTemplate->getName();
|
||||
$sublink = "?host_template_id=" . $hostTemplate->getId();
|
||||
$cancelLink = "host_template.php?id=" . $hostTemplate->getId() . "§ion=services";
|
||||
}
|
||||
}
|
||||
else if(isset($_GET['host_id'])) {
|
||||
$host = NagiosHostPeer::retrieveByPK($_GET['host_id']);
|
||||
if(!$host) {
|
||||
header("Location: welcome.php");
|
||||
die();
|
||||
}
|
||||
else {
|
||||
$title = " for Host " . $host->getName();
|
||||
$sublink = "?host_id=" . $host->getId();
|
||||
$cancelLink = "hosts.php?id=" . $host->getId() . "§ion=services";
|
||||
}
|
||||
}
|
||||
else if(isset($_GET['hostgroup_id'])) {
|
||||
$hostgroup = NagiosHostgroupPeer::retrieveByPK($_GET['hostgroup_id']);
|
||||
if(!$hostgroup) {
|
||||
header("Location: welcome.php");
|
||||
die();
|
||||
}
|
||||
else {
|
||||
$title = " for Hostgroup " . $hostgroup->getName();
|
||||
$sublink = "?hostgroup_id=" . $hostgroup->getId();
|
||||
$cancelLink = "hostgroups.php?id=" . $hostgroup->getId() . "§ion=services";
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
header("Location: welcome.php");
|
||||
die();
|
||||
}
|
||||
|
||||
if(isset($_POST['request'])) {
|
||||
if($_POST['request'] == 'add_service') {
|
||||
if(isset($hostTemplate)) {
|
||||
// Template logic
|
||||
$c = new Criteria();
|
||||
$c->add(NagiosServicePeer::DESCRIPTION, $_POST['service_description']);
|
||||
$c->add(NagiosServicePeer::HOST_TEMPLATE, $hostTemplate->getId());
|
||||
$c->setIgnoreCase(true);
|
||||
$service = NagiosServicePeer::doSelectOne($c);
|
||||
if($service) {
|
||||
$error = "A service with that description already exists for that host template.";
|
||||
}
|
||||
else {
|
||||
// Let's add.
|
||||
$service = new NagiosService();
|
||||
$service->setDescription($_POST['service_description']);
|
||||
$service->setDisplayName($_POST['display_name']);
|
||||
$service->setHostTemplate($hostTemplate->getId());
|
||||
$service->save();
|
||||
header("Location: service.php?id=" . $service->getId());
|
||||
die();
|
||||
|
||||
}
|
||||
}
|
||||
else if(isset($host)) {
|
||||
// Host logic
|
||||
$c = new Criteria();
|
||||
$c->add(NagiosServicePeer::DESCRIPTION, $_POST['service_description']);
|
||||
$c->add(NagiosServicePeer::HOST, $host->getId());
|
||||
$c->setIgnoreCase(true);
|
||||
$service = NagiosServicePeer::doSelectOne($c);
|
||||
if($service) {
|
||||
$error = "A service with that description already exists for that host.";
|
||||
}
|
||||
else {
|
||||
// Let's add.
|
||||
$service = new NagiosService();
|
||||
$service->setDescription($_POST['service_description']);
|
||||
$service->setDisplayName($_POST['display_name']);
|
||||
$service->setHost($host->getId());
|
||||
$service->save();
|
||||
header("Location: service.php?id=" . $service->getId());
|
||||
die();
|
||||
}
|
||||
}
|
||||
else if(isset($hostgroup)) {
|
||||
// Host logic
|
||||
$c = new Criteria();
|
||||
$c->add(NagiosServicePeer::DESCRIPTION, $_POST['service_description']);
|
||||
$c->add(NagiosServicePeer::HOSTGROUP, $hostgroup->getId());
|
||||
$c->setIgnoreCase(true);
|
||||
$service = NagiosServicePeer::doSelectOne($c);
|
||||
if($service) {
|
||||
$error = "A service with that description already exists for that hostgroup.";
|
||||
}
|
||||
else {
|
||||
// Let's add.
|
||||
$service = new NagiosService();
|
||||
$service->setDescription($_POST['service_description']);
|
||||
$service->setDisplayName($_POST['display_name']);
|
||||
$service->setHostgroup($hostgroup->getId());
|
||||
$service->save();
|
||||
header("Location: service.php?id=" . $service->getId());
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
print_header("Service Editor");
|
||||
|
||||
// Get list of service templates
|
||||
$lilac->get_service_template_list($tempList);
|
||||
$template_list[] = array("service_template_id" => '', "template_name" => "None");
|
||||
foreach($tempList as $tempTemplate)
|
||||
$template_list[] = array('service_template_id' => $tempTemplate->getId(), 'template_name' => $tempTemplate->getName());
|
||||
|
||||
|
||||
|
||||
|
||||
print_window_header("Add Service " . $title, "100%");
|
||||
?>
|
||||
<form name="service_template_add_form" method="post" action="add_service.php<?php echo $sublink;?>">
|
||||
<input type="hidden" name="request" value="add_service" />
|
||||
<?php double_pane_form_window_start(); ?>
|
||||
<tr bgcolor="eeeeee">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Service Description:</b><br />
|
||||
<input type="text" size="40" name="service_description" value=""><br />
|
||||
<?php echo $lilac->element_desc("service_description", "nagios_services_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="eeeeee">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Display Name: (Optional)</b><br />
|
||||
<input type="text" size="40" name="display_name" value=""><br />
|
||||
<?php echo $lilac->element_desc("display_name", "nagios_services_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php double_pane_form_window_finish(); ?>
|
||||
<input type="submit" value="Add Service" /> [ <a href="<?php echo $cancelLink;?>">Cancel</a> ]
|
||||
<br /><br />
|
||||
</form>
|
||||
<?php
|
||||
print_window_footer();
|
||||
?>
|
||||
<br />
|
||||
<?php
|
||||
print_footer();
|
||||
?>
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*
|
||||
Lilac - A Nagios Configuration Tool
|
||||
Copyright (C) 2007 Taylor Dondich
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* add_service_template.php
|
||||
* Author: Taylor Dondich (tdondich at gmail.com)
|
||||
* Description:
|
||||
* Provides interface to maintain service templates
|
||||
*
|
||||
*/
|
||||
include_once('includes/config.inc');
|
||||
|
||||
if(isset($_POST['request'])) {
|
||||
if($_POST['request'] == 'add_service_template') {
|
||||
// Check for pre-existing service template with same name
|
||||
if($lilac->service_template_exists($_POST['template_name'])) {
|
||||
$error = "A service template with that name already exists!";
|
||||
}
|
||||
else {
|
||||
// Field Error Checking
|
||||
if($_POST['template_name'] == '' || $_POST['template_description'] == '') {
|
||||
$addError = 1;
|
||||
$error = "Fields shown are required and cannot be left blank.";
|
||||
}
|
||||
else {
|
||||
$template = new NagiosServiceTemplate();
|
||||
$template->setName($_POST['template_name']);
|
||||
$template->setDescription($_POST['template_description']);
|
||||
$template->save();
|
||||
header("Location: service_template.php?id=" . $template->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_header("Service Template Editor");
|
||||
|
||||
print_window_header("Add Service Template", "100%");
|
||||
?>
|
||||
<form name="service_template_add_form" method="post" action="add_service_template.php">
|
||||
<input type="hidden" name="request" value="add_service_template" />
|
||||
<?php double_pane_form_window_start(); ?>
|
||||
<tr bgcolor="f0f0f0">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Template Name:</b><br />
|
||||
<input type="text" size="40" name="template_name" value=""><br />
|
||||
<?php echo $lilac->element_desc("template_name", "nagios_services_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="eeeeee">
|
||||
<td colspan="2" class="formcell">
|
||||
<b>Template Description:</b><br />
|
||||
<input type="text" size="40" name="template_description" value=""><br />
|
||||
<?php echo $lilac->element_desc("template_description", "nagios_services_desc"); ?><br />
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
<?php double_pane_form_window_finish(); ?>
|
||||
<input type="submit" value="Add Service Template" /> [ <a href="templates.php">Cancel</a> ]
|
||||
<br /><br />
|
||||
</form>
|
||||
<?php
|
||||
print_window_footer();
|
||||
?>
|
||||
<br />
|
||||
<?php
|
||||
print_footer();
|
||||
?>
|
@ -0,0 +1,863 @@
|
||||
<?php
|
||||
/*
|
||||
Lilac - A Nagios Configuration Tool
|
||||
Copyright (C) 2007 Taylor Dondich
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
Lilac Auto Discovery Page
|
||||
*/
|
||||
|
||||
|
||||
include_once('includes/config.inc');
|
||||
|
||||
include_once('autodiscovery/classes.inc.php');
|
||||
include_once('AutodiscoveryJob.php');
|
||||
include_once('AutodiscoveryLogEntry.php');
|
||||
|
||||
require_once("Net/Traceroute.php");
|
||||
|
||||
if(isset($_GET['id'])) {
|
||||
$autodiscoveryJob = AutodiscoveryJobPeer::retrieveByPK($_GET['id']);
|
||||
if(!$autodiscoveryJob) {
|
||||
unset($autodiscoveryJob);
|
||||
}
|
||||
|
||||
|
||||
if(isset($_GET['action']) && $_GET['action'] == "restart") {
|
||||
$autodiscoveryJob->setStatusCode(AutodiscoveryJob::STATUS_STARTING);
|
||||
$autodiscoveryJob->save();
|
||||
exec("php autodiscovery/autodiscover.php " . $autodiscoveryJob->getId() . " > /dev/null", $tempOutput, $retVal);
|
||||
if($retVal != 42) {
|
||||
$error = "Failed to run external autodiscovery script. Return value: " . $retVal . "<br /> Error:";
|
||||
foreach($tempOutput as $output) {
|
||||
$error .= $output . "<br />";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No need to show
|
||||
//$success = "Restarted AutoDiscovery Job";
|
||||
}
|
||||
}
|
||||
if(isset($_GET['delete'])) {
|
||||
// We want to delete the job!
|
||||
$autodiscoveryJob->delete();
|
||||
unset($_GET['id']);
|
||||
unset($autodiscoveryJob);
|
||||
$success = "Removed Job and associated devices.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($_GET['deviceId'])) {
|
||||
// We want to review a specific device
|
||||
$device = AutodiscoveryDevicePeer::retrieveByPK($_GET['deviceId']);
|
||||
if(!$device) {
|
||||
header("Location: autodiscovery.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if(isset($_GET['request']) && $_GET['request'] == 'recalc') {
|
||||
// We want to recalculate template matches
|
||||
$config = unserialize($autodiscoveryJob->getConfig());
|
||||
$defaultTemplateId = $config->getVar("default_template");
|
||||
if(!empty($defaultTemplateId)) {
|
||||
$defaultTemplate = NagiosHostTemplatePeer::retrieveByPK($defaultTemplateId);
|
||||
}
|
||||
if(empty($defaultTemplate)) {
|
||||
$defaultTemplate = null;
|
||||
}
|
||||
AutodiscoveryMatchMaker::match($device, $defaultTemplate);
|
||||
$success = "Recalculated Matching Templates.";
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET['request']) && $_GET['request'] == 'status') {
|
||||
// We're our AJAX client wanting status information
|
||||
$result = array();
|
||||
$autodiscoveryJob = AutodiscoveryJobPeer::retrieveByPK($_GET['id']);
|
||||
if(!$autodiscoveryJob) {
|
||||
$result['error'] = "Invalid job specified.";
|
||||
print(json_encode($result));
|
||||
exit();
|
||||
}
|
||||
// Okay, let's populate the status
|
||||
$result['start_time'] = $autodiscoveryJob->getStartTime();
|
||||
$result['status_code'] = $autodiscoveryJob->getStatusCode();
|
||||
$result['status_text'] = $autodiscoveryJob->getStatus();
|
||||
$result['status_change_time'] = $autodiscoveryJob->getStatusChangeTime();
|
||||
|
||||
// Build elapsed time
|
||||
if(!in_array($autodiscoveryJob->getStatusCode(), array(AutoDiscoveryJob::STATUS_FAILED, AutoDiscoveryJob::STATUS_FINISHED))) {
|
||||
$target = time();
|
||||
}
|
||||
else {
|
||||
$target = strtotime($result['status_change_time']);
|
||||
}
|
||||
$start = strtotime($result['start_time']);
|
||||
$total = $target - $start;
|
||||
$hours = (int)($total / 3600);
|
||||
$total = $total % 3600;
|
||||
$minutes = (int)($total / 60);
|
||||
$seconds = $total % 60;
|
||||
|
||||
$result['elapsed_time'] = $hours . " Hours " . $minutes . " Minutes " . $seconds . " Seconds";
|
||||
|
||||
print(json_encode($result));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if(isset($_GET['request']) && $_GET['request'] == 'fetch') {
|
||||
// We're our AJAX client wanting to get new log data
|
||||
$result = array();
|
||||
$c = new Criteria();
|
||||
$c->add(AutodiscoveryLogEntryPeer::JOB, $_GET['id']);
|
||||
$c->setLimit($_POST['rp']);
|
||||
$c->setOffset(isset($_POST['page']) ? ($_POST['page'] - 1) * $_POST['rp'] : 0);
|
||||
$c->addDescendingOrderByColumn(AutodiscoveryLogEntryPeer::ID);
|
||||
$entries = $autodiscoveryJob->getAutodiscoveryLogEntrys($c);
|
||||
foreach($entries as $entry) {
|
||||
$results['rows'][] = array('id' => $entry->getId(), 'cell' => array( $entry->getTime(),
|
||||
$entry->getReadableType($entry->getType()),
|
||||
$entry->getText()));
|
||||
}
|
||||
$c = new Criteria();
|
||||
$c->add(AutodiscoveryLogEntryPeer::JOB, $autodiscoveryJob->getId());
|
||||
$results['page'] = $_POST['page'];
|
||||
$results['total'] = AutodiscoveryLogEntryPeer::doCount($c);
|
||||
?>
|
||||
|
||||
<?php
|
||||
print(json_encode($results));
|
||||
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
if(isset($_POST['request'])) {
|
||||
if($_POST['request'] == "autodiscover") {
|
||||
|
||||
if(!strlen(trim($_POST['job_name']))) {
|
||||
$error = "Job name must be provided.";
|
||||
}
|
||||
else {
|
||||
if(count($_POST['target']) == 0) {
|
||||
$error = "You must provide at least one target.";
|
||||
}
|
||||
else {
|
||||
ksort($_POST['target']);
|
||||
$config = new AutodiscoveryConfig("NmapAutoDiscoveryEngine");
|
||||
|
||||
$config->setVar("targets", $_POST['target']);
|
||||
$config->setVar("nmap_binary", $_POST['nmap_binary']);
|
||||
$config->setVar("traceroute_enabled", (empty($_POST['traceroute_enabled'])) ? true : true);
|
||||
$config->setVar("default_template", $_POST['default_template']);
|
||||
|
||||
$autodiscoveryJob = new AutodiscoveryJob();
|
||||
$autodiscoveryJob->setName($_POST['job_name']);
|
||||
$autodiscoveryJob->setDescription($_POST['job_description']);
|
||||
$autodiscoveryJob->setCmd(AutodiscoveryJob::CMD_START);
|
||||
$autodiscoveryJob->setConfig(serialize($config));
|
||||
$autodiscoveryJob->setStatus("Starting...");
|
||||
$autodiscoveryJob->setStatusCode(AutodiscoveryJob::STATUS_STARTING);
|
||||
$autodiscoveryJob->save();
|
||||
|
||||
// Attempt to execute the external auto-discovery script, fork it, and love it.
|
||||
exec("php autodiscovery/autodiscover.php " . $autodiscoveryJob->getId() . " > /dev/null", $tempOutput, $retVal);
|
||||
if($retVal != 42) {
|
||||
$status_msg = "Failed to run external Autodiscovery script. Return value: " . $retVal . "<br /> Error:";
|
||||
foreach($tempOutput as $output) {
|
||||
$status_msg .= $output . "<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($_POST['request'] == "updateGeneral") {
|
||||
if(trim($_POST['name']) != '' && trim($_POST['description']) != '') {
|
||||
// Check to see first if a host or auto discovery device has that potential name
|
||||
$c = new Criteria();
|
||||
$c->add(NagiosHostPeer::NAME, trim($_POST['name']));
|
||||
$c->setIgnoreCase(true);
|
||||
$host = NagiosHostPeer::doSelectOne($c);
|
||||
if(!$host) {
|
||||
// Try a autodiscovery device?
|
||||
$c = new Criteria();
|
||||
$c->add(AutodiscoveryDevicePeer::NAME, trim($_POST['name']));
|
||||
$c->setIgnoreCase(true);
|
||||
$host = AutodiscoveryDevicePeer::doSelectOne($c);
|
||||
}
|
||||
if($host) {
|
||||
$error = "A host already exists with that name. Must choose a unique name.";
|
||||
}
|
||||
else {
|
||||
// Assign name and description
|
||||
$device->setName(trim($_POST['name']));
|
||||
$device->setDescription(trim($_POST['description']));
|
||||
$device->save();
|
||||
$success = "Updated discovered device's information.";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$error = "Name and Description cannot be blank.";
|
||||
}
|
||||
}
|
||||
else if($_POST['request'] == "assignTemplate") {
|
||||
$hostTemplate = NagiosHostTemplatePeer::retrieveByPK($_POST['template']);
|
||||
if(!$hostTemplate) {
|
||||
$error = "That template no longer exists.";
|
||||
}
|
||||
else {
|
||||
$device->setNagiosHostTemplate($hostTemplate);
|
||||
$device->save();
|
||||
$success = "Template assigned.";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We want to process our device list!
|
||||
// First we check to see if there's any hosts now with the same name
|
||||
foreach($_POST['selectedDevices'] as $deviceId) {
|
||||
$device = AutodiscoveryDevicePeer::retrieveByPK($deviceId);
|
||||
if(!$device) {
|
||||
$error = "One of the devices provided no longer exists.";
|
||||
continue;
|
||||
}
|
||||
$c = new Criteria();
|
||||
$c->add(NagiosHostPeer::NAME, $device->getName());
|
||||
$c->setIgnoreCase(true);
|
||||
$host = NagiosHostPeer::doSelectOne($c);
|
||||
if(!$host) {
|
||||
$c = new Criteria();
|
||||
$c->add(AutodiscoveryDevicePeer::NAME, $device->getName());
|
||||
$c->setIgnoreCase(true);
|
||||
$host = AutodiscoveryDevicePeer::doSelectOne($c);
|
||||
if($host->getId() == $device->getId()) {
|
||||
unset($host);
|
||||
}
|
||||
}
|
||||
if(!empty($host)) {
|
||||
$error = "A host already exists with the name of " . $device->getName() . ". Change the device's name before importing.";
|
||||
}
|
||||
}
|
||||
if(empty($error)) {
|
||||
$totalSuccess = 0;
|
||||
// Okay, no errors, let's create our hosts!
|
||||
foreach($_POST['selectedDevices'] as $deviceId) {
|
||||
$device = AutodiscoveryDevicePeer::retrieveByPK($deviceId);
|
||||
$tempHost = new NagiosHost();
|
||||
$tempHost->setAddress($device->getAddress());
|
||||
$tempHost->setName($device->getName());
|
||||
$tempHost->setAlias($device->getDescription());
|
||||
$tempHost->save();
|
||||
// Now assign a template, if wanted
|
||||
$template = $device->getNagiosHostTemplate();
|
||||
if(!empty($template)) {
|
||||
$inheritance = new NagiosHostTemplateInheritance();
|
||||
$inheritance->setNagiosHost($tempHost);
|
||||
$inheritance->setNagiosHostTemplateRelatedByTargetTemplate($template);
|
||||
$inheritance->save();
|
||||
}
|
||||
// Now parent
|
||||
$parent = $device->getNagiosHost();
|
||||
if(!empty($parent)) {
|
||||
$parentRelationship = new NagiosHostParent();
|
||||
$parentRelationship->setNagiosHostRelatedByChildHost($tempHost);
|
||||
$parentRelationship->setNagiosHostRelatedByParentHost($parent);
|
||||
$parentRelationship->save();
|
||||
}
|
||||
$totalSuccess++;
|
||||
$device->delete();
|
||||
}
|
||||
$success = $totalSuccess . " Device(s) Imported.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print_header("AutoDiscovery");
|
||||
|
||||
if(isset($autodiscoveryJob)) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#joblog").flexigrid({
|
||||
url: 'autodiscovery.php?id=<?php echo $autodiscoveryJob->getId();?>&request=fetch',
|
||||
dataType: 'json', // type of data loaded
|
||||
errormsg: 'There was a problem retrieving the error log. Refresh and try again',
|
||||
colModel: [
|
||||
{display: 'Time', name: 'name', width: 100, sortable: true, align: 'left'},
|
||||
{display: 'Type', name: 'type', width: 100, sortable: true, align: 'left'},
|
||||
{display: 'Text', name: 'text', width: 1200, sortable: true, align: 'left'}
|
||||
],
|
||||
resizable: false, //resizable table
|
||||
sortname: "time",
|
||||
sortorder: 'asc',
|
||||
usepager: true,
|
||||
procmsg: 'Grabbing Log Entries, please wait ...',
|
||||
title: false,
|
||||
showToggleBtn: false, //show or hide column toggle popup
|
||||
useRp: true,
|
||||
rp: 50,
|
||||
height: 600
|
||||
});
|
||||
|
||||
<?php
|
||||
if(!in_array($autodiscoveryJob->getStatusCode(), array(AutodiscoveryJob::STATUS_FINISHED, AutodiscoveryJob::STATUS_FAILED))) {
|
||||
// Add check timer
|
||||
?>
|
||||
var timer = 0;
|
||||
$(document).everyTime(2000, "status", function() {
|
||||
// Call ajax
|
||||
$.getJSON("autodiscovery.php?id=<?php echo $autodiscoveryJob->getId();?>&request=status&tok=" + Math.random() , function(data) {
|
||||
$("#jobstatus").html(data.status_text);
|
||||
$("#elapsedtime").html(data.elapsed_time);
|
||||
|
||||
if(data.status_code == <?php echo AutodiscoveryJob::STATUS_FINISHED;?> || data.status_code == <?php echo AutodiscoveryJob::STATUS_FAILED;?>) {
|
||||
if(data.status_code == <?php echo AutodiscoveryJob::STATUS_FINISHED;?>) {
|
||||
$("#completemsg").show("slow").fadeIn("slow");
|
||||
}
|
||||
$(document).stopTime("status");
|
||||
}
|
||||
});
|
||||
}, 0, true);
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
// We're setting up an autodiscovery job
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var targetcount = 1;
|
||||
$(function() {
|
||||
// Find the enter keypress
|
||||
if ($.browser.mozilla) {
|
||||
$("#activetarget").keypress(function(event) {
|
||||
if(event.keyCode == 13) {
|
||||
$("#addtargetlink").click();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#activetarget").keydown(function(event) {
|
||||
if(event.keyCode == 13) {
|
||||
$("#addtargetlink").click();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$("#addtargetlink").click(function(event) {
|
||||
targetcount = targetcount + 1;
|
||||
event.preventDefault();
|
||||
// Add new row to the table before this row, showing the
|
||||
var content = $("<tr><td>" + $("#activetarget").attr("value") + "<input type='hidden' name='target[" + targetcount + "]' value='" + $("#activetarget").attr("value") + "'/></td><td><a href=''>Delete This Target</a></td></tr>");
|
||||
// Add link to remove
|
||||
$("a", content).click(function(event) {
|
||||
event.preventDefault();
|
||||
$(this).parents("tr").remove();
|
||||
if($(this).parents("tr").length == 1) {
|
||||
$("#jobSubmitButton").attr("disabled", true).attr("value", "You Must Provide At Least One Target");
|
||||
}
|
||||
});
|
||||
$("#targetinputrow").before(content);
|
||||
$("#activetarget").attr("value", "");
|
||||
|
||||
// Automatically set the button and enable the form
|
||||
$("#jobSubmitButton").attr("disabled", false).attr("value", "Begin Auto-Discovery Job");
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
fieldset {
|
||||
border:1px solid #CCCCCC;
|
||||
margin:1em 0pt;
|
||||
padding:1em;
|
||||
}
|
||||
legend {
|
||||
font-weight:bold;
|
||||
}
|
||||
label {
|
||||
display:block;
|
||||
}
|
||||
|
||||
.checks label {
|
||||
width:15em;
|
||||
display: inline;
|
||||
float: none;
|
||||
}
|
||||
|
||||
.checks p {
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
if(!isset($autodiscoveryJob)) {
|
||||
$c = new Criteria();
|
||||
$c->add(AutodiscoveryJobPeer::END_TIME, null);
|
||||
$autodiscoveryJobs = autodiscoveryJobPeer::doSelect($c);
|
||||
if($autodiscoveryJobs) {
|
||||
print_window_header("Jobs In Progress", "100%");
|
||||
?>
|
||||
There appears to be running autodiscovery jobs. There should only be one running. If there are multiple showing as running, you should cancel them or purge them. Click on a job to
|
||||
view it's progress and it's log.
|
||||
<table class="jobs">
|
||||
<tr>
|
||||
<td><strong>Name</strong></td>
|
||||
<td><strong>Description</strong></td>
|
||||
<td><strong>Start Time</strong></td>
|
||||
<td><strong>Status</strong></td>
|
||||
<td colspan="2"><strong>Actions</strong></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach($autodiscoveryJobs as $job) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $job->getName();?></td>
|
||||
<td><?php echo $job->getDescription();?></td>
|
||||
<td><?php echo $job->getStartTime();?></td>
|
||||
<td><?php echo $job->getStatus();?></td>
|
||||
<td><a href="autodiscovery.php?id=<?php echo $job->getId();?>">View Job</a></td>
|
||||
<td><a href="autodiscovery.php?id=<?php echo $job->getId();?>&action=restart">Restart</a></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
print_window_footer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
print_window_header("Create New Auto Discovery Job", "100%", "center");
|
||||
?>
|
||||
To begin an auto-discovery of your configuration, an Auto Discovery Job must be defined. Configure your auto discovery job below. Once created, your auto discovery
|
||||
job will begin in the background. You will be able to check on the status of your job and view it's log as it continues running. You are advised to NOT edit anything
|
||||
in Lilac while your job is running.
|
||||
<br />
|
||||
<form name="autodiscovery_job" method="post" action="autodiscovery.php">
|
||||
<input type="hidden" name="request" value="autodiscover" />
|
||||
<p>
|
||||
<fieldset>
|
||||
<legend>Job Definition</legend>
|
||||
<label for="job_name">Job Name</label>
|
||||
<input id="job_name" name="job_name" type="text" size="100" maxlength="255" />
|
||||
<label for="job_description">Job Description</label>
|
||||
<textarea id="job_description" name="job_description" name="job_description" rows="5" cols="80" /></textarea>
|
||||
</fieldset>
|
||||
</p>
|
||||
<p>
|
||||
<fieldset>
|
||||
<legend>Discovery Options</legend>
|
||||
<p>
|
||||
<label for="nmap_binary">NMAP Binary Location</label>
|
||||
<input id="nmap_binary" name="nmap_binary" type="text" size="100" maxlength="255" value="/usr/bin/nmap" />
|
||||
</p>
|
||||
<p>
|
||||
<input id="traceroute_enabled" name="traceroute_enabled" type="checkbox" checked="checked" /> Enable Traceroute to Determine Parent Host<br />
|
||||
</p>
|
||||
<p>
|
||||
<label for="default_template">Default Template If No Templates Match</label>
|
||||
<?php
|
||||
$templates = NagiosHostTemplatePeer::doSelect(new Criteria());
|
||||
$options[] = array(
|
||||
'option' => 'None',
|
||||
'value' => ''
|
||||
);
|
||||
foreach($templates as $template) {
|
||||
$options[] = array(
|
||||
'option' => $template->getName(),
|
||||
'value' => $template->getId()
|
||||
);
|
||||
}
|
||||
print_select("default_template", $options, "value" , "option", '');
|
||||
?>
|
||||
</p>
|
||||
</fieldset>
|
||||
</p>
|
||||
<p>
|
||||
<fieldset>
|
||||
<legend>Target Specification</legend>
|
||||
<p>
|
||||
<table id="targets">
|
||||
<tr id="targetinputrow">
|
||||
<td>
|
||||
<input id="activetarget" type="text"size="40"></td><td><a id="addtargetlink" href="">Add Target</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
Provide an IP address or range of ip addresses in NMAP-accepted style. See <a target="_blank" href="http://insecure.org/nmap/man/man-target-specification.html">Target Specification</a> for examples.
|
||||
</p>
|
||||
</fieldset>
|
||||
</p>
|
||||
<input id="jobSubmitButton" type="submit" disabled="disabled" value="You Must Provide At Least One Target" />
|
||||
<?php
|
||||
print_window_footer();
|
||||
}
|
||||
else if(!isset($_GET['review'])) {
|
||||
?>
|
||||