first commit

master
Benoît S. 12 years ago
commit ee27384fa3

@ -0,0 +1 @@
Please refer to www.lilacplatform.com for documentation on installation and bug reporting.

@ -0,0 +1,281 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

@ -0,0 +1 @@
Lilac is intended to be installed from scratch.

@ -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" />&nbsp;[ <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" />&nbsp;[ <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() . "&section=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() . "&section=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() . "&section=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" />&nbsp;[ <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" />&nbsp;[ <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'])) {
?>