first commit
This commit is contained in:
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,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'])) {
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
$stats = $autodiscoveryJob->getStats();
|
||||||
|
if($stats) {
|
||||||
|
$stats = unserialize($stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
print_window_header("Job Details", "100%");
|
||||||
|
?>
|
||||||
|
<strong>Job Name:</strong> <?php echo $autodiscoveryJob->getName();?><br />
|
||||||
|
<?php echo $autodiscoveryJob->getDescription();?>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<strong>Start Time:</strong> <?php echo $autodiscoveryJob->getStartTime();?><br />
|
||||||
|
<br />
|
||||||
|
<?php
|
||||||
|
if(!in_array($autodiscoveryJob->getStatusCode(), array(AutodiscoveryJob::STATUS_FAILED, AutodiscoveryJob::STATUS_FINISHED) )) {
|
||||||
|
?>
|
||||||
|
<strong>Elapsed Time:</strong> <span id="elapsedtime">Unknown</span>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if($autodiscoveryJob->getStatusCode() == AutodiscoveryJob::STATUS_FAILED) {
|
||||||
|
?>
|
||||||
|
<strong>Time of Failure:</strong> <?php echo $autodiscoveryJob->getStatusChangeTime();?>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
?>
|
||||||
|
<strong>Time When Completed:</strong> <?php echo $autodiscoveryJob->getStatusChangeTime();?>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<br />
|
||||||
|
<strong>Current Status:</strong> <span id="jobstatus"><?php echo $autodiscoveryJob->getStatus();?></span><br />
|
||||||
|
<?php
|
||||||
|
$config = unserialize($autodiscoveryJob->getConfig());
|
||||||
|
?>
|
||||||
|
<a id="completemsg" href="autodiscovery.php?id=<?php echo $autodiscoveryJob->getid();?>&review=1" <?php if($autodiscoveryJob->getStatusCode() != AutodiscoveryJob::STATUS_FINISHED ) { ?>style="display: none;"<?php } ?>>
|
||||||
|
<div class="roundedcorner_success_box">
|
||||||
|
<div class="roundedcorner_success_top"><div></div></div>
|
||||||
|
<div class="roundedcorner_success_content">
|
||||||
|
Auto-Discovery Complete. Click to Continue To Reviewing Found Devices
|
||||||
|
</div>
|
||||||
|
<div class="roundedcorner_success_bottom"><div></div></div>
|
||||||
|
</div></a>
|
||||||
|
|
||||||
|
<a href="autodiscovery.php?id=<?php echo $autodiscoveryJob->getId();?>&action=restart">Restart Job</a> | <a href="autodiscovery.php?id=<?php echo $autodiscoveryJob->getId();?>&delete=1" onclick="javascript:confirmDelete();">Remove Job</a> | <a href="autodiscovery.php">Return To AutoDiscovery Menu</a>
|
||||||
|
<?php
|
||||||
|
print_window_footer();
|
||||||
|
print_window_header("Job Log");
|
||||||
|
?>
|
||||||
|
<div id="joblog">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
print_window_footer();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(!isset($_GET['deviceId'])) {
|
||||||
|
// We're going to review
|
||||||
|
print_window_header("Auto-Discovery Results");
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
$(".checkAllLink").click(function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
$(".autodiscoveryCheckbox").attr("checked", true);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".uncheckAllLink").click(function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
$(".autodiscoveryCheckbox").attr("checked", false);
|
||||||
|
});
|
||||||
|
$(".autodiscoveryCheckbox").attr("checked", false);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<a href="autodiscovery.php?id=<?php echo $autodiscoveryJob->getId();?>">Return To Auto-Discovery Job</a>
|
||||||
|
<div>
|
||||||
|
<?php
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AutodiscoveryDevicePeer::JOB_ID, $autodiscoveryJob->getId());
|
||||||
|
$devices = AutodiscoveryDevicePeer::doSelect($c);
|
||||||
|
if(empty($devices)) {
|
||||||
|
?>
|
||||||
|
<br />
|
||||||
|
<h3>No Devices Available For Import</h3>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
?>
|
||||||
|
<br />
|
||||||
|
<h3><?php echo count($devices);?> Device(s) Available For Import</h3>
|
||||||
|
<br />
|
||||||
|
<form action="autodiscovery.php?id=<?php echo $_GET['id'];?>&review=1" method="post">
|
||||||
|
<input type="hidden" name="request" value="process" />
|
||||||
|
|
||||||
|
<table class="tablelist">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Address
|
||||||
|
</td>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>
|
||||||
|
Description
|
||||||
|
</td>
|
||||||
|
<td>Parent</td>
|
||||||
|
<td>Hostname</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
Template Assigned
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Actions
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<?php
|
||||||
|
foreach($devices as $device) {
|
||||||
|
?>
|
||||||
|
<tr class="alt">
|
||||||
|
<td><input class="autodiscoveryCheckbox" type="checkbox" name="selectedDevices[]" value="<?php echo $device->getId();?>" /></td>
|
||||||
|
<td>
|
||||||
|
<?php echo $device->getAddress();?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $device->getName();?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $device->getDescription();?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
$parent = $device->getNagiosHost();
|
||||||
|
if(empty($parent)) {
|
||||||
|
?>Top-Level<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print($parent->getName());
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<?php echo $device->getHostname();?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
if(!$device->getHostTemplate()) {
|
||||||
|
?>None Assigned<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$hostTemplate = NagiosHostTemplatePeer::retrieveByPK($device->getHostTemplate());
|
||||||
|
if(!empty($hostTemplate)) {
|
||||||
|
print($hostTemplate->getName());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print("Template Not Found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="autodiscovery.php?id=<?php echo $autodiscoveryJob->getId();?>&review=1&deviceId=<?php echo $device->getId();?>">Modify Details</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
<a class="checkAllLink" href="#">Check All</a> / <a class="uncheckAllLink" href="#">Un-Check All</a> With Selected: <select>
|
||||||
|
<option value="accept">Import</option>
|
||||||
|
<option value="remove">Remove</option>
|
||||||
|
</select> <input type="submit" value="Process" /> </form>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
print_window_footer();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print_window_header("Device Details");
|
||||||
|
?>
|
||||||
|
[ <a href="autodiscovery.php?id=<?php echo $device->getAutodiscoveryJob()->getId();?>&review=1">Return To Device List</a> ]
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<h3>General Information</h3>
|
||||||
|
<table class="tablelist">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Address</td>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>Description</td>
|
||||||
|
<td>Parent</td>
|
||||||
|
<td>Hostname</td>
|
||||||
|
<td>OS Family</td>
|
||||||
|
<td>OS Generation</td>
|
||||||
|
<td>OS Vendor</td>
|
||||||
|
<td>Template Assigned</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $device->getAddress(); ?></td>
|
||||||
|
<td><?php echo $device->getName(); ?></td>
|
||||||
|
<td><?php echo $device->getDescription(); ?></td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
$parent = $device->getNagiosHost();
|
||||||
|
if(empty($parent)) {
|
||||||
|
?>Top-Level<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print($parent->getName());
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td><?php echo $device->getHostname(); ?></td>
|
||||||
|
|
||||||
|
<td><?php echo $device->getOsfamily(); ?></td>
|
||||||
|
<td><?php echo $device->getOsgen(); ?></td>
|
||||||
|
<td><?php echo $device->getOsvendor(); ?></td>
|
||||||
|
<td> <?php
|
||||||
|
if(!$device->getHostTemplate()) {
|
||||||
|
?>None Assigned<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$hostTemplate = NagiosHostTemplatePeer::retrieveByPK($device->getHostTemplate());
|
||||||
|
if(!empty($hostTemplate)) {
|
||||||
|
print($hostTemplate->getName());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print("Template Not Found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
<h3>Update General Information</h3>
|
||||||
|
<form action="autodiscovery.php?id=<?php echo $_GET['id'];?>&review=1&deviceId=<?php echo $device->getId();?>" method="post">
|
||||||
|
<input type="hidden" name="request" value="updateGeneral" />
|
||||||
|
<strong>Name: </strong><input type="text" value="<?php echo $device->getName();?>" name="name" size="40" maxlength="255" /> <strong>Description: </strong><input value="<?php echo $device->getDescription();?>" type="text" name="description" size="40" maxlength="255" />
|
||||||
|
<input type="submit" value="Update General" />
|
||||||
|
|
||||||
|
</form>
|
||||||
|
<br />
|
||||||
|
<h3>Change Template Assignment</h3>
|
||||||
|
<form action="autodiscovery.php?id=<?php echo $_GET['id'];?>&review=1&deviceId=<?php echo $device->getId();?>" method="post">
|
||||||
|
<input type="hidden" name="request" value="assignTemplate" />
|
||||||
|
<?php
|
||||||
|
$matchedTemplates = $device->getTemplateMatches();
|
||||||
|
$options = array();
|
||||||
|
$options[] = array(
|
||||||
|
'option' => 'None',
|
||||||
|
'value' => ''
|
||||||
|
);
|
||||||
|
$searchArray = array();
|
||||||
|
foreach($matchedTemplates as $match) {
|
||||||
|
$options[] = array(
|
||||||
|
'option' => $match->getNagiosHostTemplate()->getName() . " - " . $match->getPercent() . "%",
|
||||||
|
'value' => $match->getNagiosHostTemplate()->getId()
|
||||||
|
);
|
||||||
|
$searchArray[] = $match->getNagiosHostTemplate()->getId();
|
||||||
|
}
|
||||||
|
// Add the rest of the templates
|
||||||
|
$templates = NagiosHostTemplatePeer::doSelect(new Criteria());
|
||||||
|
foreach($templates as $template) {
|
||||||
|
if(!in_array($template->getId(), $searchArray)) {
|
||||||
|
$options[] = array(
|
||||||
|
'option' => $template->getName() . " - n/a",
|
||||||
|
'value' => $template->getId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print_select("template", $options, "value", "option", $device->getHostTemplate());
|
||||||
|
?> <input type="submit" value="Assign Template" /> [ <a href="autodiscovery.php?id=<?php echo $_GET['id'];?>&review=1&deviceId=<?php echo $device->getId();?>&request=recalc">Recalculate Template Matches</a> ]
|
||||||
|
</form>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<?php
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AutodiscoveryDeviceServicePeer::DEVICE_ID, $device->getId());
|
||||||
|
$services = AutodiscoveryDeviceServicePeer::doSelect($c);
|
||||||
|
if(empty($services)) {
|
||||||
|
?>
|
||||||
|
<p>
|
||||||
|
<h3>No Services Were Found On This Device</h3>
|
||||||
|
</p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
?>
|
||||||
|
<h3>Found <?php echo count($services);?> Service(s)</h3>
|
||||||
|
<table class="tablelist">
|
||||||
|
<?php
|
||||||
|
$tmp = 0;
|
||||||
|
foreach($services as $service) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td <?php if($tmp++ % 2) echo "class=\"alt\"";?>>
|
||||||
|
<h3><?php echo $service->getName();?> on port <?php echo $service->getProtocol();?>/<?php echo $service->getPort(); ?></h3>
|
||||||
|
<strong>Product: </strong><?php echo $service->getProduct(); ?><br />
|
||||||
|
<strong>Version: </strong><?php echo $service->getVersion(); ?><br />
|
||||||
|
<strong>Extra Information: </strong><?php echo $service->getExtraInfo(); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
print_window_footer();
|
||||||
|
}
|
||||||
|
|
||||||
|
print_footer();
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,183 @@
|
||||||
|
<?php
|
||||||
|
// Run as background process
|
||||||
|
/**
|
||||||
|
* Lilac Nagios Configuration Auto Discovery Script
|
||||||
|
*/
|
||||||
|
// This is a dirty hack to allow calling from command line and from cli. I'd like to figure out
|
||||||
|
// a better way to do this.
|
||||||
|
|
||||||
|
$webcall = false;
|
||||||
|
|
||||||
|
if(file_exists('autodiscovery')) {
|
||||||
|
chdir('autodiscovery');
|
||||||
|
$webcall = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
print(getcwd());
|
||||||
|
|
||||||
|
include_once('../includes/config.inc');
|
||||||
|
require_once('classes.inc.php');
|
||||||
|
require_once('engines/nmap/NmapAutoDiscoveryEngine.php');
|
||||||
|
include_once('AutodiscoveryJob.php');
|
||||||
|
include_once('AutodiscoveryLogEntry.php');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Potential Errors
|
||||||
|
* 10 - No job id provided on command line
|
||||||
|
* 20 - Job not found in database
|
||||||
|
* 30 - Import Engine not found (name provided in ImportConfig)
|
||||||
|
* 40 - Some error failure. View import job logs.
|
||||||
|
* 42 - SUCCESS WHEN FORKING SCRIPT
|
||||||
|
*/
|
||||||
|
|
||||||
|
set_time_limit(0); // Remove time limit
|
||||||
|
|
||||||
|
|
||||||
|
if($webcall) {
|
||||||
|
if (pcntl_fork()) { // Fork process
|
||||||
|
exit(42); // This marks a successful fork, so we should return success to the caller
|
||||||
|
}
|
||||||
|
|
||||||
|
posix_setsid(); // Make child process session leader
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Okay, we're now in our own execution space. Let's begin
|
||||||
|
// We need to restart Propel to regain access to the DB
|
||||||
|
Propel::init(LILAC_FS_ROOT . "includes/lilac-conf.php");
|
||||||
|
|
||||||
|
if(isset($argv[1]) && is_numeric($argv[1])) {
|
||||||
|
$autodiscoveryJob = AutodiscoveryJobPeer::retrieveByPK($argv[1]);
|
||||||
|
if(!$autodiscoveryJob) {
|
||||||
|
print "Job with id: " . $argv[1] . " not found.\n";
|
||||||
|
exit(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
$autodiscoveryJob->setStartTime(time());
|
||||||
|
$autodiscoveryJob->clearLog();
|
||||||
|
$autodiscoveryJob->save();
|
||||||
|
|
||||||
|
|
||||||
|
// Okay, let's get the AutodiscoveryConfig
|
||||||
|
$config = $autodiscoveryJob->getConfig();
|
||||||
|
$config = unserialize($config);
|
||||||
|
|
||||||
|
$engineClass = $config->getEngineClass();
|
||||||
|
|
||||||
|
if(!class_exists($engineClass) || !is_subclass_of($engineClass, "AutodiscoveryEngine")) {
|
||||||
|
$autodiscoveryJob->addError("Autodiscovery Engine of type " . $engineClass . " not found.");
|
||||||
|
exit(30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "No job id provided.\n";
|
||||||
|
exit(10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$autodiscoveryJob->addNotice("Starting Background Auto Discovery Process for Job: " . $autodiscoveryJob->getName());
|
||||||
|
$autodiscoveryJob->setStatus("Running");
|
||||||
|
$autodiscoveryJob->setStatusCode(AutodiscoveryJob::STATUS_RUNNING);
|
||||||
|
$autodiscoveryJob->save();
|
||||||
|
|
||||||
|
$autodiscoveryJob->addNotice("Removing old devices found in this job.");
|
||||||
|
$devices = $autodiscoveryJob->getAutodiscoveryDevices();
|
||||||
|
foreach($devices as $device) {
|
||||||
|
$device->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$defaultTemplateId = $config->getVar("default_template");
|
||||||
|
if(!empty($defaultTemplateId)) {
|
||||||
|
$autodiscoveryJob->addNotice("Fetching Default Template...");
|
||||||
|
$defaultTemplate = NagiosHostTemplatePeer::retrieveByPK($defaultTemplateId);
|
||||||
|
if(!$defaultTemplate) {
|
||||||
|
$autodiscoveryJob->addNotice("Failed to find default template requested. Will not be able to assign a default template.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$autodiscoveryJob->addNotice("Initializing Auto Discovery Engine: " . $engineClass);
|
||||||
|
|
||||||
|
$engine = new $engineClass($autodiscoveryJob);
|
||||||
|
if(!$engine->init()) {
|
||||||
|
$autodiscoveryJob->addError("Engine failed to initialize.");
|
||||||
|
$importJob->addError("Auto Discovery Engine of type " . $engineClass . " not found.");
|
||||||
|
$autodiscoveryJob->setStatusCode(AutodiscoveryJob::STATUS_FAILED);
|
||||||
|
$autodiscoveryJob->save();
|
||||||
|
exit(40);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$engine->discover()) {
|
||||||
|
$autodiscoveryJob->addError("Engine autodiscovery process failed to complete successfully.");
|
||||||
|
$autodiscoveryJob->setStatus("Failed");
|
||||||
|
$autodiscoveryJob->setStatusCode(AutodiscoveryJob::STATUS_FAILED);
|
||||||
|
$autodiscoveryJob->save();
|
||||||
|
exit(40);
|
||||||
|
}
|
||||||
|
$autodiscoveryJob->addNotice("Engine completed discovering devices");
|
||||||
|
|
||||||
|
$tracerouteEnabled = $config->getVar("traceroute_enabled");
|
||||||
|
|
||||||
|
$tracerouteEnabled = false;
|
||||||
|
|
||||||
|
if(!$tracerouteEnabled) {
|
||||||
|
$autodiscoveryJob->addNotice("Tracerouting skipped. Hosts will be set as top-level.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$autodiscoveryJob->addNotice("Beginning Traceroute for found hosts.");
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AutodiscoveryDevicePeer::JOB_ID, $autodiscoveryJob->getId());
|
||||||
|
$devices = AutodiscoveryDevicePeer::doSelect($c);
|
||||||
|
foreach($devices as $device) {
|
||||||
|
$autodiscoveryJob->addNotice("Attempting Traceroute to " . $device->getAddress());
|
||||||
|
$tr = Net_Traceroute::factory();
|
||||||
|
if(!PEAR::isError($tr)) {
|
||||||
|
$response = $tr->traceroute($device->getAddress());
|
||||||
|
$hops = $response->getHops();
|
||||||
|
$numOfHops = count($hops);
|
||||||
|
$found = false;
|
||||||
|
for($counter = $numOfHops - 1; $counter >= 0; $counter--) {
|
||||||
|
|
||||||
|
// Check the farthest hop first
|
||||||
|
$c = new Criteria();
|
||||||
|
$c1 = $c->getNewCriterion(NagiosHostPeer::ADDRESS, $hops[$counter]['ip']);
|
||||||
|
$c2 = $c->getNewCriterion(NagiosHostPeer::ADDRESS, $hops[$counter['machine']]);
|
||||||
|
$c1->addOr($c2);
|
||||||
|
$c->add($c1);
|
||||||
|
$host = NagiosHostPeer::doSelectOne($c);
|
||||||
|
if($host) {
|
||||||
|
// Found parent
|
||||||
|
$autodiscoveryJob->addNotice("Found parent: " . $host->getName());
|
||||||
|
$device->setProposedParent($host->getId());
|
||||||
|
$device->save();
|
||||||
|
$found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$found) {
|
||||||
|
$autodiscoveryJob->addNotice("Could not find a suitable parent. Setting as a top-level device.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$autodiscoveryJob->addNotce("Failed to run Traceroute. Not using it.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Okay, now we start doing the magic.
|
||||||
|
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AutodiscoveryDevicePeer::JOB_ID, $autodiscoveryJob->getId());
|
||||||
|
$devices = AutodiscoveryDevicePeer::doSelect($c);
|
||||||
|
|
||||||
|
foreach($devices as $device) {
|
||||||
|
$autodiscoveryJob->addNotice("Performing template matching for device: " . $device->getAddress());
|
||||||
|
AutodiscoveryMatchMaker::match($device, $defaultTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
$autodiscoveryJob->addNotice("Completed Auto Discovery.");
|
||||||
|
$autodiscoveryJob->setStatus("Finished.");
|
||||||
|
$autodiscoveryJob->setStatusCode(AutodiscoveryJob::STATUS_FINISHED);
|
||||||
|
$autodiscoveryJob->save();
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,270 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
abstract class AutoDiscoverer {
|
||||||
|
private $engine;
|
||||||
|
|
||||||
|
public function __construct($engine) {
|
||||||
|
$this->engine = $engine;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* @return AutoDiscoveryEngine
|
||||||
|
*/
|
||||||
|
public function getEngine() {
|
||||||
|
return $this->engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class AutoDiscoveryEngine {
|
||||||
|
// Currently empty, but used to potentially employ rules later on
|
||||||
|
private $job;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* @param ImportJob $importJob
|
||||||
|
*/
|
||||||
|
public function __construct($importJob) {
|
||||||
|
$this->job = $importJob;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* @return AutodiscoveryJob
|
||||||
|
*/
|
||||||
|
public function getJob() {
|
||||||
|
return $this->job;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getConfig() {
|
||||||
|
return unserialize($this->job->getConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStats() {
|
||||||
|
$stats = $this->job->getStats();
|
||||||
|
if(!$stats) {
|
||||||
|
// Create stats on the fly
|
||||||
|
$stats = new ImportStats();
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$stats = unserialize($stats);
|
||||||
|
}
|
||||||
|
$stats->setJob($this->job);
|
||||||
|
return $stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should be used for any startup
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
abstract function init();
|
||||||
|
|
||||||
|
abstract function discover();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currently implemented using a hash map, but we could potentially do more than this?
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class AutodiscoveryConfig {
|
||||||
|
private $configVars;
|
||||||
|
|
||||||
|
private $engineClass;
|
||||||
|
|
||||||
|
public function __construct($engine) {
|
||||||
|
$this->engineClass = $engine;
|
||||||
|
$this->configVars = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEngineClass() {
|
||||||
|
return $this->engineClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setVar($name, $val) {
|
||||||
|
$this->configVars[$name] = $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVar($name) {
|
||||||
|
if(isset($this->configVars[$name]))
|
||||||
|
return $this->configVars[$name];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currently implemented using a hash map, but we could potentially do more than this?
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class AutodiscoveryStats {
|
||||||
|
private $stats;
|
||||||
|
private $job; // Won't be serialized since it will be a reference
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->stats = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setJob($importJob) {
|
||||||
|
$this->job = $importJob;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStat($name, $val) {
|
||||||
|
$this->stats[$name] = $val;
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStat($name) {
|
||||||
|
return $this->stats[$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save() {
|
||||||
|
if(isset($job)) {
|
||||||
|
$job->setStats(serialize($his));
|
||||||
|
$this->job->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class AutodiscoveryMatchMaker {
|
||||||
|
|
||||||
|
private function __construct() {
|
||||||
|
// We don't allow instances of this class
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function match(AutodiscoveryDevice $device, NagiosHostTemplate $defaultTemplate = null) {
|
||||||
|
|
||||||
|
// Delete previous matches
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AutodiscoveryDeviceTemplateMatchPeer::DEVICE_ID, $device->getId());
|
||||||
|
AutodiscoveryDeviceTemplateMatchPeer::doDelete($c);
|
||||||
|
|
||||||
|
$templates = NagiosHostTemplatePeer::doSelect(new Criteria());
|
||||||
|
$templateMatches = array();
|
||||||
|
foreach($templates as $template) {
|
||||||
|
$templateValues = $template->getValues();
|
||||||
|
$complexity = 0;
|
||||||
|
$match = 0;
|
||||||
|
$serviceFilters = $template->getNagiosHostTemplateAutodiscoveryServices();
|
||||||
|
$inheritedServiceFilters = $template->getInheritedNagiosAutodiscoveryServiceFilters();
|
||||||
|
$serviceFilters = array_merge($serviceFilters, $inheritedServiceFilters);
|
||||||
|
|
||||||
|
if(!empty($templateValues['autodiscovery_address_filter']) && $templateValues['autodiscovery_address_filter']['value'] != '') {
|
||||||
|
$complexity++;
|
||||||
|
if(preg_match($templateValues['autodiscovery_address_filter']['value'], $device->getAddress())) {
|
||||||
|
$match++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($templateValues['autodiscovery_hostname_filter']) && $templateValues['autodiscovery_hostname_filter']['value'] != '') {
|
||||||
|
$complexity++;
|
||||||
|
if(preg_match($templateValues['autodiscovery_hostname_filter']['value'], $device->getHostname())) {
|
||||||
|
$match++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($templateValues['autodiscovery_os_family_filter']) && $templateValues['autodiscovery_os_family_filter']['value'] != '') {
|
||||||
|
$complexity++;
|
||||||
|
if(preg_match($templateValues['autodiscovery_os_family_filter']['value'], $device->getOsfamily())) {
|
||||||
|
$match++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($templateValues['autodiscovery_os_generation_filter']) && $templateValues['autodiscovery_os_generation_filter']['value'] != '') {
|
||||||
|
$complexity++;
|
||||||
|
if(preg_match($templateValues['autodiscovery_os_generation_filter']['value'], $device->getOsgen())) {
|
||||||
|
$match++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($templateValues['autodiscovery_os_vendor_filter']) && $templateValues['autodiscovery_os_vendor_filter']['value'] != '') {
|
||||||
|
$complexity++;
|
||||||
|
if(preg_match($templateValues['autodiscovery_os_vendor_filter']['value'], $device->getOsvendor())) {
|
||||||
|
$match++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Checked bases, let's now check service filters
|
||||||
|
$complexity += count($serviceFilters);
|
||||||
|
foreach($serviceFilters as $filter) {
|
||||||
|
foreach($device->getAutodiscoveryDeviceServices() as $service) {
|
||||||
|
if($filter->getPort() == $service->getPort() && $filter->getProtocol() == $service->getProtocol()) {
|
||||||
|
// Okay, we're ALMOST found...let's see if we have any other additional filters.
|
||||||
|
$tempMatch = true;
|
||||||
|
if($filter->getName() != '') {
|
||||||
|
if(!preg_match($filter->getName(), $service->getName())) {
|
||||||
|
$tempMatch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($filter->getProduct() != '') {
|
||||||
|
if(!preg_match($filter->getProduct(), $service->getProduct())) {
|
||||||
|
$tempMatch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($filter->getVersion() != '') {
|
||||||
|
if(!preg_match($filter->getVersion(), $service->getVersion())) {
|
||||||
|
$tempMatch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($filter->getExtraInformation() != '') {
|
||||||
|
if(!preg_match($filter->getExtraInformation(), $service->getExtraInformation())) {
|
||||||
|
$tempMatch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($tempMatch) {
|
||||||
|
$match++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Okay, we got everything, let's determine the percentage.
|
||||||
|
if($complexity == 0) {
|
||||||
|
// Blank template, no auto-discovery features used.
|
||||||
|
$percentage = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$percentage = (int)(((float)$match / (float)$complexity)*100);
|
||||||
|
}
|
||||||
|
if($percentage == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the template into the array
|
||||||
|
$templateMatches[$percentage][$complexity][] = $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Okay, let's now create the matches
|
||||||
|
$percentages = array_keys($templateMatches);
|
||||||
|
$assigned = false;
|
||||||
|
for($percentageCounter = 0; $percentageCounter < count($percentages); $percentageCounter++) {
|
||||||
|
$complexities = array_keys($templateMatches[$percentages[$percentageCounter]]);
|
||||||
|
$complexities = array_reverse($complexities);
|
||||||
|
for($complexityCount = 0; $complexityCount < count($complexities); $complexityCount++) {
|
||||||
|
foreach($templateMatches[$percentages[$percentageCounter]][$complexities[$complexityCount]] as $template) {
|
||||||
|
$match = new AutodiscoveryDeviceTemplateMatch();
|
||||||
|
$match->setAutodiscoveryDevice($device);
|
||||||
|
$match->setNagiosHostTemplate($template);
|
||||||
|
$match->setPercent($percentages[$percentageCounter]);
|
||||||
|
$match->setComplexity($complexities[$complexityCount]);
|
||||||
|
$match->save();
|
||||||
|
// Add the highest match as the template to assign
|
||||||
|
if(!$assigned) {
|
||||||
|
$assigned = true;
|
||||||
|
$device->setNagiosHostTemplate($template);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If Not assigned, assign default template
|
||||||
|
if(!$assigned && !empty($defaultTemplate)) {
|
||||||
|
$device->setNagiosHostTemplate($defaultTemplate);
|
||||||
|
}
|
||||||
|
$device->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
require_once('Net/Traceroute.php');
|
||||||
|
|
||||||
|
class NmapAutoDiscoveryEngine extends AutoDiscoveryEngine {
|
||||||
|
|
||||||
|
private $xmlFile;
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
$job = $this->getJob();
|
||||||
|
|
||||||
|
$this->xmlFile = "/tmp/" . $job->getId() . "-nmap.xml";
|
||||||
|
|
||||||
|
$job->addNotice("Removing potential old job files.");
|
||||||
|
@unlink($xmlFile);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function discover() {
|
||||||
|
$job = $this->getJob();
|
||||||
|
$job->addNotice("Starting discovery...");
|
||||||
|
|
||||||
|
$config = unserialize($job->getConfig());
|
||||||
|
|
||||||
|
$targets = $config->getVar("targets");
|
||||||
|
|
||||||
|
// Each target is valid
|
||||||
|
|
||||||
|
// We have a list of targets
|
||||||
|
$nmap_flags = "--max-rtt-timeout 100 --max-retries 0 -sS -O -A -v -oX " . $this->xmlFile;
|
||||||
|
|
||||||
|
$exec_line = "sudo " . $config->getVar("nmap_binary") . " " . $nmap_flags . " ";
|
||||||
|
foreach($targets as $target) {
|
||||||
|
$exec_line .= $target . " ";
|
||||||
|
}
|
||||||
|
$job->addNotice("Executing nmap via: " . $exec_line . "\n");
|
||||||
|
|
||||||
|
$completed = false;
|
||||||
|
// Open the process
|
||||||
|
$handle = popen($exec_line, 'r'); // Only need it for reading
|
||||||
|
while(!feof($handle)) {
|
||||||
|
// nmap is running!
|
||||||
|
$line = fgets($handle);
|
||||||
|
if(strlen(trim($line))) $job->addNotice("NMAP: " . $line);
|
||||||
|
if(strpos($line, "Nmap done") === 0 || strpos($line, "Nmap finished") === 0) {
|
||||||
|
// Nmap is finished
|
||||||
|
$completed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$completed) {
|
||||||
|
$job->addError("Nmap failed to complete successfully. Could be permissions issue (check sudo access). Aborting discovery.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$job->addNotice("Nmap finished discovery. Now reading in result XML.");
|
||||||
|
$nmapXML = simplexml_load_file($this->xmlFile);
|
||||||
|
// Read in hosts
|
||||||
|
$job->addNotice("Number of hosts: " . count($nmapXML->host));
|
||||||
|
|
||||||
|
foreach($nmapXML->host as $host) {
|
||||||
|
$job->addNotice('Found ' . $host->address[0]['addr'] . ':' . $host->hostnames[0]->hostname[0]['name'] . '.');
|
||||||
|
|
||||||
|
$c = new Criteria();
|
||||||
|
$c1 = $c->getNewCriterion(NagiosHostPeer::ADDRESS, $host->address[0]['addr']);
|
||||||
|
$c2 = $c->getNewCriterion(NagiosHostPeer::ADDRESS, $host->hostnames[0]->hostname[0]['name']);
|
||||||
|
$c1->addOr($c2);
|
||||||
|
$c->add($c1);
|
||||||
|
$tempHost = NagiosHostPeer::doSelectOne($c);
|
||||||
|
if($tempHost) {
|
||||||
|
$job->addNotice("Device appears to already be in configuration under hostname: " . $host->getName() . ". Skipping.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$device = new AutodiscoveryDevice();
|
||||||
|
$device->setAutodiscoveryJob($job);
|
||||||
|
$device->setAddress($host->address[0]['addr']);
|
||||||
|
if(empty($host->hostnames[0]->hostname[0]['name'])) {
|
||||||
|
$device->setName($host->address[0]['addr']);
|
||||||
|
$device->setDescription($host->address[0]['addr']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$device->setName($host->hostnames[0]->hostname[0]['name']);
|
||||||
|
$device->setDescription($host->hostnames[0]->hostname[0]['name']);
|
||||||
|
}
|
||||||
|
$device->setHostname($host->hostnames[0]->hostname[0]['name']);
|
||||||
|
// Right now, if it exists, we pick the top-level matching os string (since it's the highest scored)
|
||||||
|
if(!empty($host->os[0]->osclass[0]['osfamily'])) {
|
||||||
|
// We found os family data
|
||||||
|
$device->setOsfamily($host->os[0]->osclass[0]['osfamily']);
|
||||||
|
}
|
||||||
|
if(!empty($host->os[0]->osclass[0]['osgen'])) {
|
||||||
|
// We found os family data
|
||||||
|
$device->setOsgen($host->os[0]->osclass[0]['osgen']);
|
||||||
|
}
|
||||||
|
if(!empty($host->os[0]->osclass[0]['vendor'])) {
|
||||||
|
// We found os family data
|
||||||
|
$device->setOsvendor($host->os[0]->osclass[0]['vendor']);
|
||||||
|
}
|
||||||
|
$device->save();
|
||||||
|
// Add services
|
||||||
|
$job->addNotice("Number of ports for this host: " . count($host->ports[0]->port));
|
||||||
|
|
||||||
|
foreach($host->ports[0]->port as $port) {
|
||||||
|
// $port signifies as port / possible service, we'll grab that
|
||||||
|
$service = new AutodiscoveryDeviceService();
|
||||||
|
$service->setProtocol($port['protocol']);
|
||||||
|
$service->setPort($port['portid']);
|
||||||
|
if(!empty($port->service[0]['name'])) {
|
||||||
|
$service->setName($port->service[0]['name']);
|
||||||
|
}
|
||||||
|
if(!empty($port->service[0]['product'])) {
|
||||||
|
$service->setProduct($port->service[0]['product']);
|
||||||
|
}
|
||||||
|
if(!empty($port->service[0]['version'])) {
|
||||||
|
$service->setVersion($port->service[0]['version']);
|
||||||
|
}
|
||||||
|
if(!empty($port->service[0]['extrainfo'])) {
|
||||||
|
$service->setExtrainfo($port->service[0]['extrainfo']);
|
||||||
|
}
|
||||||
|
$service->setAutodiscoveryDevice($device);
|
||||||
|
$service->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$job->addNotice("Added devices and services.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
propel.project = lilac
|
||||||
|
propel.database = mysql
|
||||||
|
propel.database.url = mysql:host=localhost;dbname=lilac
|
||||||
|
propel.targetPackage =
|
||||||
|
propel.php.dir = ${propel.project.dir}/classes
|
||||||
|
propel.phpconf.dir = ${propel.project.dir}/includes
|
||||||
|
propel.sql.dir = ${propel.project.dir}/sqldata
|
||||||
|
propel.addTimeStamp = false
|
||||||
|
propel.addGenericAccessors = true
|
||||||
|
propel.addGenericMutators = true
|
|
@ -0,0 +1,301 @@
|
||||||
|
<?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 Index Page, Displays Menu, and Statistics
|
||||||
|
*/
|
||||||
|
include_once('includes/config.inc');
|
||||||
|
|
||||||
|
$cgiConfig = NagiosCgiConfigurationPeer::doSelectOne(new Criteria());
|
||||||
|
if(!$cgiConfig) {
|
||||||
|
$cgiConfig = new NagiosCgiConfiguration();
|
||||||
|
$cgiConfig->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['request'])) {
|
||||||
|
if($_POST['request'] == 'update') {
|
||||||
|
if(isset($_POST['cgi_config']['physical_html_path']))
|
||||||
|
$cgiConfig->setPhysicalHtmlPath($_POST['cgi_config']['physical_html_path']);
|
||||||
|
if(isset($_POST['cgi_config']['url_html_path']))
|
||||||
|
$cgiConfig->setUrlHtmlPath($_POST['cgi_config']['url_html_path']);
|
||||||
|
if(isset($_POST['cgi_config']['use_authentication']))
|
||||||
|
$cgiConfig->setUseAuthentication($_POST['cgi_config']['use_authentication']);
|
||||||
|
if(isset($_POST['cgi_config']['default_user_name']))
|
||||||
|
$cgiConfig->setDefaultUserName($_POST['cgi_config']['default_user_name']);
|
||||||
|
if(isset($_POST['cgi_config']['authorized_for_system_information']))
|
||||||
|
$cgiConfig->setAuthorizedForSystemInformation($_POST['cgi_config']['authorized_for_system_information']);
|
||||||
|
if(isset($_POST['cgi_config']['authorized_for_system_commands']))
|
||||||
|
$cgiConfig->setAuthorizedForSystemCommands($_POST['cgi_config']['authorized_for_system_commands']);
|
||||||
|
if(isset($_POST['cgi_config']['authorized_for_configuration_information']))
|
||||||
|
$cgiConfig->setAuthorizedForConfigurationInformation($_POST['cgi_config']['authorized_for_configuration_information']);
|
||||||
|
if(isset($_POST['cgi_config']['authorized_for_all_hosts']))
|
||||||
|
$cgiConfig->setAuthorizedForAllHosts($_POST['cgi_config']['authorized_for_all_hosts']);
|
||||||
|
if(isset($_POST['cgi_config']['authorized_for_all_host_commands']))
|
||||||
|
$cgiConfig->setAuthorizedForAllHostCommands($_POST['cgi_config']['authorized_for_all_host_commands']);
|
||||||
|
if(isset($_POST['cgi_config']['authorized_for_all_services']))
|
||||||
|
$cgiConfig->setAuthorizedForAllServices($_POST['cgi_config']['authorized_for_all_services']);
|
||||||
|
if(isset($_POST['cgi_config']['authorized_for_all_service_commands']))
|
||||||
|
$cgiConfig->setAuthorizedForAllServiceCommands($_POST['cgi_config']['authorized_for_all_service_commands']);
|
||||||
|
if(isset($_POST['cgi_config']['statusmap_background_image']))
|
||||||
|
$cgiConfig->setStatusmapBackgroundImage($_POST['cgi_config']['statusmap_background_image']);
|
||||||
|
if(isset($_POST['cgi_config']['default_statusmap_layout']))
|
||||||
|
$cgiConfig->setDefaultStatusmapLayout($_POST['cgi_config']['default_statusmap_layout']);
|
||||||
|
if(isset($_POST['cgi_config']['statuswrl_include']))
|
||||||
|
$cgiConfig->setStatuswrlInclude($_POST['cgi_config']['statuswrl_include']);
|
||||||
|
if(isset($_POST['cgi_config']['default_statuswrl_layout']))
|
||||||
|
$cgiConfig->setDefaultStatuswrlLayout($_POST['cgi_config']['default_statuswrl_layout']);
|
||||||
|
if(isset($_POST['cgi_config']['refresh_rate']))
|
||||||
|
$cgiConfig->setRefreshRate($_POST['cgi_config']['refresh_rate']);
|
||||||
|
if(isset($_POST['cgi_config']['host_unreachable_sound']))
|
||||||
|
$cgiConfig->setHostUnreachableSound($_POST['cgi_config']['host_unreachable_sound']);
|
||||||
|
if(isset($_POST['cgi_config']['host_down_sound']))
|
||||||
|
$cgiConfig->setHostDownSound($_POST['cgi_config']['host_down_sound']);
|
||||||
|
if(isset($_POST['cgi_config']['service_critical_sound']))
|
||||||
|
$cgiConfig->setServiceCriticalSound($_POST['cgi_config']['service_critical_sound']);
|
||||||
|
if(isset($_POST['cgi_config']['service_warning_sound']))
|
||||||
|
$cgiConfig->setServiceWarningSound($_POST['cgi_config']['service_warning_sound']);
|
||||||
|
if(isset($_POST['cgi_config']['service_unknown_sound']))
|
||||||
|
$cgiConfig->setServiceUnknownSound($_POST['cgi_config']['service_unknown_sound']);
|
||||||
|
if(isset($_POST['cgi_config']['ping_syntax']))
|
||||||
|
$cgiConfig->setPingSyntax($_POST['cgi_config']['ping_syntax']);
|
||||||
|
|
||||||
|
if(isset($_POST['cgi_config']['lock_author_names']))
|
||||||
|
$cgiConfig->setLockAuthorNames($_POST['cgi_config']['lock_author_names']);
|
||||||
|
if(isset($_POST['cgi_config']['escape_html_tags']))
|
||||||
|
$cgiConfig->setEscapeHtmlTags($_POST['cgi_config']['escape_html_tags']);
|
||||||
|
if(isset($_POST['cgi_config']['notes_url_target']))
|
||||||
|
$cgiConfig->setNotesUrlTarget($_POST['cgi_config']['notes_url_target']);
|
||||||
|
if(isset($_POST['cgi_config']['action_url_target']))
|
||||||
|
$cgiConfig->setActionUrlTarget($_POST['cgi_config']['action_url_target']);
|
||||||
|
if(isset($_POST['cgi_config']['enable_splunk_integration']))
|
||||||
|
$cgiConfig->setEnableSplunkIntegration($_POST['cgi_config']['enable_splunk_integration']);
|
||||||
|
if(isset($_POST['cgi_config']['splunk_url']))
|
||||||
|
$cgiConfig->setSplunkUrl($_POST['cgi_config']['splunk_url']);
|
||||||
|
$cgiConfig->save();
|
||||||
|
$success = "Updated CGI Configuration.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Let's make the status map layout select list
|
||||||
|
$statusmap_layout_list[] = array("values" => "0", "text" => "User-Defined Coordinates");
|
||||||
|
$statusmap_layout_list[] = array("values" => "1", "text" => "Depth Layers");
|
||||||
|
$statusmap_layout_list[] = array("values" => "2", "text" => "Collapsed Tree");
|
||||||
|
$statusmap_layout_list[] = array("values" => "3", "text" => "Balanced Tree");
|
||||||
|
$statusmap_layout_list[] = array("values" => "4", "text" => "Circular");
|
||||||
|
$statusmap_layout_list[] = array("values" => "5", "text" => "Circular (Marked Up)");
|
||||||
|
$statusmap_layout_list[] = array("values" => "6", "text" => "Circular (Marked Down)");
|
||||||
|
|
||||||
|
// Let's make the status wrl layout select list
|
||||||
|
$statuswrl_layout_list[] = array("values" => "0", "text" => "User-Defined Coordinates");
|
||||||
|
$statuswrl_layout_list[] = array("values" => "1", "text" => "Depth Layers");
|
||||||
|
$statuswrl_layout_list[] = array("values" => "2", "text" => "Collapsed Tree");
|
||||||
|
$statuswrl_layout_list[] = array("values" => "3", "text" => "Balanced Tree");
|
||||||
|
$statuswrl_layout_list[] = array("values" => "4", "text" => "Circular");
|
||||||
|
|
||||||
|
|
||||||
|
if(!isset($_GET['section']))
|
||||||
|
$_GET['section'] = 'paths';
|
||||||
|
|
||||||
|
|
||||||
|
// Build subnavigation
|
||||||
|
$subnav = array(
|
||||||
|
'paths' => 'Paths',
|
||||||
|
'authentication' => 'Authentication',
|
||||||
|
'status' => 'Status',
|
||||||
|
'sounds' => 'Sounds',
|
||||||
|
'other' => 'Other'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
print_header("CGI Configuration File Editor");
|
||||||
|
|
||||||
|
print_window_header("Web Interface Configuration", "100%", "center");
|
||||||
|
print_subnav($subnav, $_GET['section'], "section");
|
||||||
|
if($_GET['section'] == 'paths') {
|
||||||
|
|
||||||
|
?>
|
||||||
|
<form name="cgi_path_config" method="post" action="cgi.php?section=paths">
|
||||||
|
<input type="hidden" name="request" value="update" />
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Physical HTML Path:</b><br />
|
||||||
|
<input type="text" size="80" name="cgi_config[physical_html_path]" VALUE="<?php echo $cgiConfig->getPhysicalHtmlPath();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("physical_html_path", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>URL HTML Path:</b><br />
|
||||||
|
<input type="text" size="80" name="cgi_config[url_html_path]" VALUE="<?php echo $cgiConfig->getUrlHtmlPath();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("url_html_path", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<input type="submit" value="Update Path Configuration" />
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else if($_GET['section'] == 'authentication') {
|
||||||
|
?>
|
||||||
|
<form name="cgi_authentication_config" method="post" action="cgi.php?section=authentication">
|
||||||
|
<input type="hidden" name="request" value="update" />
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Use Authentication:</b> <?php print_select("cgi_config[use_authentication]", $enable_list, "values", "text", $cgiConfig->getUseAuthentication());?><br />
|
||||||
|
<?php echo $lilac->element_desc("use_authentication", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Default Username:</b> <input type="text" name="cgi_config[default_user_name]" VALUE="<?php echo $cgiConfig->getDefaultUserName();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("default_user_name", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Authorized for System Information:</b> <input type="text" name="cgi_config[authorized_for_system_information]" VALUE="<?php echo $cgiConfig->getAuthorizedForSystemInformation();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("authorized_for_system_information", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Authorized for System Commands:</b> <input type="text" name="cgi_config[authorized_for_system_commands]" VALUE="<?php echo $cgiConfig->getAuthorizedForSystemCommands();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("authorized_for_system_commands", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Authorized for Configuration Information:</b> <input type="text" name="cgi_config[authorized_for_configuration_information]" VALUE="<?php echo $cgiConfig->getAuthorizedForConfigurationInformation();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("authorized_for_configuration_information", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Authorized for All Hosts:</b> <input type="text" name="cgi_config[authorized_for_all_hosts]" VALUE="<?php echo $cgiConfig->getAuthorizedForAllHosts();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("authorized_for_all_hosts", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Authorized for All Host Commands:</b> <input type="text" name="cgi_config[authorized_for_all_host_commands]" VALUE="<?php echo $cgiConfig->getAuthorizedForAllHostCommands();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("authorized_for_all_host_commands", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Authorized for All Services:</b> <input type="text" name="cgi_config[authorized_for_all_services]" VALUE="<?php echo $cgiConfig->getAuthorizedForAllServices();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("authorized_for_all_services", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Authorized for All Service Commands:</b> <input type="text" name="cgi_config[authorized_for_all_service_commands]" VALUE="<?php echo $cgiConfig->getAuthorizedForAllServiceCommands();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("authorized_for_all_service_commands", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<input type="submit" value="Update Authentication Configuration" />
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else if($_GET['section'] == 'status') {
|
||||||
|
?>
|
||||||
|
<form name="cgi_authentication_config" method="post" action="cgi.php?section=status">
|
||||||
|
<input type="hidden" name="request" value="update" />
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Statusmap Background Image:</b> <input type="text" name="cgi_config[statusmap_background_image]" VALUE="<?php echo $cgiConfig->getStatusmapBackgroundImage();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("statusmap_background_image", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Default Statusmap Layout</b> <?php print_select("cgi_config[default_statusmap_layout]", $statusmap_layout_list, "values", "text", $cgiConfig->getDefaultStatusmapLayout());?><br />
|
||||||
|
<?php echo $lilac->element_desc("default_statusmap_layout", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Statuswrl Include:</b> <input type="text" name="cgi_config[statuswrl_include]" VALUE="<?php echo $cgiConfig->getStatuswrlInclude();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("statuswrl_include", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Default Statuswrl Layout</b> <?php print_select("cgi_config[default_statuswrl_layout]", $statuswrl_layout_list, "values", "text", $cgiConfig->getDefaultStatuswrlLayout());?><br />
|
||||||
|
<?php echo $lilac->element_desc("default_statuswrl_layout", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Refresh Rate:</b> <input type="text" name="cgi_config[refresh_rate]" VALUE="<?php echo $cgiConfig->getRefreshRate();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("refresh_rate", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<input type="submit" value="Update Status Configuration" />
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else if($_GET['section'] == 'sounds') {
|
||||||
|
?>
|
||||||
|
<form name="cgi_authentication_config" method="post" action="cgi.php?section=sounds">
|
||||||
|
<input type="hidden" name="request" value="update" />
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Host Unreachable Sound:</b> <input type="text" name="cgi_config[host_unreachable_sound]" VALUE="<?php echo $cgiConfig->getHostUnreachableSound();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("host_unreachable_sound", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Host Down Sound:</b> <input type="text" name="cgi_config[host_down_sound]" VALUE="<?php echo $cgiConfig->getHostDownSound();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("host_down_sound", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Service Critical Sound:</b> <input type="text" name="cgi_config[service_critical_sound]" VALUE="<?php echo $cgiConfig->getServiceCriticalSound();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("service_critical_sound", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Service Warning Sound:</b> <input type="text" name="cgi_config[service_warning_sound]" VALUE="<?php echo $cgiConfig->getServiceWarningSound();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("service_warning_sound", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Service Unknown Sound:</b> <input type="text" name="cgi_config[service_unknown_sound]" VALUE="<?php echo $cgiConfig->getServiceUnknownSound();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("service_unknown_sound", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<input type="submit" value="Update Sound Configuration" />
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else if($_GET['section'] == 'other') {
|
||||||
|
?>
|
||||||
|
<form name="cgi_authentication_config" method="post" action="cgi.php?section=other">
|
||||||
|
<input type="hidden" name="request" value="update" />
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Lock Author Names:</b> <?php print_select("cgi_config[lock_author_names]", $enable_list, "values", "text", $cgiConfig->getLockAuthorNames());?><br />
|
||||||
|
<?php echo $lilac->element_desc("lock_author_names", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Escape HTML Tags:</b> <?php print_select("cgi_config[escape_html_tags]", $enable_list, "values", "text", $cgiConfig->getEscapeHtmlTags());?><br />
|
||||||
|
<?php echo $lilac->element_desc("escape_html_tags", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Notes URL Target:</b><br />
|
||||||
|
<input type="text" size="40" name="cgi_config[notes_url_target]" VALUE="<?php echo $cgiConfig->getNotesUrlTarget();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("notes_url_target", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Action URL Target:</b><br />
|
||||||
|
<input type="text" size="40" name="cgi_config[action_url_target]" VALUE="<?php echo $cgiConfig->getActionUrlTarget();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("action_url_target", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Ping Syntax:</b><br />
|
||||||
|
<input type="text" size="80" name="cgi_config[ping_syntax]" VALUE="<?php echo $cgiConfig->getPingSyntax();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("ping_syntax", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Enable Splunk Integration:</b> <?php print_select("cgi_config[enable_splunk_integration]", $enable_list, "values", "text", $cgiConfig->getEnableSplunkIntegration());?><br />
|
||||||
|
<?php echo $lilac->element_desc("enable_splunk_integration", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<b>Splunk URL:</b><br />
|
||||||
|
<input type="text" size="80" name="cgi_config[splunk_url]" VALUE="<?php echo $cgiConfig->getSplunkUrl();?>"><br />
|
||||||
|
<?php echo $lilac->element_desc("splunk_url", "nagios_cgi_desc"); ?><br />
|
||||||
|
</div>
|
||||||
|
<div class="formbox">
|
||||||
|
<input type="submit" value="Update Other Configuration" />
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
print_window_footer();
|
||||||
|
|
||||||
|
print_footer();
|
||||||
|
?>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryDevice.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'autodiscovery_device' table.
|
||||||
|
*
|
||||||
|
* AutoDiscovery Found Device
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryDevice extends BaseAutodiscoveryDevice {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of AutodiscoveryDevice object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateMatches() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AutodiscoveryDeviceTemplateMatchPeer::DEVICE_ID, $this->getId());
|
||||||
|
$c->addDescendingOrderByColumn(AutodiscoveryDeviceTemplateMatchPeer::PERCENT);
|
||||||
|
$c->addDescendingOrderByColumn(AutodiscoveryDeviceTemplateMatchPeer::COMPLEXITY);
|
||||||
|
$matches = AutodiscoveryDeviceTemplateMatchPeer::doSelect($c);
|
||||||
|
return $matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // AutodiscoveryDevice
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryDevicePeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'autodiscovery_device' table.
|
||||||
|
*
|
||||||
|
* AutoDiscovery Found Device
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryDevicePeer extends BaseAutodiscoveryDevicePeer {
|
||||||
|
|
||||||
|
} // AutodiscoveryDevicePeer
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryDeviceService.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'autodiscovery_device_service' table.
|
||||||
|
*
|
||||||
|
* AutoDiscovery Found Service
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryDeviceService extends BaseAutodiscoveryDeviceService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of AutodiscoveryDeviceService object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // AutodiscoveryDeviceService
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryDeviceServicePeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'autodiscovery_device_service' table.
|
||||||
|
*
|
||||||
|
* AutoDiscovery Found Service
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryDeviceServicePeer extends BaseAutodiscoveryDeviceServicePeer {
|
||||||
|
|
||||||
|
} // AutodiscoveryDeviceServicePeer
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryDeviceTemplateMatch.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'autodiscovery_device_template_match' table.
|
||||||
|
*
|
||||||
|
* AutoDiscovery Device Matched Template
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryDeviceTemplateMatch extends BaseAutodiscoveryDeviceTemplateMatch {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of AutodiscoveryDeviceTemplateMatch object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // AutodiscoveryDeviceTemplateMatch
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryDeviceTemplateMatchPeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'autodiscovery_device_template_match' table.
|
||||||
|
*
|
||||||
|
* AutoDiscovery Device Matched Template
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryDeviceTemplateMatchPeer extends BaseAutodiscoveryDeviceTemplateMatchPeer {
|
||||||
|
|
||||||
|
} // AutodiscoveryDeviceTemplateMatchPeer
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryJob.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'autodiscovery_job' table.
|
||||||
|
*
|
||||||
|
* AutoDiscovery Job Information
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryJob extends BaseAutodiscoveryJob {
|
||||||
|
|
||||||
|
const CMD_START = "start";
|
||||||
|
const CMD_STOP = "stop";
|
||||||
|
|
||||||
|
const STATUS_PENDING = 1;
|
||||||
|
const STATUS_STARTING = 2;
|
||||||
|
const STATUS_RUNNING = 3;
|
||||||
|
const STATUS_FINISHED = 4;
|
||||||
|
const STATUS_FAILED = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of AutodiscoveryJob object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function addLogEntry($text, $type = 3) {
|
||||||
|
if(!AutodiscoveryLogEntry::isValidType($type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$entry = new AutodiscoveryLogEntry();
|
||||||
|
$entry->setTime(time());
|
||||||
|
$entry->setType($type);
|
||||||
|
$entry->setAutodiscoveryJob($this);
|
||||||
|
$entry->setText($text);
|
||||||
|
$entry->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public function setStatus($v) {
|
||||||
|
parent::setStatus($v);
|
||||||
|
// update the status time
|
||||||
|
$this->setStatusChangeTime(time());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearLog() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AutodiscoveryLogEntryPeer::JOB, $this->getId());
|
||||||
|
AutodiscoveryLogEntryPeer::doDelete($c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addError($text) {
|
||||||
|
$this->addLogEntry($text, AutodiscoveryLogEntry::TYPE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addWarning($text) {
|
||||||
|
$this->addLogEntry($text, AutodiscoveryLogEntry::TYPE_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addNotice($text) {
|
||||||
|
$this->addLogEntry($text, AutodiscoveryLogEntry::TYPE_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // AutodiscoveryJob
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryJobPeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'autodiscovery_job' table.
|
||||||
|
*
|
||||||
|
* AutoDiscovery Job Information
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryJobPeer extends BaseAutodiscoveryJobPeer {
|
||||||
|
|
||||||
|
} // AutodiscoveryJobPeer
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryLogEntry.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'autodiscovery_log_entry' table.
|
||||||
|
*
|
||||||
|
* Export Job Entry
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryLogEntry extends BaseAutodiscoveryLogEntry {
|
||||||
|
const TYPE_NOTICE = 1;
|
||||||
|
const TYPE_WARNING = 2;
|
||||||
|
const TYPE_ERROR = 3;
|
||||||
|
|
||||||
|
public function isValidType($type) {
|
||||||
|
return true;
|
||||||
|
if($type != AutodiscoveryLogEntry::TYPE_NOTICE &&
|
||||||
|
$type != AutodiscoveryLogEntry::TYPE_WARNING &&
|
||||||
|
$type != AutodiscoveryLogEntry::TYPE_ERROR) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReadableType($type) {
|
||||||
|
if($type == AutodiscoveryLogEntry::TYPE_NOTICE) {
|
||||||
|
return "NOTICE";
|
||||||
|
}
|
||||||
|
if($type == AutodiscoveryLogEntry::TYPE_WARNING) {
|
||||||
|
return "WARNING";
|
||||||
|
}
|
||||||
|
if($type == AutodiscoveryLogEntry::TYPE_ERROR) {
|
||||||
|
return "ERROR";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initializes internal state of AutodiscoveryLogEntry object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // AutodiscoveryLogEntry
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseAutodiscoveryLogEntryPeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'autodiscovery_log_entry' table.
|
||||||
|
*
|
||||||
|
* Export Job Entry
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class AutodiscoveryLogEntryPeer extends BaseAutodiscoveryLogEntryPeer {
|
||||||
|
|
||||||
|
} // AutodiscoveryLogEntryPeer
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseExportJob.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'export_job' table.
|
||||||
|
*
|
||||||
|
* Export Job Information
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class ExportJob extends BaseExportJob {
|
||||||
|
|
||||||
|
const CMD_START = "start";
|
||||||
|
const CMD_STOP = "stop";
|
||||||
|
|
||||||
|
const STATUS_PENDING = 1;
|
||||||
|
const STATUS_STARTING = 2;
|
||||||
|
const STATUS_RUNNING = 3;
|
||||||
|
const STATUS_FINISHED = 4;
|
||||||
|
const STATUS_FAILED = 50;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->setStats(serialize(new ImportStats()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addLogEntry($text, $type = 3) {
|
||||||
|
if(!ExportLogEntry::isValidType($type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$entry = new ExportLogEntry();
|
||||||
|
$entry->setTime(time());
|
||||||
|
$entry->setType($type);
|
||||||
|
$entry->setExportJob($this);
|
||||||
|
$entry->setText($text);
|
||||||
|
$entry->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStatus($v) {
|
||||||
|
parent::setStatus($v);
|
||||||
|
$this->setStatusChangeTime(time());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearLog() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(ExportLogEntryPeer::JOB, $this->getId());
|
||||||
|
ExportLogEntryPeer::doDelete($c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addError($text) {
|
||||||
|
$this->addLogEntry($text, ImportLogEntry::TYPE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addWarning($text) {
|
||||||
|
$this->addLogEntry($text, ImportLogEntry::TYPE_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addNotice($text) {
|
||||||
|
$this->addLogEntry($text, ImportLogEntry::TYPE_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ExportJob
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseExportJobPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'ExportJob.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'export_job' table.
|
||||||
|
*
|
||||||
|
* Export Job Information
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class ExportJobPeer extends BaseExportJobPeer {
|
||||||
|
|
||||||
|
} // ExportJobPeer
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseExportLogEntry.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'export_log_entry' table.
|
||||||
|
*
|
||||||
|
* Export Job Entry
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class ExportLogEntry extends BaseExportLogEntry {
|
||||||
|
|
||||||
|
const TYPE_NOTICE = 1;
|
||||||
|
const TYPE_WARNING = 2;
|
||||||
|
const TYPE_ERROR = 3;
|
||||||
|
|
||||||
|
public function isValidType($type) {
|
||||||
|
return true;
|
||||||
|
if($type != ImportLogEntry::TYPE_NOTICE &&
|
||||||
|
$type != ImportLogEntry::TYPE_WARNING &&
|
||||||
|
$type != ImportLogEntry::TYPE_ERROR) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReadableType($type) {
|
||||||
|
if($type == ImportLogEntry::TYPE_NOTICE) {
|
||||||
|
return "NOTICE";
|
||||||
|
}
|
||||||
|
if($type == ImportLogEntry::TYPE_WARNING) {
|
||||||
|
return "WARNING";
|
||||||
|
}
|
||||||
|
if($type == ImportLogEntry::TYPE_ERROR) {
|
||||||
|
return "ERROR";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ExportLogEntry
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseExportLogEntryPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'ExportLogEntry.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'export_log_entry' table.
|
||||||
|
*
|
||||||
|
* Export Job Entry
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class ExportLogEntryPeer extends BaseExportLogEntryPeer {
|
||||||
|
|
||||||
|
} // ExportLogEntryPeer
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseImportJob.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'import_job' table.
|
||||||
|
*
|
||||||
|
* Import Job Information
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class ImportJob extends BaseImportJob {
|
||||||
|
|
||||||
|
const CMD_START = "start";
|
||||||
|
const CMD_STOP = "stop";
|
||||||
|
|
||||||
|
const STATUS_PENDING = 1;
|
||||||
|
const STATUS_STARTING = 2;
|
||||||
|
const STATUS_RUNNING = 3;
|
||||||
|
const STATUS_FINISHED = 4;
|
||||||
|
const STATUS_FAILED = 50;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addLogEntry($text, $type = 3) {
|
||||||
|
if(!ImportLogEntry::isValidType($type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$entry = new ImportLogEntry();
|
||||||
|
$entry->setTime(time());
|
||||||
|
$entry->setType($type);
|
||||||
|
$entry->setImportJob($this);
|
||||||
|
$entry->setText($text);
|
||||||
|
$entry->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStatus($v) {
|
||||||
|
parent::setStatus($v);
|
||||||
|
// update the status time
|
||||||
|
$this->setStatusChangeTime(time());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearLog() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(ImportLogEntryPeer::JOB, $this->getId());
|
||||||
|
ImportLogEntryPeer::doDelete($c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addError($text) {
|
||||||
|
$this->addLogEntry($text, ImportLogEntry::TYPE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addWarning($text) {
|
||||||
|
$this->addLogEntry($text, ImportLogEntry::TYPE_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addNotice($text) {
|
||||||
|
$this->addLogEntry($text, ImportLogEntry::TYPE_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ImportJob
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseImportJobPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'ImportJob.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'import_job' table.
|
||||||
|
*
|
||||||
|
* Import Job Information
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class ImportJobPeer extends BaseImportJobPeer {
|
||||||
|
|
||||||
|
} // ImportJobPeer
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseImportLogEntry.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'import_log_entry' table.
|
||||||
|
*
|
||||||
|
* Import Job Entry
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class ImportLogEntry extends BaseImportLogEntry {
|
||||||
|
|
||||||
|
const TYPE_NOTICE = 1;
|
||||||
|
const TYPE_WARNING = 2;
|
||||||
|
const TYPE_ERROR = 3;
|
||||||
|
|
||||||
|
public function isValidType($type) {
|
||||||
|
return true;
|
||||||
|
if($type != ImportLogEntry::TYPE_NOTICE &&
|
||||||
|
$type != ImportLogEntry::TYPE_WARNING &&
|
||||||
|
$type != ImportLogEntry::TYPE_ERROR) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReadableType($type) {
|
||||||
|
if($type == ImportLogEntry::TYPE_NOTICE) {
|
||||||
|
return "NOTICE";
|
||||||
|
}
|
||||||
|
if($type == ImportLogEntry::TYPE_WARNING) {
|
||||||
|
return "WARNING";
|
||||||
|
}
|
||||||
|
if($type == ImportLogEntry::TYPE_ERROR) {
|
||||||
|
return "ERROR";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ImportLogEntry
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseImportLogEntryPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'ImportLogEntry.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'import_log_entry' table.
|
||||||
|
*
|
||||||
|
* Import Job Entry
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class ImportLogEntryPeer extends BaseImportLogEntryPeer {
|
||||||
|
|
||||||
|
} // ImportLogEntryPeer
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseLabel.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'label' table.
|
||||||
|
*
|
||||||
|
* Language based labels
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 22:27:35 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class Label extends BaseLabel {
|
||||||
|
|
||||||
|
} // Label
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseLabelPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'Label.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'label' table.
|
||||||
|
*
|
||||||
|
* Language based labels
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 22:27:35 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class LabelPeer extends BaseLabelPeer {
|
||||||
|
|
||||||
|
} // LabelPeer
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseLilacConfiguration.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'lilac_configuration' table.
|
||||||
|
*
|
||||||
|
* Lilac Configuration
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class LilacConfiguration extends BaseLilacConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of LilacConfiguration object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // LilacConfiguration
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseLilacConfigurationPeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'lilac_configuration' table.
|
||||||
|
*
|
||||||
|
* Lilac Configuration
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class LilacConfigurationPeer extends BaseLilacConfigurationPeer {
|
||||||
|
|
||||||
|
} // LilacConfigurationPeer
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class LilacCoreModule extends Module {
|
||||||
|
|
||||||
|
public function getModulesByHook($hook) {
|
||||||
|
return $this->createModulesByHook($hook);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderForHook($hook) {
|
||||||
|
$mods = $this->getModulesByHook($hook);
|
||||||
|
foreach($mods as $mod) {
|
||||||
|
$mod->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,226 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base Module class to be used when writing Add On Modules.
|
||||||
|
*/
|
||||||
|
abstract class Module {
|
||||||
|
private $_ormModule; // The ORM AddOnModule which represents this module in ORM land
|
||||||
|
private $_callingModule; // Reference to the Module which is calling this module
|
||||||
|
private $_context; // The context which is passed by the calling Module
|
||||||
|
|
||||||
|
private $__getParams = array();
|
||||||
|
private $__notUsGetParams = array(); // Parameters from the URL which do not belong to us, but still needs to be passed to future urls.
|
||||||
|
private $__postParams = array();
|
||||||
|
private $__uploadedFiles = array();
|
||||||
|
|
||||||
|
|
||||||
|
final public function __construct(AddOnModule $module, $context, Module $caller = null) {
|
||||||
|
// Checks
|
||||||
|
$tmpClassName = $module->getClassname();
|
||||||
|
if((get_class($this) != $module->getClassname())) {
|
||||||
|
throw new Exception("The creation of this module of type " . get_class($this) . " does not match the classname of the AddOnModule: " . $module->getClassname());
|
||||||
|
}
|
||||||
|
$this->_ormModule = $module;
|
||||||
|
$this->_context = $context;
|
||||||
|
$this->_callingModule = $caller;
|
||||||
|
|
||||||
|
// Grab our getParameters
|
||||||
|
$len = strlen("__m" . $this->_ormModule->getId() . "_");
|
||||||
|
foreach($_GET as $getName => $getValue) {
|
||||||
|
$pos = strpos($getName, "__m" . $this->_ormModule->getId() . "_");
|
||||||
|
if($pos === 0) {
|
||||||
|
// This variable belongs to us
|
||||||
|
$actualName = substr($getName, $len);
|
||||||
|
$this->__getParams[$actualName] = $getValue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->__notUsGetParams[$getName] = $getValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Build our postParameters
|
||||||
|
foreach($_POST as $postName => $postValue) {
|
||||||
|
$pos = strpos($postName, "__m" . $this->_ormModule->getId() . "_");
|
||||||
|
if($pos === 0) {
|
||||||
|
// This variable belongs to us
|
||||||
|
$actualName = substr($postName, $len);
|
||||||
|
$this->__postParams[$actualName] = $postValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Build our uploadedFiles
|
||||||
|
foreach($_FILES as $fileName => $fileValue) {
|
||||||
|
$pos = strpos($fileName, "__m" . $this->_ormModule->getId() . "_");
|
||||||
|
if($pos === 0) {
|
||||||
|
// This variable belongs to us
|
||||||
|
$actualName = substr($fileName, $len);
|
||||||
|
$this->__fileParams[$actualName] = $fileValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getId() {
|
||||||
|
return $this->_ormModule->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getContext() {
|
||||||
|
return $this->_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getParamName($name) {
|
||||||
|
$newName = "__m" . $this->_ormModule->getId() . "_" . trim($name);
|
||||||
|
return $newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function buildURL($pairs) {
|
||||||
|
if(!is_array($pairs)) {
|
||||||
|
throw new Exception("Arguement to buildURL must be an associative array");
|
||||||
|
}
|
||||||
|
$url = $_SERVER['PHP_SELF'] . "?";
|
||||||
|
// Add our not us values
|
||||||
|
$first = true;
|
||||||
|
foreach($this->__notUsGetParams as $key => $val) {
|
||||||
|
if(!$first)
|
||||||
|
$url .= "&";
|
||||||
|
$first = false;
|
||||||
|
$url .= $key . "=" . urlencode($val);
|
||||||
|
}
|
||||||
|
foreach($pairs as $key => $val) {
|
||||||
|
$name = $this->getParamName($key);
|
||||||
|
if(!$first)
|
||||||
|
$url .= "&";
|
||||||
|
$first = false;
|
||||||
|
$url .= $name . "=" . urlencode($val);
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getUrlParam($name) {
|
||||||
|
if(!array_key_exists($name, $this->__getParams))
|
||||||
|
return false;
|
||||||
|
return $this->__getParams[$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getPostParam($name) {
|
||||||
|
if(!array_key_exists($name, $this->__postParams))
|
||||||
|
return false;
|
||||||
|
return $this->__postParams[$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getUploadedFile($name) {
|
||||||
|
if(!array_key_exists($name, $this->__uploadedFiles))
|
||||||
|
return false;
|
||||||
|
return $this->__uploadedFiles[$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getAddOnModule() {
|
||||||
|
return $this->_ormModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getAddOnUrl() {
|
||||||
|
$addOn = $this->_ormModule->getAddOnRelatedByAddOn();
|
||||||
|
$url = $addOn->getPath();
|
||||||
|
if(empty($url))
|
||||||
|
return false;
|
||||||
|
return $url . "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getCallingModule() {
|
||||||
|
return $this->_callingModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function createModulesByHook($hook, $context = null) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AddOnModuleHookPeer::ADD_ON_MODULE, $this->_ormModule->getId());
|
||||||
|
$c->add(AddOnModuleHookPeer::NAME, $hook);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$hook = AddOnModuleHookPeer::doSelectOne($c);
|
||||||
|
if(!$hook)
|
||||||
|
return false;
|
||||||
|
$registrations = $hook->getAddOnModuleHookRegistrations();
|
||||||
|
$modules = array();
|
||||||
|
foreach($registrations as $registration) {
|
||||||
|
$addOnModule = $registration->getAddOnModuleRelatedByAddOnModule();
|
||||||
|
if($addOnModule) {
|
||||||
|
// Okay, let's load up the class.
|
||||||
|
// First, make sure we include the class file.
|
||||||
|
if(!file_exists(dirname(__FILE__) . "/../addons/" . $addOnModule->getAddOnRelatedByAddOn()->getPath() . "/modules/" . $addOnModule->getClassName() . ".php")) {
|
||||||
|
throw new Exception("The module class file for " . $addOnModule->getClassName() . " could not be found.");
|
||||||
|
}
|
||||||
|
require_once(dirname(__FILE__) . "/../addons/" . $addOnModule->getAddOnRelatedByAddOn()->getPath() . "/modules/" . $addOnModule->getClassName() . ".php");
|
||||||
|
$className = $addOnModule->getClassName();
|
||||||
|
$modules[] = new $className($addOnModule, $context == null ? $this->getContext() : $context, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getDynamicData($name = null) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AddOnModuleDynamicDataPeer::ADD_ON_MODULE, $this->_ormModule->getId());
|
||||||
|
if($name != null)
|
||||||
|
$c->add(AddOnModuleDynamicDataPeer::NAME, $name);
|
||||||
|
$dynData = AddOnModuleDynamicDataPeer::doSelect($c);
|
||||||
|
$data = array();
|
||||||
|
if(!empty($dynData)) {
|
||||||
|
foreach($dynData as $segment)
|
||||||
|
$data[$segment->getName()] = $segment->getData();
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function deleteDynamicdata($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AddOnModuleDynamicDataPeer::ADD_ON_MODULE, $this->_ormModule->getId());
|
||||||
|
$c->add(AddOnModuleDynamicDataPeer::NAME, $name);
|
||||||
|
$dynData = AddOnModuleDynamicDataPeer::doSelectOne($c);
|
||||||
|
if(empty($dynData)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$dynData->delete();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final protected function dynamicDataExists($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AddOnModuleDynamicDataPeer::ADD_ON_MODULE, $this->_ormModule->getId());
|
||||||
|
$c->add(AddOnModuleDynamicDataPeer::NAME, $name);
|
||||||
|
$dynData = AddOnModuleDynamicDataPeer::doSelectOne($c);
|
||||||
|
if(!empty($dynData)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function setDynamicData($name, $data) {
|
||||||
|
if(trim($name) == '') {
|
||||||
|
throw new Exception("Name of dynamic data to be set cannot be blank.");
|
||||||
|
}
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(AddOnModuleDynamicDataPeer::ADD_ON_MODULE, $this->_ormModule->getId());
|
||||||
|
$c->add(AddOnModuleDynamicDataPeer::NAME, $name);
|
||||||
|
$dynData = AddOnModuleDynamicDataPeer::doSelectOne($c);
|
||||||
|
if(!empty($dynData)) {
|
||||||
|
$dynData->setData($data);
|
||||||
|
$dynData->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$dynData = new AddOnModuleDynamicData();
|
||||||
|
$dynData->setAddOnModuleRelatedByAddOnModule($this->_ormModule);
|
||||||
|
$dynData->setName($name);
|
||||||
|
$dynData->setData($data);
|
||||||
|
$dynData->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public function init();
|
||||||
|
abstract public function render();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MenuItem {
|
||||||
|
public function getTitle();
|
||||||
|
public function getDescription();
|
||||||
|
public function getIcon();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosBrokerModule.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_broker_module' table.
|
||||||
|
*
|
||||||
|
* Event Broker Modules
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosBrokerModule extends BaseNagiosBrokerModule {
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosBrokerModule
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosBrokerModulePeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosBrokerModule.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_broker_module' table.
|
||||||
|
*
|
||||||
|
* Event Broker Modules
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosBrokerModulePeer extends BaseNagiosBrokerModulePeer {
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosBrokerModulePeer
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosCgiConfiguration.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_cgi_configuration' table.
|
||||||
|
*
|
||||||
|
* CGI Configuration
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosCgiConfiguration extends BaseNagiosCgiConfiguration {
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosCgiConfiguration
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosCgiConfigurationPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosCgiConfiguration.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_cgi_configuration' table.
|
||||||
|
*
|
||||||
|
* CGI Configuration
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosCgiConfigurationPeer extends BaseNagiosCgiConfigurationPeer {
|
||||||
|
|
||||||
|
} // NagiosCgiConfigurationPeer
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosCommand.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_command' table.
|
||||||
|
*
|
||||||
|
* Nagios Command
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosCommand extends BaseNagiosCommand {
|
||||||
|
|
||||||
|
public function updateFromArray($source) {
|
||||||
|
if(isset($source['command_name'])) $this->setName($source['command_name']);
|
||||||
|
if(isset($source['command_desc'])) $this->setDescription($source['command_desc']);
|
||||||
|
if(isset($source['command_line'])) $this->setLine($source['command_line']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosCommand
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosCommandPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosCommand.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_command' table.
|
||||||
|
*
|
||||||
|
* Nagios Command
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosCommandPeer extends BaseNagiosCommandPeer {
|
||||||
|
|
||||||
|
public function getByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
return $command;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosCommandPeer
|
|
@ -0,0 +1,100 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosContact.php';
|
||||||
|
require_once('NagiosContactGroup.php');
|
||||||
|
require_once('NagiosContactGroupMember.php');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_contact' table.
|
||||||
|
*
|
||||||
|
* Nagios Contact
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContact extends BaseNagiosContact {
|
||||||
|
|
||||||
|
|
||||||
|
public function setServiceNotificationPeriodByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosTimeperiodPeer::NAME, $name);
|
||||||
|
$timeperiod = NagiosTimeperiodPeer::doSelectOne($c);
|
||||||
|
if(!empty($timeperiod)) {
|
||||||
|
$this->setNagiosTimeperiodRelatedByServiceNotificationPeriod($timeperiod);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHostNotificationPeriodByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosTimeperiodPeer::NAME, $name);
|
||||||
|
$timeperiod = NagiosTimeperiodPeer::doSelectOne($c);
|
||||||
|
if(!empty($timeperiod)) {
|
||||||
|
$this->setNagiosTimeperiodRelatedByHostNotificationPeriod($timeperiod);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addServiceNotificationCommandByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!empty($command)) {
|
||||||
|
$notificationCommand = new NagiosContactNotificationCommand();
|
||||||
|
$notificationCommand->setType("service");
|
||||||
|
$notificationCommand->setNagiosContact($this);
|
||||||
|
$notificationCommand->setNagiosCommand($command);
|
||||||
|
$notificationCommand->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addHostNotificationCommandByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!empty($command)) {
|
||||||
|
$notificationCommand = new NagiosContactNotificationCommand();
|
||||||
|
$notificationCommand->setType("host");
|
||||||
|
$notificationCommand->setNagiosContact($this);
|
||||||
|
$notificationCommand->setNagiosCommand($command);
|
||||||
|
$notificationCommand->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function joinNagiosContactGroupByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactGroupPeer::NAME, $name);
|
||||||
|
$group = NagiosContactGroupPeer::doSelectOne($c);
|
||||||
|
if(!empty($group)) {
|
||||||
|
$membership = new NagiosContactGroupMember();
|
||||||
|
$membership->setNagiosContact($this);
|
||||||
|
$membership->setNagiosContactGroup($group);
|
||||||
|
$membership->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addAddress($text) {
|
||||||
|
$address = new NagiosContactAddress();
|
||||||
|
$address->setNagiosContact($this);
|
||||||
|
$address->setAddress($text);
|
||||||
|
$address->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosContact
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosContactAddress.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_contact_address' table.
|
||||||
|
*
|
||||||
|
* Nagios Contact Address
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactAddress extends BaseNagiosContactAddress {
|
||||||
|
|
||||||
|
} // NagiosContactAddress
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosContactAddressPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosContactAddress.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_contact_address' table.
|
||||||
|
*
|
||||||
|
* Nagios Contact Address
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactAddressPeer extends BaseNagiosContactAddressPeer {
|
||||||
|
|
||||||
|
} // NagiosContactAddressPeer
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosContactGroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_contact_group' table.
|
||||||
|
*
|
||||||
|
* Nagios Contact Group
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactGroup extends BaseNagiosContactGroup {
|
||||||
|
|
||||||
|
public function addMemberByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactPeer::NAME, $name);
|
||||||
|
$contact = NagiosContactPeer::doSelectOne($c);
|
||||||
|
if(!empty($contact)) {
|
||||||
|
$membership = new NagiosContactGroupMember();
|
||||||
|
$membership->setNagiosContactGroup($this);
|
||||||
|
$membership->setNagiosContact($contact);
|
||||||
|
$membership->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} // NagiosContactGroup
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosContactGroupMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_contact_group_member' table.
|
||||||
|
*
|
||||||
|
* Member of a Nagios Contact Group
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactGroupMember extends BaseNagiosContactGroupMember {
|
||||||
|
|
||||||
|
} // NagiosContactGroupMember
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosContactGroupMemberPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosContactGroupMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_contact_group_member' table.
|
||||||
|
*
|
||||||
|
* Member of a Nagios Contact Group
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactGroupMemberPeer extends BaseNagiosContactGroupMemberPeer {
|
||||||
|
|
||||||
|
} // NagiosContactGroupMemberPeer
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosContactGroupPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosContactGroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_contact_group' table.
|
||||||
|
*
|
||||||
|
* Nagios Contact Group
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactGroupPeer extends BaseNagiosContactGroupPeer {
|
||||||
|
|
||||||
|
public function getByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactGroupPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$contactgroup = NagiosContactGroupPeer::doSelectOne($c);
|
||||||
|
if(!$contactgroup)
|
||||||
|
return false;
|
||||||
|
return $contactgroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosContactGroupPeer
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosContactNotificationCommand.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_contact_notification_command' table.
|
||||||
|
*
|
||||||
|
* Notification Command for a Nagios Contact
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactNotificationCommand extends BaseNagiosContactNotificationCommand {
|
||||||
|
|
||||||
|
} // NagiosContactNotificationCommand
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosContactNotificationCommandPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosContactNotificationCommand.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_contact_notification_command' table.
|
||||||
|
*
|
||||||
|
* Notification Command for a Nagios Contact
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactNotificationCommandPeer extends BaseNagiosContactNotificationCommandPeer {
|
||||||
|
|
||||||
|
} // NagiosContactNotificationCommandPeer
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosContactPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosContact.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_contact' table.
|
||||||
|
*
|
||||||
|
* Nagios Contact
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosContactPeer extends BaseNagiosContactPeer {
|
||||||
|
|
||||||
|
public function getByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$contact = NagiosContactPeer::doSelectOne($c);
|
||||||
|
if(!$contact)
|
||||||
|
return false;
|
||||||
|
return $contact;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosContactPeer
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosDependency.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_dependency' table.
|
||||||
|
*
|
||||||
|
* Nagios Dependency
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosDependency extends BaseNagiosDependency {
|
||||||
|
|
||||||
|
public function getType() {
|
||||||
|
if($this->getNagiosService())
|
||||||
|
return "service";
|
||||||
|
if($this->getNagiosServiceTemplate())
|
||||||
|
return "servicetemplate";
|
||||||
|
if($this->getNagiosHost())
|
||||||
|
return "host";
|
||||||
|
if($this->getNagiosHostTemplate())
|
||||||
|
return "hosttemplate";
|
||||||
|
if($this->getNagiosHostgroup())
|
||||||
|
return "hostgroup";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDependencyPeriodByName($name) {
|
||||||
|
$timeperiod = NagiosTimeperiodPeer::getByName($name);
|
||||||
|
if(!$timeperiod)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosTimeperiod($timeperiod);
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosDependency
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosDependencyPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosDependency.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_dependency' table.
|
||||||
|
*
|
||||||
|
* Nagios Dependency
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosDependencyPeer extends BaseNagiosDependencyPeer {
|
||||||
|
|
||||||
|
} // NagiosDependencyPeer
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosDependencyTarget.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_dependency_target' table.
|
||||||
|
*
|
||||||
|
* Targets for a Dependency
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosDependencyTarget extends BaseNagiosDependencyTarget {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of NagiosDependencyTarget object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType() {
|
||||||
|
if($this->getNagiosService())
|
||||||
|
return "service";
|
||||||
|
if($this->getNagiosHost())
|
||||||
|
return "host";
|
||||||
|
if($this->getNagiosHostgroup())
|
||||||
|
return "hostgroup";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosDependencyTarget
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosDependencyTargetPeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_dependency_target' table.
|
||||||
|
*
|
||||||
|
* Targets for a Dependency
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosDependencyTargetPeer extends BaseNagiosDependencyTargetPeer {
|
||||||
|
|
||||||
|
} // NagiosDependencyTargetPeer
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosEscalation.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_escalation' table.
|
||||||
|
*
|
||||||
|
* Nagios Escalation
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosEscalation extends BaseNagiosEscalation {
|
||||||
|
|
||||||
|
public function setEscalationPeriodByName($name) {
|
||||||
|
$timeperiod = NagiosTimeperiodPeer::getByName($name);
|
||||||
|
if(!$timeperiod)
|
||||||
|
return false;
|
||||||
|
return $timeperiod;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosEscalation
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosEscalationContact.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_escalation_contact' table.
|
||||||
|
*
|
||||||
|
* Contact Group for Escalation
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosEscalationContact extends BaseNagiosEscalationContact {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of NagiosEscalationContact object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosEscalationContact
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosEscalationContactPeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_escalation_contact' table.
|
||||||
|
*
|
||||||
|
* Contact Group for Escalation
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosEscalationContactPeer extends BaseNagiosEscalationContactPeer {
|
||||||
|
|
||||||
|
} // NagiosEscalationContactPeer
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosEscalationContactgroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_escalation_contactgroup' table.
|
||||||
|
*
|
||||||
|
* Contact Group for Escalation
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosEscalationContactgroup extends BaseNagiosEscalationContactgroup {
|
||||||
|
|
||||||
|
} // NagiosEscalationContactgroup
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosEscalationContactgroupPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosEscalationContactgroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_escalation_contactgroup' table.
|
||||||
|
*
|
||||||
|
* Contact Group for Escalation
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosEscalationContactgroupPeer extends BaseNagiosEscalationContactgroupPeer {
|
||||||
|
|
||||||
|
} // NagiosEscalationContactgroupPeer
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosEscalationPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosEscalation.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_escalation' table.
|
||||||
|
*
|
||||||
|
* Nagios Escalation
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosEscalationPeer extends BaseNagiosEscalationPeer {
|
||||||
|
|
||||||
|
} // NagiosEscalationPeer
|
|
@ -0,0 +1,477 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosHost.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_host' table.
|
||||||
|
*
|
||||||
|
* Nagios Host
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHost extends BaseNagiosHost {
|
||||||
|
|
||||||
|
public function getValues($inherited = false) {
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::SOURCE_HOST, $this->getId());
|
||||||
|
$c->addAscendingOrderByColumn(NagiosHostTemplateInheritancePeer::ORDER);
|
||||||
|
|
||||||
|
$inheritanceTemplates = NagiosHostTemplateInheritancePeer::doSelect($c);
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $inheritanceItem) {
|
||||||
|
$hostTemplate = $inheritanceItem->getNagiosHostTemplateRelatedByTargetTemplate();
|
||||||
|
$templateValues = $hostTemplate->getValues(true);
|
||||||
|
$values = array_merge($values, $templateValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach(NagiosHostPeer::getFieldNames() as $fieldName) {
|
||||||
|
$colName = NagiosHostPeer::translateFieldName($fieldName, BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME);
|
||||||
|
// At this point, $fieldName is the fieldname for each column in our table record
|
||||||
|
$colName = strtolower(substr($colName, strlen("nagios_host.")));
|
||||||
|
// $colName is now the abbreviated column name.
|
||||||
|
|
||||||
|
switch($colName) {
|
||||||
|
case 'maximum_check_attempts':
|
||||||
|
$colName = 'max_check_attempts';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$methodName = "get" . $fieldName;
|
||||||
|
if(method_exists($this, $methodName)) {
|
||||||
|
$val = $this->{$methodName}();
|
||||||
|
|
||||||
|
if($val !== null) {
|
||||||
|
|
||||||
|
// Yay, let's populate
|
||||||
|
$values[$colName] = array(
|
||||||
|
'inherited' => $inherited,
|
||||||
|
'source' => array('id' => $this->getId(), 'name' => $this->getName()),
|
||||||
|
'value' => $val
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedCommandParameters($self = true) {
|
||||||
|
$parameterList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$parameters = $hostTemplate->getInheritedCommandParameters(false);
|
||||||
|
$parameterList = array_merge($parameterList, $parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$parameters = $this->getNagiosHostCheckCommandParameters();
|
||||||
|
array_merge($parameterList, $parameters);
|
||||||
|
}
|
||||||
|
return $parameterList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getInheritedDependencies($self = true) {
|
||||||
|
$dependenciesList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$dependencies = $hostTemplate->getInheritedDependencies(false);
|
||||||
|
$dependenciesList = array_merge($dependenciesList, $dependencies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$dependencies = $this->getNagiosDependencys();
|
||||||
|
$dependenciesList = array_merge($dependenciesList, $dependencies);
|
||||||
|
}
|
||||||
|
return $dependenciesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedEscalations($self = true) {
|
||||||
|
$escalationsList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$escalations = $hostTemplate->getInheritedEscalations(false);
|
||||||
|
$escalationsList = array_merge($escalationsList, $escalations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$escalations = $this->getNagiosEscalations();
|
||||||
|
$escalationsList = array_merge($escalationsList, $escalations);
|
||||||
|
}
|
||||||
|
return $escalationsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedServices($self = true) {
|
||||||
|
$servicesList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$services = $hostTemplate->getInheritedServices(false);
|
||||||
|
$servicesList = array_merge($servicesList, $services);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
|
||||||
|
$services = $this->getNagiosServices();
|
||||||
|
$servicesList = array_merge($servicesList, $services);
|
||||||
|
}
|
||||||
|
return $servicesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedHostGroups($self = true) {
|
||||||
|
$groupList = array();
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$hostgroups = $hostTemplate->getInheritedHostGroups(false);
|
||||||
|
$groupList = array_merge($groupList, $hostgroups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$hostgroupMemberships = $this->getNagiosHostgroupMemberships();
|
||||||
|
foreach($hostgroupMemberships as $membership) {
|
||||||
|
$hostgroup = $membership->getNagiosHostGroup();
|
||||||
|
$groupList[] = $hostgroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedContacts($self = true) {
|
||||||
|
$contactsList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$contacts = $hostTemplate->getInheritedContacts(false);
|
||||||
|
$contactsList = array_merge($contactsList, $contacts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$contactMemberships = $this->getNagiosHostContactMembers();
|
||||||
|
foreach($contactMemberships as $membership) {
|
||||||
|
$contact = $membership->getNagiosContact();
|
||||||
|
$contactsList[] = $contact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $contactsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getInheritedContactGroups($self = true) {
|
||||||
|
$groupList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$contactgroups = $hostTemplate->getInheritedContactGroups(false);
|
||||||
|
$groupList = array_merge($groupList, $contactgroups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$contatgroupMemberships = $this->getNagiosHostContactgroups();
|
||||||
|
foreach($contatgroupMemberships as $membership) {
|
||||||
|
$contactgroup = $membership->getNagiosContactGroup();
|
||||||
|
$groupList[] = $contactgroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNumberOfChildren() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostParentPeer::PARENT_HOST , $this->getId());
|
||||||
|
|
||||||
|
return NagiosHostPeer::doCount($c);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNagiosHostTemplateInheritances() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::SOURCE_HOST, $this->getId());
|
||||||
|
$c->addAscendingOrderByColumn(NagiosHostTemplateInheritancePeer::ORDER);
|
||||||
|
|
||||||
|
$list = array();
|
||||||
|
$inheritanceTemplates = NagiosHostTemplateInheritancePeer::doSelect($c);
|
||||||
|
|
||||||
|
foreach($inheritanceTemplates as $inheritanceItem) {
|
||||||
|
$list[] = $inheritanceItem->getNagiosHostTemplateRelatedByTargetTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addCheckCommandParameter($value) {
|
||||||
|
$parameter = new NagiosHostCheckCommandParameter();
|
||||||
|
$parameter->setNagiosHost($this);
|
||||||
|
$parameter->setParameter($value);
|
||||||
|
$parameter->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getInheritedCommandWithParameters($cmdObj = null) {
|
||||||
|
$self = false;
|
||||||
|
if($cmdObj === null) {
|
||||||
|
$self = true;
|
||||||
|
// Initialize array
|
||||||
|
$cmdObj = array(
|
||||||
|
'command' => null,
|
||||||
|
'parameters' => array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$inheritedTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
// Inheritedtemplates is our collection of templates that we directly inherit from. Let's grab 'em
|
||||||
|
foreach($inheritedTemplates as $template) {
|
||||||
|
$cmdObj = $template->getInheritedCommandWithParameters($cmdObj);
|
||||||
|
}
|
||||||
|
// Okay, let's check ourselves
|
||||||
|
if($this->getNagiosCommandRelatedByCheckCommand()) {
|
||||||
|
$cmdObj['command'] = array('inherited' => ($self ? false : true),
|
||||||
|
'source' => $this,
|
||||||
|
'command' => $this->getNagiosCommandRelatedByCheckCommand());
|
||||||
|
}
|
||||||
|
$parameters = $this->getNagiosHostCheckCommandParameters();
|
||||||
|
foreach($parameters as $param) {
|
||||||
|
$cmdObj['parameters'][] = array(
|
||||||
|
'inherited' => ($self ? false : true),
|
||||||
|
'source' => $this,
|
||||||
|
'parameter' => $param
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $cmdObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCheckCommandByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosCommandRelatedByCheckCommand($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCheckPeriodByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosTimeperiodPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosTimeperiodPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosTimeperiodRelatedByCheckPeriod($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setEventHandlerByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosCommandRelatedByEventHandler($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function setNotificationPeriodByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosTimeperiodPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosTimeperiodPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosTimeperiodRelatedByNotificationPeriod($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns just the first parnet of the host.
|
||||||
|
*/
|
||||||
|
function getParentHost() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostParentPeer::CHILD_HOST, $this->getId());
|
||||||
|
$relationship = NagiosHostParentPeer::doSelectOne($c);
|
||||||
|
if(!count($relationship)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $relationship->getNagiosHostRelatedByParentHost()->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getChildrenHosts() {
|
||||||
|
$con = Propel::getConnection(NagiosHostPeer::DATABASE_NAME);
|
||||||
|
$sql = "SELECT nagios_host.* FROM nagios_host_parent INNER JOIN nagios_host ON nagios_host.id = nagios_host_parent.child_host WHERE nagios_host_parent.parent_host = " . $this->getId() . " ORDER BY nagios_host.name";
|
||||||
|
$stmt = $con->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$children = NagiosHostPeer::populateObjects($stmt);
|
||||||
|
return $children;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addParentByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$host = NagiosHostPeer::doSelectOne($c);
|
||||||
|
if(!$host)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Okay, let's first see if there's a parent relationship around
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostParentPeer::CHILD_HOST, $this->getId());
|
||||||
|
$c->add(NagiosHostParentPeer::PARENT_HOST, $host->getId());
|
||||||
|
$relationship = NagiosHostParentPeer::doSelectOne($c);
|
||||||
|
if($relationship) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Okay, relationship doesn't exist, let's add it!
|
||||||
|
$relationship = new NagiosHostParent();
|
||||||
|
$relationship->setNagiosHostRelatedByChildHost($this);
|
||||||
|
$relationship->setNagiosHostRelatedByParentHost($host);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addHostgroupByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostgroupPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$hostgroup = NagiosHostgroupPeer::doSelectOne($c);
|
||||||
|
if(!$hostgroup)
|
||||||
|
return false;
|
||||||
|
// Okay, hostgroup is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostgroupMembershipPeer::HOST, $this->getId());
|
||||||
|
$c->add(NagiosHostgroupMembershipPeer::HOSTGROUP, $hostgroup->getId());
|
||||||
|
$relationship = NagiosHostgroupMembershipPeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$relationship = new NagiosHostgroupMembership();
|
||||||
|
$relationship->setNagiosHost($this);
|
||||||
|
$relationship->setNagiosHostgroup($hostgroup);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addContactByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$contact = NagiosContactPeer::doSelectOne($c);
|
||||||
|
if(!$contact)
|
||||||
|
return false;
|
||||||
|
// Okay, contact is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostContactMemberPeer::HOST, $this->getId());
|
||||||
|
$c->add(NagiosHostContactMemberPeer::CONTACT, $contact->getId());
|
||||||
|
$relationship = NagiosHostContactMemberPeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$relationship = new NagiosHostContactMember();
|
||||||
|
$relationship->setNagiosHost($this);
|
||||||
|
$relationship->setNagiosContact($contact);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addContactGroupByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactGroupPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$contactgroup = NagiosContactGroupPeer::doSelectOne($c);
|
||||||
|
if(!$contactgroup)
|
||||||
|
return false;
|
||||||
|
// Okay, contactgroup is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostContactgroupPeer::HOST, $this->getId());
|
||||||
|
$c->add(NagiosHostContactgroupPeer::CONTACTGROUP, $contactgroup->getId());
|
||||||
|
$relationship = NagiosHostContactgroupPeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$relationship = new NagiosHostContactgroup();
|
||||||
|
$relationship->setNagiosHost($this);
|
||||||
|
$relationship->setNagiosContactGroup($contactgroup);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTemplateInheritance($name) {
|
||||||
|
// First get the template by name
|
||||||
|
$template = NagiosHostTemplatePeer::getByName($name);
|
||||||
|
if(!$template)
|
||||||
|
return false;
|
||||||
|
// Check to see if inheritance already exists
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::SOURCE_HOST, $this->getId());
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::TARGET_TEMPLATE, $template->getId());
|
||||||
|
$relationship = NagiosHostTemplateInheritancePeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Okay, create new one
|
||||||
|
$relationship = new NagiosHostTemplateInheritance();
|
||||||
|
$relationship->setNagiosHost($this);
|
||||||
|
$relationship->setNagiosHostTemplateRelatedByTargetTemplate($template);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNagiosHostCheckCommandParameters($criteria = null, PropelPDO $con = null) {
|
||||||
|
if($criteria == null)
|
||||||
|
$criteria = new Criteria();
|
||||||
|
$criteria->addAscendingOrderByColumn(NagiosHostCheckCommandParameterPeer::ID);
|
||||||
|
return parent::getNagiosHostCheckCommandParameters($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosHost
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosHostCheckCommandParameter.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_host_check_command_parameter' table.
|
||||||
|
*
|
||||||
|
* Parameter for Host Check Command
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostCheckCommandParameter extends BaseNagiosHostCheckCommandParameter {
|
||||||
|
|
||||||
|
} // NagiosHostCheckCommandParameter
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosHostCheckCommandParameterPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosHostCheckCommandParameter.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_host_check_command_parameter' table.
|
||||||
|
*
|
||||||
|
* Parameter for Host Check Command
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostCheckCommandParameterPeer extends BaseNagiosHostCheckCommandParameterPeer {
|
||||||
|
|
||||||
|
} // NagiosHostCheckCommandParameterPeer
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosHostContactMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_host_contact_member' table.
|
||||||
|
*
|
||||||
|
* Contacts which belong to host templates or hosts
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostContactMember extends BaseNagiosHostContactMember {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of NagiosHostContactMember object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosHostContactMember
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosHostContactMemberPeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_host_contact_member' table.
|
||||||
|
*
|
||||||
|
* Contacts which belong to host templates or hosts
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostContactMemberPeer extends BaseNagiosHostContactMemberPeer {
|
||||||
|
|
||||||
|
} // NagiosHostContactMemberPeer
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosHostContactgroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_host_contactgroup' table.
|
||||||
|
*
|
||||||
|
* Contact Group for Host
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostContactgroup extends BaseNagiosHostContactgroup {
|
||||||
|
|
||||||
|
} // NagiosHostContactgroup
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosHostContactgroupPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosHostContactgroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_host_contactgroup' table.
|
||||||
|
*
|
||||||
|
* Contact Group for Host
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostContactgroupPeer extends BaseNagiosHostContactgroupPeer {
|
||||||
|
|
||||||
|
} // NagiosHostContactgroupPeer
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosHostParent.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_host_parent' table.
|
||||||
|
*
|
||||||
|
* Nagios Host Parent Relationship
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostParent extends BaseNagiosHostParent {
|
||||||
|
|
||||||
|
} // NagiosHostParent
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosHostParentPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosHostParent.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_host_parent' table.
|
||||||
|
*
|
||||||
|
* Nagios Host Parent Relationship
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostParentPeer extends BaseNagiosHostParentPeer {
|
||||||
|
|
||||||
|
} // NagiosHostParentPeer
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosHostPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosHost.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_host' table.
|
||||||
|
*
|
||||||
|
* Nagios Host
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostPeer extends BaseNagiosHostPeer {
|
||||||
|
|
||||||
|
public function getByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$host = NagiosHostPeer::doSelectOne($c);
|
||||||
|
if(!$host) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTopLevelHosts() {
|
||||||
|
$con = Propel::getConnection(BaseNagiosHostPeer::DATABASE_NAME);
|
||||||
|
$sql = "SELECT * from nagios_host WHERE (select count(*) FROM nagios_host_parent WHERE nagios_host_parent.child_host = nagios_host.id) = 0 ORDER BY nagios_host.name";
|
||||||
|
$stmt = $con->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$hosts = NagiosHostPeer::populateObjects($stmt);
|
||||||
|
return $hosts;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosHostPeer
|
|
@ -0,0 +1,523 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosHostTemplate.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_host_template' table.
|
||||||
|
*
|
||||||
|
* Nagios Host Template
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostTemplate extends BaseNagiosHostTemplate {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns hosts which are affected by this template, via voodoo-magic
|
||||||
|
* (and recursive powah!)
|
||||||
|
*/
|
||||||
|
public function getAffectedHosts($affectedHosts = null) {
|
||||||
|
if($affectedHosts == null)
|
||||||
|
$affectedHosts = array(); // Hosts array will be indexed by hostname
|
||||||
|
// Get directly affected hosts
|
||||||
|
$inheritances = $this->getNagiosHostTemplateInheritancesRelatedByTargetTemplateJoinNagiosHost();
|
||||||
|
foreach($inheritances as $inheritance) {
|
||||||
|
if($inheritance->getNagiosHostTemplateRelatedBySourceTemplate()) {
|
||||||
|
// This is a template which inherits us, grab it's hosts!
|
||||||
|
$affectedHosts = $inheritance->getNagiosHostTemplateRelatedBySourceTemplate()->getAffectedHosts($affectedHosts);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$host = $inheritance->getNagiosHost();
|
||||||
|
if(!array_key_exists($host->getName(), $affectedHosts)) {
|
||||||
|
$affectedHosts[$host->getName()] = $host;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $affectedHosts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns multi-dimension
|
||||||
|
*
|
||||||
|
* @param unknown_type $hosttemplateinfo
|
||||||
|
* @param unknown_type $hosttemplateinfoSources
|
||||||
|
* @return unknown
|
||||||
|
*/
|
||||||
|
public function getValues($inherited = false) {
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::SOURCE_TEMPLATE, $this->getId());
|
||||||
|
$c->addAscendingOrderByColumn(NagiosHostTemplateInheritancePeer::ORDER);
|
||||||
|
|
||||||
|
$inheritanceTemplates = NagiosHostTemplateInheritancePeer::doSelect($c);
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $inheritanceItem) {
|
||||||
|
$hostTemplate = $inheritanceItem->getNagiosHostTemplateRelatedByTargetTemplate();
|
||||||
|
$templateValues = $hostTemplate->getValues(true);
|
||||||
|
$values = array_merge($values, $templateValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach(NagiosHostTemplatePeer::getFieldNames() as $fieldName) {
|
||||||
|
$colName = NagiosHostTemplatePeer::translateFieldName($fieldName, BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME);
|
||||||
|
// At this point, $fieldName is the fieldname for each column in our table record
|
||||||
|
$colName = strtolower(substr($colName, strlen("nagios_host_template.")));
|
||||||
|
// $colName is now the abbreviated column name.
|
||||||
|
|
||||||
|
switch($colName) {
|
||||||
|
case 'maximum_check_attempts':
|
||||||
|
$colName = 'max_check_attempts';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$methodName = "get" . $fieldName;
|
||||||
|
if(method_exists($this, $methodName)) {
|
||||||
|
$val = $this->{$methodName}();
|
||||||
|
|
||||||
|
if($val !== null) {
|
||||||
|
|
||||||
|
// Yay, let's populate
|
||||||
|
$values[$colName] = array(
|
||||||
|
'inherited' => $inherited,
|
||||||
|
'source' => array('id' => $this->getId(), 'name' => $this->getName()),
|
||||||
|
'value' => $val
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedCommandParameters($self = true) {
|
||||||
|
$parameterList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$parameters = $hostTemplate->getInheritedCommandParameters(false);
|
||||||
|
$parameterList = array_merge($parameterList, $parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$parameters = $this->getNagiosHostCheckCommandParameters();
|
||||||
|
array_merge($parameterList, $parameters);
|
||||||
|
}
|
||||||
|
return $parameterList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedDependencies($self = true) {
|
||||||
|
$dependenciesList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$dependencies = $hostTemplate->getInheritedDependencies(false);
|
||||||
|
$dependenciesList = array_merge($dependenciesList, $dependencies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$dependencies = $this->getNagiosDependencys();
|
||||||
|
$dependenciesList = array_merge($dependenciesList, $dependencies);
|
||||||
|
}
|
||||||
|
return $dependenciesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedEscalations($self = true) {
|
||||||
|
$escalationsList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$escalations = $hostTemplate->getInheritedEscalations(false);
|
||||||
|
$escalationsList = array_merge($escalationsList, $escalations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$escalations = $this->getNagiosEscalations();
|
||||||
|
$escalationsList = array_merge($escalationsList, $escalations);
|
||||||
|
}
|
||||||
|
return $escalationsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedServices($self = true) {
|
||||||
|
$servicesList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$services = $hostTemplate->getInheritedServices(false);
|
||||||
|
$servicesList = array_merge($servicesList, $services);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
|
||||||
|
$services = $this->getNagiosServices();
|
||||||
|
$servicesList = array_merge($servicesList, $services);
|
||||||
|
}
|
||||||
|
return $servicesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedHostGroups($self = true) {
|
||||||
|
$groupList = array();
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$hostgroups = $hostTemplate->getInheritedHostGroups(false);
|
||||||
|
$groupList = array_merge($groupList, $hostgroups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$hostgroupMemberships = $this->getNagiosHostgroupMemberships();
|
||||||
|
foreach($hostgroupMemberships as $membership) {
|
||||||
|
$hostgroup = $membership->getNagiosHostGroup();
|
||||||
|
$groupList[] = $hostgroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedContactGroups($self = true) {
|
||||||
|
$groupList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$contactgroups = $hostTemplate->getInheritedContactGroups(false);
|
||||||
|
$groupList = array_merge($groupList, $contactgroups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$contactgroupMemberships = $this->getNagiosHostContactgroups();
|
||||||
|
foreach($contactgroupMemberships as $membership) {
|
||||||
|
$contactgroup = $membership->getNagiosContactGroup();
|
||||||
|
$groupList[] = $contactgroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedContacts($self = true) {
|
||||||
|
$contactsList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$contacts = $hostTemplate->getInheritedContacts(false);
|
||||||
|
$contactsList = array_merge($contactsList, $contacts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$contactMemberships = $this->getNagiosHostContactMembers();
|
||||||
|
foreach($contactMemberships as $membership) {
|
||||||
|
$contact = $membership->getNagiosContact();
|
||||||
|
$contactsList[] = $contact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $contactsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedNagiosAutodiscoveryServiceFilters($self = true) {
|
||||||
|
$filterList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $hostTemplate) {
|
||||||
|
$filters = $hostTemplate->getInheritedNagiosAutodiscoveryServiceFilters(false);
|
||||||
|
$filterList = array_merge($filterList, $filters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$filters = $this->getNagiosHostTemplateAutodiscoveryServices();
|
||||||
|
$filterList = array_merge($filterList, $filters);
|
||||||
|
}
|
||||||
|
return $filterList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNagiosHostTemplateInheritances() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::SOURCE_TEMPLATE, $this->getId());
|
||||||
|
$c->addAscendingOrderByColumn(NagiosHostTemplateInheritancePeer::ORDER);
|
||||||
|
|
||||||
|
$list = array();
|
||||||
|
$inheritanceTemplates = NagiosHostTemplateInheritancePeer::doSelect($c);
|
||||||
|
foreach($inheritanceTemplates as $inheritanceItem) {
|
||||||
|
$list[] = $inheritanceItem->getNagiosHostTemplateRelatedByTargetTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedCommandWithParameters($cmdObj = null) {
|
||||||
|
$self = false;
|
||||||
|
if($cmdObj === null) {
|
||||||
|
$self = true;
|
||||||
|
// Initialize array
|
||||||
|
$cmdObj = array(
|
||||||
|
'command' => null,
|
||||||
|
'parameters' => array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$inheritedTemplates = $this->getNagiosHostTemplateInheritances();
|
||||||
|
// Inheritedtemplates is our collection of templates that we directly inherit from. Let's grab 'em
|
||||||
|
foreach($inheritedTemplates as $template) {
|
||||||
|
$cmdObj = $template->getInheritedCommandWithParameters($cmdObj);
|
||||||
|
}
|
||||||
|
// Okay, let's check ourselves
|
||||||
|
if($this->getNagiosCommandRelatedByCheckCommand()) {
|
||||||
|
$cmdObj['command'] = array('inherited' => ($self ? false : true),
|
||||||
|
'source' => $this,
|
||||||
|
'command' => $this->getNagiosCommandRelatedByCheckCommand());
|
||||||
|
}
|
||||||
|
$parameters = $this->getNagiosHostCheckCommandParameters();
|
||||||
|
foreach($parameters as $param) {
|
||||||
|
$cmdObj['parameters'][] = array(
|
||||||
|
'inherited' => ($self ? false : true),
|
||||||
|
'source' => $this,
|
||||||
|
'parameter' => $param
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $cmdObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addCheckCommandParameter($value) {
|
||||||
|
$parameter = new NagiosHostCheckCommandParameter();
|
||||||
|
$parameter->setNagiosHostTemplate($this);
|
||||||
|
$parameter->setParameter($value);
|
||||||
|
$parameter->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setCheckCommandByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosCommandRelatedByCheckCommand($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCheckPeriodByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosTimeperiodPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosTimeperiodPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosTimeperiodRelatedByCheckPeriod($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setEventHandlerByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosCommandRelatedByEventHandler($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function setNotificationPeriodByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosTimeperiodPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosTimeperiodPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosTimeperiodRelatedByNotificationPeriod($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addParentByName($name) {
|
||||||
|
$parentId = $this->getParentHost();
|
||||||
|
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$host = NagiosHostPeer::doSelectOne($c);
|
||||||
|
if(!$host)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(empty($parentId)) {
|
||||||
|
$this->setParentHost($host->getId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Okay, let's first see if there's a parent relationship around
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostParentPeer::CHILD_HOST_TEMPLATE, $this->getId());
|
||||||
|
$c->add(NagiosHostParentPeer::PARENT_HOST, $host->getId());
|
||||||
|
$relationship = NagiosHostParentPeer::doSelectOne($c);
|
||||||
|
if($relationship) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Okay, relationship doesn't exist, let's add it!
|
||||||
|
$relationship = new NagiosHostParent();
|
||||||
|
$relationship->setNagiosHostTemplate($this);
|
||||||
|
$relationship->setNagiosHostRelatedByParentHost($host);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addHostgroupByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostgroupPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$hostgroup = NagiosHostgroupPeer::doSelectOne($c);
|
||||||
|
if(!$hostgroup) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Okay, hostgroup is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostgroupMembershipPeer::HOST_TEMPLATE, $this->getId());
|
||||||
|
$c->add(NagiosHostgroupMembershipPeer::HOSTGROUP, $hostgroup->getId());
|
||||||
|
$relationship = NagiosHostgroupMembershipPeer::doSelectOne($c);
|
||||||
|
if($relationship) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relationship = new NagiosHostgroupMembership();
|
||||||
|
$relationship->setNagiosHostTemplate($this);
|
||||||
|
$relationship->setNagiosHostgroup($hostgroup);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addContactByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$contact = NagiosContactPeer::doSelectOne($c);
|
||||||
|
if(!$contact)
|
||||||
|
return false;
|
||||||
|
// Okay, contact is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostContactMemberPeer::TEMPLATE, $this->getId());
|
||||||
|
$c->add(NagiosHostContactMemberPeer::CONTACT, $contact->getId());
|
||||||
|
$relationship = NagiosHostContactMemberPeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$relationship = new NagiosHostContactMember();
|
||||||
|
$relationship->setNagiosHostTemplate($this);
|
||||||
|
$relationship->setNagiosContact($contact);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addContactGroupByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactGroupPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$contactgroup = NagiosContactGroupPeer::doSelectOne($c);
|
||||||
|
if(!$contactgroup) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Okay, contactgroup is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostContactgroupPeer::HOST_TEMPLATE, $this->getId());
|
||||||
|
$c->add(NagiosHostContactgroupPeer::CONTACTGROUP, $contactgroup->getId());
|
||||||
|
$relationship = NagiosHostContactgroupPeer::doSelectOne($c);
|
||||||
|
if($relationship) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relationship = new NagiosHostContactgroup();
|
||||||
|
$relationship->setNagiosHostTemplate($this);
|
||||||
|
$relationship->setNagiosContactGroup($contactgroup);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function integrityCheck() {
|
||||||
|
// Get our services
|
||||||
|
$services = $this->getNagiosServices();
|
||||||
|
foreach($services as $service) {
|
||||||
|
$service->integrityCheck();
|
||||||
|
}
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::SOURCE_TEMPLATE, $this->getId());
|
||||||
|
$c->addAscendingOrderByColumn(NagiosHostTemplateInheritancePeer::ORDER);
|
||||||
|
$inheritanceTemplates = NagiosHostTemplateInheritancePeer::doSelect($c);
|
||||||
|
foreach($inheritanceTemplates as $inheritance) {
|
||||||
|
$template = $inheritance->getNagiosHostTemplateRelatedByTargetTemplate();
|
||||||
|
$template->integrityCheck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTemplateInheritance($name) {
|
||||||
|
// First get the template by name
|
||||||
|
$template = NagiosHostTemplatePeer::getByName($name);
|
||||||
|
if(!$template) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check to see if inheritance already exists
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::SOURCE_TEMPLATE, $this->getId());
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::TARGET_TEMPLATE, $template->getId());
|
||||||
|
$relationship = NagiosHostTemplateInheritancePeer::doSelectOne($c);
|
||||||
|
if($relationship) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Okay, create new one
|
||||||
|
$relationship = new NagiosHostTemplateInheritance();
|
||||||
|
$relationship->setNagiosHostTemplateRelatedBySourceTemplate($this);
|
||||||
|
$relationship->setNagiosHostTemplateRelatedByTargetTemplate($template);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNagiosHostCheckCommandParameters($criteria = null, PropelPDO $con = null) {
|
||||||
|
if($criteria == null)
|
||||||
|
$criteria = new Criteria();
|
||||||
|
$criteria->addAscendingOrderByColumn(NagiosHostCheckCommandParameterPeer::ID);
|
||||||
|
return parent::getNagiosHostCheckCommandParameters($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosHostTemplate
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosHostTemplateAutodiscoveryService.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_host_template_autodiscovery_service' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostTemplateAutodiscoveryService extends BaseNagiosHostTemplateAutodiscoveryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of NagiosHostTemplateAutodiscoveryService object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosHostTemplateAutodiscoveryService
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosHostTemplateAutodiscoveryServicePeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_host_template_autodiscovery_service' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostTemplateAutodiscoveryServicePeer extends BaseNagiosHostTemplateAutodiscoveryServicePeer {
|
||||||
|
|
||||||
|
} // NagiosHostTemplateAutodiscoveryServicePeer
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosHostTemplateInheritance.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_host_template_inheritance' table.
|
||||||
|
*
|
||||||
|
* Nagios Host Template Inheritance
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostTemplateInheritance extends BaseNagiosHostTemplateInheritance {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of NagiosHostTemplateInheritance object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to determine if inheritance creates a circular chain. This is
|
||||||
|
* done by recursively going through inheritance trees and seeing if the
|
||||||
|
* source template is already found. If so, this would create a circular
|
||||||
|
* inheritance loop and destroy our world as we know it.
|
||||||
|
*
|
||||||
|
*@param int $targetTemplateId what template Id are we looking at
|
||||||
|
*@param int $originalSourceTemplateId what template Id are we looking for
|
||||||
|
*/
|
||||||
|
static function isCircular($targetTemplateId, $originalSourceTemplateId) {
|
||||||
|
if($targetTemplateId == $originalSourceTemplateId)
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
// Get all the potential inheritance in which the target template id
|
||||||
|
// is the source
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplateInheritancePeer::SOURCE_TEMPLATE, $targetTemplateId);
|
||||||
|
$inheritances = NagiosHostTemplateInheritancePeer::doSelect($c);
|
||||||
|
foreach($inheritances as $inheritance) {
|
||||||
|
if(NagiosHostTemplateInheritance::isCircular($inheritance->getTargetTemplate(), $originalSourceTemplateId))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(PropelPDO $con = null) {
|
||||||
|
parent::delete($con);
|
||||||
|
// Check our service dependencies
|
||||||
|
$targetTemplate = $this->getNagiosHostTemplateRelatedByTargetTemplate();
|
||||||
|
$targetTemplate->integrityCheck();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(PropelPDO $con = null) {
|
||||||
|
if(NagiosHostTemplateInheritance::isCircular($this->getTargetTemplate(), $this->getSourceTemplate())) {
|
||||||
|
throw new Exception("Adding that inheritance would create a circular chain.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parent::save($con); // Okay, we've saved
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosHostTemplateInheritance
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosHostTemplateInheritancePeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_host_template_inheritance' table.
|
||||||
|
*
|
||||||
|
* Nagios Host Template Inheritance
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostTemplateInheritancePeer extends BaseNagiosHostTemplateInheritancePeer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosHostTemplateInheritancePeer
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosHostTemplatePeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosHostTemplate.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_host_template' table.
|
||||||
|
*
|
||||||
|
* Nagios Host Template
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostTemplatePeer extends BaseNagiosHostTemplatePeer {
|
||||||
|
|
||||||
|
|
||||||
|
public function getByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostTemplatePeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$template = NagiosHostTemplatePeer::doSelectOne($c);
|
||||||
|
if(!$template) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosHostTemplatePeer
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosHostgroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_hostgroup' table.
|
||||||
|
*
|
||||||
|
* Nagios Hostgroup
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostgroup extends BaseNagiosHostgroup {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We should update this.
|
||||||
|
*
|
||||||
|
* @return unknown
|
||||||
|
*/
|
||||||
|
public function getMembers() {
|
||||||
|
$members = array(); // Members are indexed by host names
|
||||||
|
$criteria = new Criteria();
|
||||||
|
$criteria->add(NagiosHostgroupMembershipPeer::HOST, NULL, Criteria::ISNOTNULL);
|
||||||
|
$criteria->add(NagiosHostgroupMembershipPeer::HOSTGROUP, $this->getId());
|
||||||
|
$memberships = NagiosHostgroupMembershipPeer::doSelect($criteria);
|
||||||
|
foreach($memberships as $member) {
|
||||||
|
$host = $member->getNagiosHost();
|
||||||
|
if(!array_key_exists($host->getName(), $members)) {
|
||||||
|
$members[$host->getName()] = $host;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$criteria = new Criteria();
|
||||||
|
$criteria->add(NagiosHostgroupMembershipPeer::HOST_TEMPLATE, NULL, Criteria::ISNOTNULL);
|
||||||
|
$criteria->add(NagiosHostgroupMembershipPeer::HOSTGROUP, $this->getId());
|
||||||
|
$memberships = NagiosHostgroupMembershipPeer::doSelect($criteria);
|
||||||
|
foreach($memberships as $member) {
|
||||||
|
$template = $member->getNagiosHostTemplate();
|
||||||
|
$members = $template->getAffectedHosts($members);
|
||||||
|
}
|
||||||
|
return $members;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addMembersByHostgroup($name) {
|
||||||
|
// First get hostgroup
|
||||||
|
$hostgroup = NagiosHostgroupPeer::getByName($name);
|
||||||
|
if(!$hostgroup) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get the members
|
||||||
|
$memberships = $hostgroup->getNagiosHostgroupMemberships();
|
||||||
|
foreach($memberships as $membership) {
|
||||||
|
$host = $membership->getNagiosHost();
|
||||||
|
// Check to see if we already have this in our member list
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostgroupMembershipPeer::HOSTGROUP, $this->getId());
|
||||||
|
$c->add(NagiosHostgroupMembershipPeer::HOST, $host->getId());
|
||||||
|
$relationship = NagiosHostgroupMembershipPeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Create new relationship
|
||||||
|
$relationship = new NagiosHostgroupMembership();
|
||||||
|
$relationship->setNagiosHost($host);
|
||||||
|
$relationship->setNagiosHostgroup($this);
|
||||||
|
$relationship->save();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addMemberByName($name) {
|
||||||
|
// Support for adding ALL hosts
|
||||||
|
if($name == "*") {
|
||||||
|
$hosts = NagiosHostPeer::doSelect(new Criteria());
|
||||||
|
foreach($hosts as $host) {
|
||||||
|
$this->addMemberByName($host->getName());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$host = NagiosHostPeer::getByName($name);
|
||||||
|
if(!$host) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostgroupMembershipPeer::HOSTGROUP, $this->getId());
|
||||||
|
$c->add(NagiosHostgroupMembershipPeer::HOST, $host->getId());
|
||||||
|
$relationship = NagiosHostgroupMembershipPeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
return true; // Already exists.
|
||||||
|
}
|
||||||
|
// Create new relationship
|
||||||
|
$relationship = new NagiosHostgroupMembership();
|
||||||
|
$relationship->setNagiosHost($host);
|
||||||
|
$relationship->setNagiosHostgroup($this);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosHostgroup
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosHostgroupMembership.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_hostgroup_membership' table.
|
||||||
|
*
|
||||||
|
* Hostgroup Membership for Host
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostgroupMembership extends BaseNagiosHostgroupMembership {
|
||||||
|
|
||||||
|
} // NagiosHostgroupMembership
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosHostgroupMembershipPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosHostgroupMembership.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_hostgroup_membership' table.
|
||||||
|
*
|
||||||
|
* Hostgroup Membership for Host
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostgroupMembershipPeer extends BaseNagiosHostgroupMembershipPeer {
|
||||||
|
|
||||||
|
} // NagiosHostgroupMembershipPeer
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosHostgroupPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosHostgroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_hostgroup' table.
|
||||||
|
*
|
||||||
|
* Nagios Hostgroup
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosHostgroupPeer extends BaseNagiosHostgroupPeer {
|
||||||
|
|
||||||
|
public function getByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosHostgroupPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$hostgroup = NagiosHostgroupPeer::doSelectOne($c);
|
||||||
|
if(!$hostgroup)
|
||||||
|
return false;
|
||||||
|
return $hostgroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosHostgroupPeer
|
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosMainConfiguration.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_main_configuration' table.
|
||||||
|
*
|
||||||
|
* Nagios Main Configuration
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosMainConfiguration extends BaseNagiosMainConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* @return LilacError Collection of errors and warnings for validation purposes
|
||||||
|
*/
|
||||||
|
public function verify() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValues() {
|
||||||
|
$values = array();
|
||||||
|
$fieldNames = NagiosMainConfigurationPeer::getFieldNames(BasePeer::TYPE_FIELDNAME);
|
||||||
|
foreach($fieldNames as $fieldName) {
|
||||||
|
$method = "get" . NagiosMainConfigurationPeer::translateFieldName($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
|
||||||
|
$val = $this->$method();
|
||||||
|
if($val !== null) {
|
||||||
|
$values[$fieldName] = array();
|
||||||
|
|
||||||
|
$values[$fieldName]['value'] = $val;
|
||||||
|
$values[$fieldName]['source']['id'] = null;
|
||||||
|
$values[$fieldName]['inherited'] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGlobalHostEventHandlerByName($command_name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if($command) {
|
||||||
|
$this->setGlobalHostEventHandler($command->getId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGlobalServiceEventHandlerByName($command_name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if($command) {
|
||||||
|
$this->setGlobalServiceEventHandler($command->getId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHostPerfdataCommandByName($command_name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if($command) {
|
||||||
|
$this->setHostPerfdataCommand($command->getId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setServicePerfdataCommandByName($command_name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if($command) {
|
||||||
|
$this->setServicePerfdataCommand($command->getId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHostPerfdataFileProcessingCommandByName($command_name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if($command) {
|
||||||
|
$this->setHostPerfdataFileProcessingCommand($command->getId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setServicePerfdataFileProcessingCommandByName($command_name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if($command) {
|
||||||
|
$this->setServicePerfdataFileProcessingCommand($command->getId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // NagiosMainConfiguration
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosMainConfigurationPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosMainConfiguration.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_main_configuration' table.
|
||||||
|
*
|
||||||
|
* Nagios Main Configuration
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosMainConfigurationPeer extends BaseNagiosMainConfigurationPeer {
|
||||||
|
|
||||||
|
} // NagiosMainConfigurationPeer
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosResource.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_resource' table.
|
||||||
|
*
|
||||||
|
* Nagios Resource
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosResource extends BaseNagiosResource {
|
||||||
|
|
||||||
|
} // NagiosResource
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosResourcePeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosResource.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_resource' table.
|
||||||
|
*
|
||||||
|
* Nagios Resource
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosResourcePeer extends BaseNagiosResourcePeer {
|
||||||
|
|
||||||
|
} // NagiosResourcePeer
|
|
@ -0,0 +1,451 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosService.php';
|
||||||
|
require_once 'NagiosServiceGroupMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_service' table.
|
||||||
|
*
|
||||||
|
* Nagios Service
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosService extends BaseNagiosService {
|
||||||
|
|
||||||
|
public function getOwnerDescription() {
|
||||||
|
if($this->getNagiosHost()) {
|
||||||
|
return "Host " . $this->getNagiosHost()->getName();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if($this->getNagiosHostTemplate()) {
|
||||||
|
return "Host Template " . $this->getNagiosHostTemplate()->getName();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if($this->getNagiosHostgroup()) {
|
||||||
|
return "Hostgroup " . $this->getNagiosHostgroup()->getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValues($inherited = false) {
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceTemplateInheritancePeer::SOURCE_SERVICE, $this->getId());
|
||||||
|
$c->addAscendingOrderByColumn(NagiosServiceTemplateInheritancePeer::ORDER);
|
||||||
|
|
||||||
|
$inheritanceTemplates = NagiosServiceTemplateInheritancePeer::doSelect($c);
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $inheritanceItem) {
|
||||||
|
$serviceTemplate = $inheritanceItem->getNagiosServiceTemplateRelatedByTargetTemplate();
|
||||||
|
$templateValues = $serviceTemplate->getValues(true);
|
||||||
|
$values = array_merge($values, $templateValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach(NagiosServicePeer::getFieldNames() as $fieldName) {
|
||||||
|
$colName = NagiosServicePeer::translateFieldName($fieldName, BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME);
|
||||||
|
// At this point, $fieldName is the fieldname for each column in our table record
|
||||||
|
$colName = strtolower(substr($colName, strlen("nagios_service.")));
|
||||||
|
// $colName is now the abbreviated column name.
|
||||||
|
|
||||||
|
switch($colName) {
|
||||||
|
case 'maximum_check_attempts':
|
||||||
|
$colName = 'max_check_attempts';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$methodName = "get" . $fieldName;
|
||||||
|
if(method_exists($this, $methodName)) {
|
||||||
|
$val = $this->{$methodName}();
|
||||||
|
|
||||||
|
|
||||||
|
if($val !== null) {
|
||||||
|
|
||||||
|
// Yay, let's populate
|
||||||
|
$values[$colName] = array(
|
||||||
|
'inherited' => $inherited,
|
||||||
|
'source' => array('id' => $this->getId(), 'name' => $this->getDescription()),
|
||||||
|
'value' => $val
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedCommandParameters($self = true) {
|
||||||
|
$parameterList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosServiceTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $serviceTemplate) {
|
||||||
|
$parameters = $serviceTemplate->getInheritedCommandParameters(false);
|
||||||
|
$parameterList = array_merge($parameterList, $parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$parameters = $this->getNagiosServiceCheckCommandParameters();
|
||||||
|
array_merge($parameterList, $parameters);
|
||||||
|
}
|
||||||
|
return $parameterList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedDependencies($self = true) {
|
||||||
|
$dependenciesList = array();
|
||||||
|
$inheritanceTemplates = $this->getNagiosServiceTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $serviceTemplate) {
|
||||||
|
$dependencies = $serviceTemplate->getInheritedDependencies(false);
|
||||||
|
$dependenciesList = array_merge($dependenciesList, $dependencies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$dependencies = $this->getNagiosDependencys();
|
||||||
|
$dependenciesList = array_merge($dependenciesList, $dependencies);
|
||||||
|
}
|
||||||
|
return $dependenciesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedEscalations($self = true) {
|
||||||
|
$escalationsList = array();
|
||||||
|
$inheritanceTemplates = $this->getNagiosServiceTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $serviceTemplate) {
|
||||||
|
$escalations = $serviceTemplate->getInheritedEscalations(false);
|
||||||
|
$escalationsList = array_merge($escalationsList, $escalations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$escalations = $this->getNagiosEscalations();
|
||||||
|
$escalationsList = array_merge($escalationsList, $escalations);
|
||||||
|
}
|
||||||
|
return $escalationsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedServiceGroups($self = true) {
|
||||||
|
$groupList = array();
|
||||||
|
$inheritanceTemplates = $this->getNagiosServiceTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $serviceTemplate) {
|
||||||
|
$servicegroup = $serviceTemplate->getInheritedServiceGroups(false);
|
||||||
|
$groupList = array_merge($groupList, $servicegroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$servicegroupMemberships = $this->getNagiosServiceGroupMembers();
|
||||||
|
foreach($servicegroupMemberships as $membership) {
|
||||||
|
$servicegroup = $membership->getNagiosServiceGroup();
|
||||||
|
$groupList[] = $servicegroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInheritedContacts($self = true) {
|
||||||
|
$contactsList = array();
|
||||||
|
|
||||||
|
$inheritanceTemplates = $this->getNagiosServiceTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $serviceTemplate) {
|
||||||
|
$contacts = $serviceTemplate->getInheritedContacts(false);
|
||||||
|
$contactsList = array_merge($contactsList, $contacts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$contactMemberships = $this->getNagiosServiceContactMembers();
|
||||||
|
foreach($contactMemberships as $membership) {
|
||||||
|
$contact = $membership->getNagiosContact();
|
||||||
|
$contactsList[] = $contact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $contactsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getInheritedContactGroups($self = true) {
|
||||||
|
$groupList = array();
|
||||||
|
$inheritanceTemplates = $this->getNagiosServiceTemplateInheritances();
|
||||||
|
|
||||||
|
if(count($inheritanceTemplates)) {
|
||||||
|
// This template has inherited templates, let's bring their values in
|
||||||
|
foreach($inheritanceTemplates as $serviceTemplate) {
|
||||||
|
$contactgroups = $serviceTemplate->getInheritedContactGroups(false);
|
||||||
|
$groupList = array_merge($groupList, $contactgroups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$self) {
|
||||||
|
$contatgroupMemberships = $this->getNagiosServiceContactGroupMembers();
|
||||||
|
foreach($contatgroupMemberships as $membership) {
|
||||||
|
$contactgroup = $membership->getNagiosContactGroup();
|
||||||
|
$groupList[] = $contactgroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addCheckCommandParameter($value) {
|
||||||
|
$parameter = new NagiosServiceCheckCommandParameter();
|
||||||
|
$parameter->setNagiosService($this);
|
||||||
|
$parameter->setParameter($value);
|
||||||
|
$parameter->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getInheritedCommandWithParameters($cmdObj = null) {
|
||||||
|
$self = false;
|
||||||
|
if($cmdObj === null) {
|
||||||
|
$self = true;
|
||||||
|
// Initialize array
|
||||||
|
$cmdObj = array(
|
||||||
|
'command' => null,
|
||||||
|
'parameters' => array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$inheritedTemplates = $this->getNagiosServiceTemplateInheritances();
|
||||||
|
// Inheritedtemplates is our collection of templates that we directly inherit from. Let's grab 'em
|
||||||
|
foreach($inheritedTemplates as $template) {
|
||||||
|
$cmdObj = $template->getInheritedCommandWithParameters($cmdObj);
|
||||||
|
}
|
||||||
|
// Okay, let's check ourselves
|
||||||
|
if($this->getNagiosCommandRelatedByCheckCommand()) {
|
||||||
|
$cmdObj['command'] = array('inherited' => ($self ? false : true),
|
||||||
|
'source' => $this,
|
||||||
|
'command' => $this->getNagiosCommandRelatedByCheckCommand());
|
||||||
|
}
|
||||||
|
$parameters = $this->getNagiosServiceCheckCommandParameters();
|
||||||
|
foreach($parameters as $param) {
|
||||||
|
$cmdObj['parameters'][] = array(
|
||||||
|
'inherited' => ($self ? false : true),
|
||||||
|
'source' => $this,
|
||||||
|
'parameter' => $param
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $cmdObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNagiosServiceTemplateInheritances() {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceTemplateInheritancePeer::SOURCE_SERVICE , $this->getId());
|
||||||
|
$c->addAscendingOrderByColumn(NagiosServiceTemplateInheritancePeer::ORDER);
|
||||||
|
|
||||||
|
$list = array();
|
||||||
|
$inheritanceTemplates = NagiosServiceTemplateInheritancePeer::doSelect($c);
|
||||||
|
foreach($inheritanceTemplates as $inheritanceItem) {
|
||||||
|
$list[] = $inheritanceItem->getNagiosServiceTemplateRelatedByTargetTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function integrityCheck() {
|
||||||
|
// Get NagiosDependencyTargets with Target service being this service
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosDependencyTargetPeer::TARGET_SERVICE, $this->getId());
|
||||||
|
$targets = NagiosDependencyTargetPeer::doSelect($c);
|
||||||
|
foreach($targets as $target) {
|
||||||
|
$found = false;
|
||||||
|
// Get host
|
||||||
|
$host = $target->getNagiosHost();
|
||||||
|
$services = $host->getNagiosServices();
|
||||||
|
foreach($services as $service) {
|
||||||
|
if($service->getId() == $this->getId()) {
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$found) {
|
||||||
|
$services = $host->getInheritedServices();
|
||||||
|
foreach($services as $service) {
|
||||||
|
if($service->getId() == $this->getId()) {
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$found) {
|
||||||
|
$target->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCheckCommandByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosCommandRelatedByCheckCommand($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCheckPeriodByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosTimeperiodPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosTimeperiodPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosTimeperiodRelatedByCheckPeriod($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setEventHandlerByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosCommandPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosCommandPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosCommandRelatedByEventHandler($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function setNotificationPeriodByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosTimeperiodPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$command = NagiosTimeperiodPeer::doSelectOne($c);
|
||||||
|
if(!$command)
|
||||||
|
return false;
|
||||||
|
$this->setNagiosTimeperiodRelatedByNotificationPeriod($command);
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addServicegroupByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceGroupPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$servicegroup = NagiosServiceGroupPeer::doSelectOne($c);
|
||||||
|
if(!$servicegroup) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Okay, servicegroup is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceGroupMemberPeer::SERVICE, $this->getId());
|
||||||
|
$c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $servicegroup->getId());
|
||||||
|
$relationship = NagiosServiceGroupMemberPeer::doSelectOne($c);
|
||||||
|
if($relationship) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relationship = new NagiosServiceGroupMember();
|
||||||
|
$relationship->setNagiosService($this);
|
||||||
|
$relationship->setNagiosServiceGroup($servicegroup);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addContactByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$contact = NagiosContactPeer::doSelectOne($c);
|
||||||
|
if(!$contact)
|
||||||
|
return false;
|
||||||
|
// Okay, contact is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceContactMemberPeer::SERVICE, $this->getId());
|
||||||
|
$c->add(NagiosServiceContactMemberPeer::CONTACT, $contact->getId());
|
||||||
|
$relationship = NagiosServiceContactMemberPeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$relationship = new NagiosServiceContactMember();
|
||||||
|
$relationship->setNagiosService($this);
|
||||||
|
$relationship->setNagiosContact($contact);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addContactGroupByName($name) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosContactGroupPeer::NAME, $name);
|
||||||
|
$c->setIgnoreCase(true);
|
||||||
|
$contactgroup = NagiosContactGroupPeer::doSelectOne($c);
|
||||||
|
if(!$contactgroup) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Okay, contactgroup is valid, check for relationship
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceContactGroupMemberPeer::SERVICE, $this->getId());
|
||||||
|
$c->add(NagiosServiceContactGroupMemberPeer::CONTACT_GROUP, $contactgroup->getId());
|
||||||
|
$relationship = NagiosServiceContactGroupMemberPeer::doSelectOne($c);
|
||||||
|
if($relationship) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relationship = new NagiosServiceContactGroupMember();
|
||||||
|
$relationship->setNagiosService($this);
|
||||||
|
$relationship->setNagiosContactGroup($contactgroup);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTemplateInheritance($name) {
|
||||||
|
// First get the template by name
|
||||||
|
$template = NagiosServiceTemplatePeer::getByName($name);
|
||||||
|
if(!$template) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check to see if inheritance already exists
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceTemplateInheritancePeer::SOURCE_SERVICE, $this->getId());
|
||||||
|
$c->add(NagiosServiceTemplateInheritancePeer::TARGET_TEMPLATE, $template->getId());
|
||||||
|
$relationship = NagiosServiceTemplateInheritancePeer::doSelectOne($c);
|
||||||
|
if($relationship) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Okay, create new one
|
||||||
|
$relationship = new NagiosServiceTemplateInheritance();
|
||||||
|
$relationship->setNagiosService($this);
|
||||||
|
$relationship->setNagiosServiceTemplateRelatedByTargetTemplate($template);
|
||||||
|
$relationship->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNagiosServiceCheckCommandParameters($criteria = null, PropelPDO $con = null) {
|
||||||
|
if($criteria == null)
|
||||||
|
$criteria = new Criteria();
|
||||||
|
$criteria->addAscendingOrderByColumn(NagiosServiceCheckCommandParameterPeer::ID);
|
||||||
|
return parent::getNagiosServiceCheckCommandParameters($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosService
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosServiceCheckCommandParameter.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_service_check_command_parameter' table.
|
||||||
|
*
|
||||||
|
* Parameter for check command for service or service template
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceCheckCommandParameter extends BaseNagiosServiceCheckCommandParameter {
|
||||||
|
|
||||||
|
} // NagiosServiceCheckCommandParameter
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosServiceCheckCommandParameterPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosServiceCheckCommandParameter.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_service_check_command_parameter' table.
|
||||||
|
*
|
||||||
|
* Parameter for check command for service or service template
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceCheckCommandParameterPeer extends BaseNagiosServiceCheckCommandParameterPeer {
|
||||||
|
|
||||||
|
} // NagiosServiceCheckCommandParameterPeer
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosServiceContactGroupMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_service_contact_group_member' table.
|
||||||
|
*
|
||||||
|
* Nagios Service Group
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceContactGroupMember extends BaseNagiosServiceContactGroupMember {
|
||||||
|
|
||||||
|
} // NagiosServiceContactGroupMember
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosServiceContactGroupMemberPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosServiceContactGroupMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_service_contact_group_member' table.
|
||||||
|
*
|
||||||
|
* Nagios Service Group
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceContactGroupMemberPeer extends BaseNagiosServiceContactGroupMemberPeer {
|
||||||
|
|
||||||
|
} // NagiosServiceContactGroupMemberPeer
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosServiceContactMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_service_contact_member' table.
|
||||||
|
*
|
||||||
|
* Contacts which belong to service templates or services
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceContactMember extends BaseNagiosServiceContactMember {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of NagiosServiceContactMember object.
|
||||||
|
* @see parent::__construct()
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Make sure that parent constructor is always invoked, since that
|
||||||
|
// is where any default values for this object are set.
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosServiceContactMember
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'om/BaseNagiosServiceContactMemberPeer.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_service_contact_member' table.
|
||||||
|
*
|
||||||
|
* Contacts which belong to service templates or services
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceContactMemberPeer extends BaseNagiosServiceContactMemberPeer {
|
||||||
|
|
||||||
|
} // NagiosServiceContactMemberPeer
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosServiceGroup.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_service_group' table.
|
||||||
|
*
|
||||||
|
* Nagios Service Group
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceGroup extends BaseNagiosServiceGroup {
|
||||||
|
|
||||||
|
public function addService($service) {
|
||||||
|
// First check to see if the membership exists
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $this->getId());
|
||||||
|
$c->add(NagiosServiceGroupMemberPeer::SERVICE, $service->getId());
|
||||||
|
$membership = NagiosServiceGroupMemberPeer::doSelectOne($c);
|
||||||
|
if($membership)
|
||||||
|
return true;
|
||||||
|
$membership = new NagiosServiceGroupMember();
|
||||||
|
$membership->setNagiosServiceGroup($this);
|
||||||
|
$membership->setNagiosService($service);
|
||||||
|
$membership->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addMembersByServiceGroup($name) {
|
||||||
|
// First get servicegroup
|
||||||
|
$servicegroup = NagiosServiceGroupPeer::getByName($name);
|
||||||
|
if(!$servicegroup) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get the members
|
||||||
|
$memberships = $servicegroup->getNagiosServiceGroupMembers();
|
||||||
|
foreach($memberships as $membership) {
|
||||||
|
$service = $membership->getNagiosService();
|
||||||
|
// Check to see if we already have this in our member list
|
||||||
|
$id = $this->getId();
|
||||||
|
if(!empty($id)) {
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $this->getId());
|
||||||
|
$c->add(NagiosServiceGroupMemberPeer::SERVICE, $service->getId());
|
||||||
|
$relationship = NagiosServiceGroupMemberPeer::doSelectOne($c);
|
||||||
|
if($relationship)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Create new relationship
|
||||||
|
$relationship = new NagiosServiceGroupMember();
|
||||||
|
$relationship->setNagiosService($service);
|
||||||
|
$relationship->setNagiosServiceGroup($this);
|
||||||
|
$relationship->save();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // NagiosServiceGroup
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'om/BaseNagiosServiceGroupMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'nagios_service_group_member' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceGroupMember extends BaseNagiosServiceGroupMember {
|
||||||
|
|
||||||
|
} // NagiosServiceGroupMember
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'om/BaseNagiosServiceGroupMemberPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'NagiosServiceGroupMember.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'nagios_service_group_member' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This class was autogenerated by Propel on:
|
||||||
|
*
|
||||||
|
* Thu Dec 13 21:25:24 2007
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
*/
|
||||||
|
class NagiosServiceGroupMemberPeer extends BaseNagiosServiceGroupMemberPeer {
|
||||||
|
|
||||||
|
} // NagiosServiceGroupMemberPeer
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue