# MonArch - Groundwork Monitor Architect
# MonarchForms.pm
#
############################################################################
# Release 4.0
# November 2011
############################################################################
#
# Original author: Scott Parris
#
# Copyright 2007-2011 GroundWork Open Source, Inc. (GroundWork)
# All rights reserved. This program is free software; you can redistribute
# it and/or modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# 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.
#
use strict;
use MonarchInstrument;
package Forms;
my $doc_root_monarch = '/monarch';
my $cgi_exe = 'monarch.cgi';
my $SERVER_SOFTWARE = $ENV{SERVER_SOFTWARE};
my $monarch_cgi;
my $monarch_css;
my $monarch_html;
my $monarch_images;
my $monarch_js;
my $monarch_download;
my $monarch_export;
if (defined($SERVER_SOFTWARE) && $SERVER_SOFTWARE eq 'TOMCAT') {
$monarch_cgi = '/monarch';
$monarch_css = '/monarch/css';
$monarch_html = '/monarch/html';
$monarch_images = '/monarch/images';
$monarch_js = '/monarch/js';
$monarch_download = '/monarch/download';
$monarch_export = '/monarch-export';
}
elsif ( -e '/usr/local/groundwork/config/db.properties' ) {
$monarch_cgi = '/monarch/cgi-bin';
$monarch_css = '/monarch';
$monarch_html = '/monarch';
$monarch_images = '/monarch/images';
$monarch_js = '/monarch';
$monarch_download = '/monarch/download';
$monarch_export = '/monarch/download';
}
else {
# Standalone Monarch (outside of GW Monitor) is no longer supported.
}
my $form_class = 'row1';
my $global_cell_pad = 3;
my $disable_test_buttons = 0; # set to 0 or 1
my $extend_page = '
';
sub members(@) {
my $title = $_[1];
my $name = $_[2];
my $members = $_[3];
my $nonmembers = $_[4];
my $req = $_[5];
my $size = $_[6];
my $doc = $_[7];
my $override = $_[8];
my $tab = $_[9];
return members_submit (undef, $title, $name, $members, $nonmembers, $req, $size, '', $doc, $override, $tab);
}
sub members_submit(@) {
my $title = $_[1];
my $name = $_[2];
my $members = $_[3];
my $nonmembers = $_[4];
my $req = $_[5];
my $size = $_[6];
my $submit = $_[7];
my $doc = $_[8];
my $override = $_[9];
my $tab = $_[10];
my $tabindex = $tab ? "tabindex=\"$tab\"" : '';
$submit = $submit ? 'selIt();submit();' : '';
if ( !$size ) { $size = 15 }
$req = $req ? "
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= "\n | \n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
|
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= " | \n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | ); # Handle non-automatic coercions. $value = 0 if !defined($value) || $value eq '' || $value eq '-zero-'; if ( $value == 1 ) { $detail .= "\n"; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
| ); if ($value) { $detail .= "\n"; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= " | \n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
| ); if ( $value == 1 ) { $detail .= "\n"; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title |
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title $req | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= "\n | \n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | );
my $got_selected = undef;
foreach my $item (@list) {
my $title = $item;
$title =~ s/_/ /g;
foreach my $selected (@selected) {
if ( $item eq $selected ) { $got_selected = 1 }
}
if ($got_selected) {
$got_selected = undef;
$detail .= "\n \u$title "; } else { $detail .= "\n \u$title "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
| $title | ); if ($doc) { $detail .= "\n? | "; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
|
| $title | ); if ($doc) { $detail .= "\n? | "; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title | ); if ($doc) { $detail .= "\n? | "; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
|
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title | ); if ($doc) { $detail .= "\n\n ? \n | "; } else { $detail .= "\n\n | "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}$req |
| $title | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= "\n | \n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $req |
| Test: |
|
|||||||
| $results | ||||||||
| Test: | Host: | |
| $results | ||
| Install plugin | ||
| New command from an existing plugin | ||
| Clone a command: |
| $title | ); if ($name) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ($doc) { $detail .= "\n\n ? "; } else { $detail .= "\n | \n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $display |
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= "\n | \n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $req |
| $title | $req |
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | $title | ); if ($doc) { $detail .= "\n\n ? | "; } elsif (! $text_width) { $detail .= "\n\n | "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}$req |
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | Stalking options: $req | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= "\n | \n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | );
my @opts = ( 'd', 'o', 'u' );
my $desc = undef;
foreach my $opt (@opts) {
if ( $opt =~ 'd' ) {
$desc = 'down';
}
elsif ( $opt =~ 'o' ) {
$desc = 'up';
}
elsif ( $opt =~ 'u' ) {
$desc = 'unreachable';
}
my $got_opt = undef;
foreach my $sel (@selected) {
if ( $sel eq $opt ) { $got_opt = 1 }
}
if ($got_opt) {
$detail .= "\n \u$desc $req "; } else { $detail .= "\n \u$desc $req "; } $req = ''; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | \u$title: | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= "\n | \n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | );
my @opts = ();
if ( $obj =~ /service_escalation/ ) {
@opts = ( 'r', 'w', 'u', 'c' );
}
elsif ( $obj =~ /escalation/ ) {
@opts = ( 'r', 'd', 'u' );
}
elsif ( $obj =~ /contact/ && $name =~ /service/ ) {
@opts = ( 'u', 'c', 'w', 'r' );
if ( $nagios_ver =~ /^[23]\.x$/ ) { push @opts, 'f'; }
if ( $nagios_ver =~ /^[3]\.x$/ ) { push @opts, 's'; }
push @opts, 'n';
}
elsif ( $obj =~ /contact/ && $name =~ /host/ ) {
@opts = ( 'd', 'u', 'r' );
if ( $nagios_ver =~ /^[23]\.x$/ ) { push @opts, 'f'; }
if ( $nagios_ver =~ /^[3]\.x$/ ) { push @opts, 's'; }
push @opts, 'n';
}
elsif ( $obj =~ /service/ ) {
@opts = ( 'u', 'c', 'w', 'r' );
if ( $nagios_ver =~ /^[23]\.x$/ ) { push @opts, 'f'; }
if ( $nagios_ver =~ /^[3]\.x$/ ) { push @opts, 's'; }
push @opts, 'n';
}
elsif ( $obj =~ /host/ ) {
@opts = ( 'd', 'u', 'r' );
if ( $nagios_ver =~ /^[23]\.x$/ ) { push @opts, 'f'; }
if ( $nagios_ver =~ /^[3]\.x$/ ) { push @opts, 's'; }
push @opts, 'n';
}
my $desc = undef;
foreach my $opt (@opts) {
if ( $opt =~ 'd' ) {
$desc = 'down';
}
elsif ( $opt eq 'u' ) {
$desc = 'unreachable';
if ( $obj =~ /service/ ) { $desc = 'unknown' }
if ( $obj =~ /contact/ && $name =~ /service/ ) { $desc = 'unknown' }
}
elsif ( $opt eq 'r' ) {
$desc = 'recovery';
}
elsif ( $opt eq 'c' ) {
$desc = 'critical';
}
elsif ( $opt eq 'w' ) {
$desc = 'warning';
}
elsif ( $opt eq 'n' ) {
$desc = 'none';
}
elsif ( $opt eq 'f' ) {
$desc = 'flapping';
}
elsif ( $opt eq 's' ) {
$desc = 'downtime';
}
my $got_opt = undef;
foreach my $sel (@selected) {
if ( $sel eq $opt ) { $got_opt = 1 }
}
if ($got_opt) {
$detail .= "\n \u$desc $req "; } else { $detail .= "\n \u$desc $req "; } $req = ''; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |
| "; } else { $detail .= "\n | "; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | \u$title: | ); if ($doc) { $detail .= "\n\n ? "; } else { $detail .= "\n | \n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} | );
my @opts = ( 'o', 'w', 'u', 'c', 'n' );
if ( $type eq 'host_dependencies' ) { @opts = ( 'o', 'd', 'u', 'p', 'n' ) }
my $desc = undef;
foreach my $opt (@opts) {
if ( $opt eq 'o' && $type eq 'host_dependencies' ) {
$desc = 'up';
}
elsif ( $opt eq 'o' ) {
$desc = 'okay';
}
elsif ( $opt eq 'u' && $type eq 'host_dependencies' ) {
$desc = 'unreachable';
}
elsif ( $opt eq 'u' ) {
$desc = 'unknown';
}
elsif ( $opt eq 'd' ) {
$desc = 'down';
}
elsif ( $opt eq 'r' ) {
$desc = 'recovery';
}
elsif ( $opt eq 'c' ) {
$desc = 'critical';
}
elsif ( $opt eq 'w' ) {
$desc = 'warning';
}
elsif ( $opt eq 'p' ) {
$desc = 'pending';
}
elsif ( $opt eq 'n' ) {
$desc = 'none';
}
my $got_opt = undef;
foreach my $sel (@selected) {
if ( $sel eq $opt ) { $got_opt = 1 }
}
if ($got_opt) {
$detail .= "\n \u$desc $req "; } else { $detail .= "\n \u$desc $req "; } $req = ''; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} |