# 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 ? " * required" : ''; my @members = @{$members}; my @nonmembers = @{$nonmembers}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n
$title\n ? "; } else { $detail .= "\n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $req
); return $detail; } sub hidden(@) { my $hidden = $_[1]; my %hidden = %{$hidden}; my $detail = "\n\n"; foreach my $key ( sort keys %hidden ) { if ( $hidden{$key} ) { $detail .= "\n"; } } $detail .= "\n\n"; return $detail; } sub checkbox(@) { my $title = $_[1]; my $name = $_[2]; my $value = $_[3]; my $doc = $_[4]; my $override = $_[5]; my $tab = $_[6]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n\n
$title\n ? "; } else { $detail .= "\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()]}
); return $detail; } sub checkbox_override(@) { my $title = $_[1]; my $name = $_[2]; my $value = $_[3]; my $doc = $_[4]; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n\n
); if ($value) { $detail .= "\n"; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $title\n ? "; } else { $detail .= "\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
); return $detail; } sub checkbox_left(@) { my $title = $_[1]; my $name = $_[2]; my $value = $_[3]; my $override = $_[4]; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $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
); return $detail; } sub checkbox_list(@) { my $title = $_[1]; my $name = $_[2]; my $list = $_[3]; my @list = @{$list}; my $selected = $_[4]; my $req = $_[5]; my $doc = $_[6]; my $override = $_[7]; my $tab = $_[8]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; $req = $req ? ' * required' : ''; my @selected = @{$selected}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n
$title $req\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()]}
); return $detail; } sub hash_hash_display(@) { my $title = $_[1]; my $hash = $_[2]; my %hash = %{$hash}; my $max_size = $_[3]; my $doc = $_[4]; my $display = $title; $display =~ s/://g; $display =~ s/s$//g; if ( $display =~ /^use$/i ) { $display = "template" } my $size = 0; foreach my $item (keys %hash) { $size += scalar keys %{ $hash{$item} }; } $size = $max_size if $size > $max_size; $size = 1 if $size < 1; my @rows = (); if ( not %hash ) { push @rows, "\n-- no \L$display" . "s --"; } else { foreach my $item1 (sort { lc($a) cmp lc($b) } keys %hash) { foreach my $item2 (sort { lc($a) cmp lc($b) } keys %{ $hash{$item1} }) { push @rows, "\n$item1$item2"; } } } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n"; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title ?   @rows
); return $detail; } # write-only list display; no user selection sub list_box_display(@) { my $title = $_[1]; my $name = $_[2]; my $list = $_[3]; my @list = @{$list}; my $max_size = $_[4]; my $doc = $_[5]; my $display = $title; $display =~ s/://g; $display =~ s/s$//g; if ( $display =~ /^use$/i ) { $display = "template" } my $size = (@list > $max_size) ? $max_size : (scalar @list); $size = 1 if $size < 1; my @options = (); if ( not defined $list[0] ) { push @options, "\n"; } else { @list = sort { lc($a) cmp lc($b) } @list; foreach my $item (@list) { push @options, "\n"; } } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n"; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title ?  
); return $detail; } sub list_box_multiple(@) { my $title = $_[1]; my $name = $_[2]; my $list = $_[3]; my @list = @{$list}; my $selected = $_[4]; my $req = $_[5]; my $doc = $_[6]; my $override = $_[7]; my $tab = $_[8]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; $req = $req ? " * required" : ''; my @selected = @{$selected}; my $display = $title; $display =~ s/://g; if ( $display =~ /^use$/i ) { $display = "template" } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n"; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title ?  
$req
); return $detail; } sub list_box(@) { my $title = $_[1]; my $name = $_[2]; my $list = $_[3]; my $selected = $_[4]; my $req = $_[5]; my $doc = $_[6]; my $override = $_[7]; my $tab = $_[8]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; $req = $req ? ' * required' : ''; my @list = @{$list}; my $display = $title; $display =~ s/://g; if ( $display =~ /^use$/i ) { $display = "template" } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n"; } else { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title\n ? \n\n  $req
); return $detail; } sub list_box_submit(@) { my $title = $_[1]; my $name = $_[2]; my $list = $_[3]; my $selected = $_[4]; my $req = $_[5]; my $doc = $_[6]; my $tab = $_[7]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; $req = $req ? ' * required' : ''; my @list = @{$list}; my $display = $title; $display =~ s/://g; if ( $display =~ /^use$/i ) { $display = "template" } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n
$title\n ? "; } else { $detail .= "\n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $req
); return $detail; } sub command_test() { my $results = $_[1]; my $host = $_[2]; my $args = $_[3]; my $service_desc = $_[4]; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $button_class = $disable_test_buttons ? 'submitbutton_disabled' : 'submitbutton'; my $test_enabled = $disable_test_buttons ? 'disabled' : ''; unless ($results) { $results = "$args
" } $service_desc = '' if not defined $service_desc; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
Test:
Host: 
Arguments: 
Service description: 
 
$results  
); return $detail; } sub test_service_check() { my $results = $_[1]; my $host = $_[2]; my $args = $_[3]; my $tab = $_[4]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $button_class = $disable_test_buttons ? 'submitbutton_disabled' : 'submitbutton'; my $test_enabled = $disable_test_buttons ? 'disabled' : ''; unless ($results) { $results = defined($args) ? "$args
" : '
'; } $host = '' if not defined $host; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
Test: Host:    
$results  
); return $detail; } sub command_select() { my $list = $_[1]; my $selected = $_[2]; my $tab = $_[3]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my @list = @{$list}; my %selected = %{$selected}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $temp = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Install plugin  
New command from an existing plugin  
Clone a command:
); return $detail; } sub display_hidden(@) { my $title = $_[1]; my $name = $_[2]; my $value = $_[3]; my $doc = $_[4]; my $parent = $_[5]; if ($parent) { $form_class = 'parent' } my $display = $value; $display = '' if not defined $display; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($name) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ($doc) { $detail .= "\n
$title\n ? "; } else { $detail .= "\n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $display
); return $detail; } sub text_box(@) { my $title = $_[1]; my $name = $_[2]; my $value = $_[3]; my $size = $_[4]; my $req = $_[5]; my $doc = $_[6]; my $override = $_[7]; my $tab = $_[8]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; if ( !$size ) { $size = 50 } $req = $req ? ' * required' : ''; if (defined $value) { $value =~ s//>/g; $value =~ s/\"/"/g; } else { $value = ''; } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n
$title\n ? "; } else { $detail .= "\n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $req
); return $detail; } sub password_box(@) { my $title = $_[1]; my $name = $_[2]; my $size = $_[3]; my $req = $_[4]; if ( !$size ) { $size = 50 } $req = $req ? ' * required' : ''; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title   $req
); return $detail; } sub text_area(@) { my $title = $_[1]; my $name = $_[2]; my $value = $_[3]; my $rows = $_[4]; my $size = $_[5]; my $req = $_[6]; my $doc = $_[7]; my $override = $_[8]; my $tab = $_[9]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; if ( !$rows ) { $rows = 3 } if ( !$size ) { $size = 40 } my $title_width = '25%'; my $text_width = ''; $value = '' if not defined $value; if ($size eq '100%') { $size = 40; $title_width = '2%'; $text_width = 'style="width: 99%;"'; } $req = $req ? ' * required' : ''; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n"; } elsif (! $text_width) { $detail .= "\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title\n ? \n $req
); return $detail; } sub stalking_options(@) { my $selected = $_[1]; my $req = $_[2]; my $doc = $_[3]; my $override = $_[4]; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; $req = $req ? ' * required' : ''; my @selected = @{$selected}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n
Stalking options: $req\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()]}
); return $detail; } sub notification_options(@) { my $obj = $_[1]; my $name = $_[2]; my $selected = $_[3]; my $req = $_[4]; my $nagios_ver = $_[5]; my $doc = $_[6]; my $override = $_[7]; my $tab = $_[8]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; $req = $req ? ' * required' : ''; my @selected = @{$selected}; my $title = $name; $title =~ s/_/ /g; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n
\u$title:\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()]}
); return $detail; } sub failure_criteria(@) { my $name = $_[1]; my $selected = $_[2]; my $req = $_[3]; my $type = $_[4]; my $doc = $_[5]; my $override = $_[6]; my $tab = $_[7]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; $req = $req ? ' * required' : ''; $type = '' if not defined $type; my @selected = @{$selected}; my $title = $name; $title =~ s/_/ /g; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($override) { if ( $override eq 'checked' ) { $detail .= "\n"; } else { $detail .= "\n"; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($doc) { $detail .= "\n
\u$title:\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()]}
); return $detail; } sub submit_button(@) { my $name = $_[1]; my $value = $_[2]; my $tab = $_[3]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; return qq(@{[&$Instrument::show_trace_as_html_comment()]}
); } sub form_top(@) { my $caption = $_[1]; my $onsubmit_action = $_[2]; my $ez = $_[3]; my $boxwidth = $_[4] || '90%'; my $align = 'left'; if ( defined($ez) && $ez eq '1' ) { $cgi_exe = 'monarch_ez.cgi' } if ( defined($ez) && $ez eq '2' ) { $cgi_exe = 'monarch_auto.cgi' } $onsubmit_action = '' if not defined $onsubmit_action; return qq(@{[&$Instrument::show_trace_as_html_comment()]}
); } sub form_top_file(@) { my $caption = $_[1]; my $onsubmit_action = $_[2]; my $ez = $_[3]; my $align = 'left'; # next line commented out because now the caller provides the ' onsubmit=' along with the action #if ($onsubmit_action) { $onsubmit_action = qq(@{[&$Instrument::show_trace_as_html_comment()]} onsubmit="$onsubmit_action") } if ($ez) { $cgi_exe = 'monarch_ez.cgi' } return qq(@{[&$Instrument::show_trace_as_html_comment()]}
 $caption
); } sub form_errors(@) { my $errors = $_[1]; my $errstr = join('
', @$errors); return qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } sub profile_import_status(@) { my @messages = @{ $_[1] }; my $status_table = qq(@{[&$Instrument::show_trace_as_html_comment()]}
 $caption
Error(s):   Please correct the following:
$errstr
); foreach my $message (@messages) { if ( $message =~ /^Importing/ ) { $status_table .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $message =~ /^Performance/ ) { $status_table .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $message =~ /^-----/ ) { $status_table .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $message =~ /^(.*\S+)\s+(\d+)\s*read,\s*(\d+)\s*added,\s*(\d+)\s*updated\s*\(overwrite existing = (Y|N)\S+\)/ ) { $status_table .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $message =~ /^(.*\S+)\s+(\d+)\s*read,\s*(\d+)\s*added,\s*(\d+)\s*updated,\s*(\d+)\s*error[s]?\s*\(overwrite existing = (Y|N)\S+\)/ ) { $status_table .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $message =~ /error|try again/i ) { $status_table .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { $status_table .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } } $status_table .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$message
  Read Added Updated Overwrite Errors
$message

$1 $2 $3 $4 $5
$1 $2 $3 $4 $6 $5
$message
$message
); return qq(@{[&$Instrument::show_trace_as_html_comment()]}
Import Status:
$status_table
); } sub form_message(@) { my $title = $_[1]; my $message = $_[2]; my $class = $_[3]; my $color_errors = $_[4]; my $simulate_tabs = $_[5]; my $title_width = $_[6] || '10%'; my @message = @{$message}; # FIX LATER: make $color_errors a pattern specified by the caller, not a binary flag if ($color_errors) { foreach (@message) { s{.*}{$&} if /Error:/i; } } if ($simulate_tabs) { foreach (@message) { s/^(\t+)/' ' x (length($1) * 8)/e; } } my $msg = join( '
', @message ); return qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title   $msg
); } sub form_image(@) { my $image_file = $_[1]; my $image_x = $_[2]; my $image_y = $_[3]; my $class = $_[4]; return qq(@{[&$Instrument::show_trace_as_html_comment()]}
); } sub form_doc(@) { my $message = $_[1]; return qq(@{[&$Instrument::show_trace_as_html_comment()]}
$message
); } sub form_status(@) { my $title = $_[1]; my $message = $_[2]; my $class = $_[3]; return qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title $message
); } sub form_bottom_buttons(@) { my $self_discard = shift; my @args = @_; my $tab = 0; if ( ref( $args[$#args] ) ne 'HASH' ) { $tab = pop(@args); } my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $class; my $disabled; my $html = qq(@{[&$Instrument::show_trace_as_html_comment()]}
); foreach my $button (@args) { if (defined $button->{disabled}) { $class = 'submitbutton_disabled'; $disabled = 'disabled'; } else { $class = 'submitbutton'; $disabled = ''; } $html .= qq( {name} value="$button->{value}" onclick="this.form.clicked=this.name" $tabindex> ); } unindent($html); my $html_end = qq(@{[&$Instrument::show_trace_as_html_comment()]}
); unindent($html_end); return $html . $html_end; } sub form_file(@) { my $tab = $_[1]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; return qq(@{[&$Instrument::show_trace_as_html_comment()]}
Upload file:
); } sub table_download_links(@) { my $doc_folder = $_[1]; my @source = @{ $_[2] }; my $server = $_[3]; my $line_url; my $plain_url; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}

 Files in $doc_folder


\n); foreach my $name (@source) { if ( $name =~ /tar$/ ) { $line_url = qq($name); $plain_url = ''; } else { $line_url = qq($name); $plain_url = qq((plain)); } $detail .= qq(\n\n\n); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$line_url   $plain_url\n
\n); return $detail; } sub success(@) { my $caption = $_[1]; my $message = $_[2]; my $task = $_[3]; my $hidden = $_[4]; my %hidden = %{$hidden}; my $hiddenstr = ''; foreach my $name ( keys %hidden ) { unless ( $name =~ /HASH/ ) { $hiddenstr .= "\n"; } } return qq(@{[&$Instrument::show_trace_as_html_comment()]}
$caption
$message
$hiddenstr   
); } sub are_you_sure(@) { my $caption = $_[1]; my $message = $_[2]; my $task = $_[3]; my $hidden = $_[4]; my $bail = $_[5]; if ( $_[6] ) { $cgi_exe = 'monarch_auto.cgi' } my %hidden = %{$hidden}; my $hiddenstr = ''; unless ($bail) { $bail = 'task' } foreach my $name ( keys %hidden ) { unless ( $name =~ /HASH/ ) { $hiddenstr .= "\n"; } } return qq(@{[&$Instrument::show_trace_as_html_comment()]}
$caption
$message
$hiddenstr  
); } sub display($) { my $name = shift; my @words = split( /_/, $name ); my $display = undef; foreach my $word (@words) { $display .= "\u$word " } chop $display; return $display; } sub frame(@) { my $session_id = $_[1]; my $top_menu = $_[2]; my $is_portal = $_[3]; my $ez = $_[4]; my $cols = 'cols="25%,75%"'; if ( $top_menu eq 'time_periods' ) { $cols = 'cols="18%,82%"'; } $ez = '' if not defined $ez; if ($is_portal) { # FIX MINOR: Drop references to gw.jquery.autoheight.js now that we fixed the problem via other means? return qq(@{[&$Instrument::show_trace_as_html_comment()]} Monarch ); } else { return qq(@{[&$Instrument::show_trace_as_html_comment()]} Monarch ); } } sub top_frame(@) { my $session_id = $_[1]; my $top_menu = $_[2]; my @menus = @{ $_[3] }; my $auth_level = $_[4]; my $ver = $_[5]; my $enable_ez = $_[6]; my $ez = $_[7]; my %auth_add = %{ $_[8] }; my $login = $_[9]; my $title = "GroundWork Monitor Architect"; my $class = 'submenu'; my $links = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $colspan = 2; my $menuspan = 2; my $width = 70; my $m = 0; my $first_menu = $menus[0]; foreach (@menus) { $m++ } if ($m) { $width = $width / $m } $width = sprintf( "%.0f", $width ); my $javascript = ''; my $ez_main = ''; my %selected = (); if ($ez) { $selected{'ez'} = 'selected'; $javascript = qq(parent.monarch_left.location='$monarch_cgi/monarch_tree.cgi?CGISESSID=$session_id&top_menu=$top_menu&ez=1';); } else { $selected{'main'} = 'selected'; $javascript = qq(parent.monarch_left.location='$monarch_cgi/monarch_tree.cgi?CGISESSID=$session_id&top_menu=$top_menu';); } if ($login) { $javascript = ''; } # don't want the page to load twice if new login if ( $enable_ez && ( $auth_add{'ez'} || $auth_add{'ez_main'} || $auth_add{'main_ez'} ) ) { $ez_main = qq(@{[&$Instrument::show_trace_as_html_comment()]}
); } foreach my $menu (@menus) { $colspan++; $menuspan++; my $display = "\u$menu"; if ( $menu =~ /_/ ) { $display = undef; my @disp = split( /_/, $menu ); foreach (@disp) { $display .= "\u$_ " } chop $display; } $class = 'top_menu_menu'; if ( $menu eq 'help' ) { $links .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $display); } else { $links .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $display     ); } } $links .= "\n"; $width = "$width" . "%"; my $logout = ''; if ( $auth_level == 2 ) { $colspan--; $logout = qq(@{[&$Instrument::show_trace_as_html_comment()]} Logout ); } my $detail = qq( @{[&$Instrument::show_trace_as_html_comment()]} Monarch Menus
$logout
   $title $ver
$ez_main $links
); return $detail; } sub header(@) { my $title = $_[1]; my $session_id = $_[2]; my $top_menu = $_[3]; my $refresh_url = $_[4]; my $refresh_left = $_[5]; my $ez = $_[6]; my $load_event = $_[7]; if ( defined($ez) && $ez eq '1' ) { $cgi_exe = 'monarch_ez.cgi' } if ( defined($ez) && $ez eq '2' ) { $cgi_exe = 'monarch_auto.cgi' } my $meta = qq(); my $javascript = ''; my $now = time; if ($refresh_url) { # This meta-refresh used to be our standard mechanism for triggering a redirect after # displaying the current page, but it no longer works because we now insist on a referrer. # $meta = qq(); $javascript = "onload=\"location='$refresh_url';\""; } elsif ($refresh_left) { my $ezstr = $ez ? '&ez=1' : ''; $top_menu =~ s/\s/_/g; # refresh left time Periods to time_periods $top_menu = lc($top_menu); $javascript = "onload=\"parent.monarch_left.location='$monarch_cgi/monarch_tree.cgi?CGISESSID=$session_id&nocache=$now&refresh_left=1&top_menu=$top_menu$ezstr';\""; } elsif ( defined($load_event) ) { if ( $load_event eq '1' ) { $javascript = "onload=\"scan_host();\""; } elsif ( $load_event eq '2' ) { $javascript = "onload=\"got_warning = false; got_error = false; check_status();\""; } } return qq( @{[&$Instrument::show_trace_as_html_comment()]} $title $meta ); } # FIX MAJOR: make sure the table tags used here are always matched by corresponding tags earlier sub footer(@) { my $debug = $_[1]; $debug = '' if not defined $debug; return qq(@{[&$Instrument::show_trace_as_html_comment()]} $debug $extend_page ); } ############################################################################ # Special Forms # sub access_checkbox_list(@) { my $title = $_[1]; my $name = $_[2]; my @list = @{ $_[3] }; my @selected = @{ $_[4] }; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title ); 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()]}
        
); return $detail; } sub access_settings_ez(@) { my %view = %{ $_[1] }; if ( $view{'enable_ez'} ) { $view{'enable_ez'} = 'checked' } if ( $view{'ez_main'} ) { $view{'ez_main_checked'} = 'checked' } if ( $view{'main_ez'} ) { $view{'main_ez_checked'} = 'checked' } if ( $view{'ez'} ) { $view{'ez_checked'} = 'checked' } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
Enable EZ:  Enable
View option:  EZ-Main
 Main-EZ
 EZ
); return $detail; } sub access_list(@) { my $title = $_[1]; my $assets = $_[2]; my @assets = @{$assets}; my $assets_selected = $_[3]; my %assets_selected = %{$assets_selected}; my $type = $_[4]; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); foreach my $asset (@assets) { my %selected = {}; my @perms = split( /,/, $assets_selected{$asset} ); foreach (@perms) { $selected{$_} = " checked" } my $title = $asset; $title =~ s/_/ /g; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title Add Modify Delete  
\u$title:  
        
); return $detail; } sub add_file() { my $name = $_[1]; my $type = $_[2]; my $path = $_[3]; my $files = $_[4]; my $file = $_[5]; my $req = $_[6]; my $doc = $_[7]; $req = $req ? ' * required' : ''; my @files = @{$files}; my $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
File: $req  
 
File: $req
  Path: $req
 
 
); return $detail; } sub external_list(@) { my $session_id = $_[1]; my $name = $_[2]; my $externals = $_[3]; my $list = $_[4]; my $type = $_[5]; my $service_id = $_[6]; # not used; drop this, here and in all callers? my $service_name = $_[7]; # not used; drop this, here and in all callers? my $modified = $_[8]; my $obj_view = 'host_externals'; if ( $type eq 'service' ) { $obj_view = 'service_externals' } my %externals = %{$externals}; my @list = @{$list}; my $detail = undef; ( my $short_type = $type ) =~ s/_name//; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $row = 1; foreach my $external ( sort keys %externals ) { my $class = undef; my $removebutton = undef; if ( $row == 1 ) { $class = 'row_lt'; $removebutton = 'removebutton_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $removebutton = 'removebutton_dk'; $row = 1; } if ( $external =~ /HASH/ ) { next } my $lexternal = $external; $lexternal =~ s/\s/+/g; if ( $type eq 'service_name' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } my $modify_state = !$modified ? '' : $modified->{$external} ? 'locally modified' : 'unmodified from original'; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } my $size = ( scalar @list ) + 1; $size = 20 if $size > 20; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
\u$short_type Externals:
$external
$modify_state
  
); return $detail; } sub external_xml_list(@) { my %externals = %{ $_[1] }; my @externals = @{ $_[2] }; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); foreach my $ext ( sort keys %externals ) { if ( $ext =~ /^HASH/ ) { next } my $checked = undef; if ( $externals{$ext}{'enable'} eq 'ON' ) { $checked = 'checked' } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ( $externals{$ext}{'description'} ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ( $externals{$ext}{'service_name'} ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ( $externals{$ext}{'command'} ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); foreach my $param ( sort keys %{ $externals{$ext}{'command'} } ) { if ( $param eq 'name' ) { next } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ( $externals{$ext}{'command'}{$param}{'description'} ) { $detail .= "\n\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$ext Enabled:
  Enabled: $externals{$ext}{'description'}
  $externals{$ext}{'service_name'}
  Command: $externals{$ext}{'command'}{'name'}
    Param: $param\n ? "; } else { $detail .= "\n 
  
); return $detail; } sub service_list(@) { my $session_id = $_[1]; my $name = $_[2]; my $services = $_[3]; my $list = $_[4]; my $selected = $_[5]; my %services = %{$services}; my @list = @{$list}; my $now = time; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
Service Name
); my $row = 1; use URI::Escape; $name = uri_escape($name); foreach my $service ( sort keys %services ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } if ( $service =~ /HASH/ ) { next } my $display = $service; $display =~ s/\+/ /g; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$display · details   remove service assignment
  
); return $detail; } sub service_select(@) { my $services = $_[1]; my $selected = $_[2]; my $tab = $_[3]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %services = %{$services}; my %selected = %{$selected}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $row = 1; foreach my $service ( sort keys %services ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } if ( $service =~ /HASH/ ) { next } my %checked = ( add => '', edit => '', discard => '' ); if ( $selected{$service} eq 'add' ) { $checked{'add'} = 'checked'; } elsif ( $selected{$service} eq 'edit' ) { $checked{'edit'} = 'checked'; } else { $checked{'discard'} = 'checked'; } my $title = $service; my $extinfo = defined( $services{$service}{'extinfo'} ) ? $services{$service}{'extinfo'} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Include/Modify/Discard Service Name Template Extended Info
$title $services{$service}{'template'} $extinfo
Check command: $services{$service}{'command'}
 
); return $detail; } sub profile_list(@) { my $session_id = $_[1]; my $host = $_[2]; my $profiles = $_[3]; my @profiles = @{$profiles}; my $now = time; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
Service Profiles:
); my $row = 1; if ( $profiles[0] ) { foreach my $profile (@profiles) { my $class = undef; my $removebutton = undef; if ( $row == 1 ) { $class = 'row_lt'; $removebutton = 'removebutton_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $removebutton = 'removebutton_dk'; $row = 1; } my $display = $profile; $profile = uri_escape($profile); $display =~ s/\+/ /g; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$display
None selected  
 
); return $detail; } sub add_service_profile(@) { my $list = $_[1]; my $tab = $_[2]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my @list = @{$list}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
Select service profile:     
); return $detail; } sub add_service(@) { my $list = $_[1]; my $tab = $_[2]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my @list = @{$list}; my $size = ( scalar @list ) + 1; $size = 20 if $size > 20; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
Select other service(s):     
); return $detail; } sub manage_escalation_tree(@) { my $session_id = $_[1]; my $view = $_[2]; my $type = $_[3]; my $name = $_[4]; my $tree_id = $_[5]; my $ids = $_[6]; my $members = $_[7]; my $nonmembers = $_[8]; my $contact_groups = $_[9]; my $first_notify = $_[10]; my $tab = $_[11]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my @members = @{$members}; my @nonmembers = @{$nonmembers}; @nonmembers = sort { lc($a) cmp lc($b) } @nonmembers; my %ids = %{$ids}; my %contact_groups = %{$contact_groups}; my %first_notify = %{$first_notify}; my $errstr = undef; my $now = time; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
); foreach my $escalation (@members) { my $sname = $name; $sname =~ s/\s/+/g; my $fn = $first_notify{ $ids{$escalation} }; $fn =~ s/-zero-/0/; my $contactgroups = $contact_groups{ $ids{$escalation} } || 'ERROR: none assigned yet'; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Escalations First Notify Contact Groups  
$escalation $fn $contactgroups
Potential escalations in this escalation tree:   
); } sub host_top(@) { my $name = $_[1]; my $session_id = $_[2]; my $obj_view = $_[3]; my $externals = $_[4]; my $selected = $_[5]; my $form_service = $_[6]; my $boxwidth = ($obj_view eq 'service_check' || $obj_view =~ /_external_detail/) ? '100%' : '90%'; my $now = time; my $colspan = 1; my @menus = (); if ($form_service) { @menus = ( 'service_detail', 'service_check', 'service_dependencies' ); if ($externals) { push @menus, 'service_externals'; } if ( $obj_view eq 'service_external_detail' ) { push @menus, 'service_external_detail'; } } else { push @menus, 'host_detail'; if ( $obj_view =~ /service_detail|service_dependencies|service_externals|service_check/ ) { push( @menus, ( 'services', 'service_detail', 'service_check', 'service_dependencies' ) ); if ($externals) { push @menus, 'service_externals'; } } elsif ( $obj_view eq 'service_external_detail' ) { push( @menus, ( 'services', 'service_detail', 'service_externals', 'service_external_detail' ) ); } elsif ( $obj_view eq 'host_external_detail' ) { push( @menus, ( 'host_profile', 'service_profiles', 'services', 'host_externals', 'host_external_detail' ) ); } else { push( @menus, ( 'host_profile', 'service_profiles', 'parents', 'hostgroups', 'escalation_trees', 'services' ) ); if ($externals) { push @menus, 'host_externals'; } } } $colspan = scalar (@menus); my $width = 100 / $colspan . '%'; my $title = 'Manage Host'; if ($form_service) { $title .= ' Service' } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ( $obj_view =~ /profile|parents|hostgroups|host_detail|service_detail/ ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
); } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub host_profile_top(@) { my $name = $_[1]; my $session_id = $_[2]; my $obj_view = $_[3]; my $externals = $_[4]; my $objs = $_[5]; my %objs = (); my $urlstr = ''; my $now = time; if ($objs) { %objs = %{$objs}; foreach my $key ( keys %objs ) { if ( $objs{$key} ) { $urlstr .= '&' . $key . '=' . $objs{$key} } } } my $colspan = 9; my @menus = ( 'host_detail', 'parents', 'hostgroups', 'escalation_trees' ); if ($externals) { push( @menus, ( 'externals', 'service_profiles', 'assign_hosts', 'assign_hostgroups', 'apply' ) ); $colspan = 10; } else { push( @menus, ( 'service_profiles', 'assign_hosts', 'assign_hostgroups', 'apply' ) ); } my $width = 100 / $colspan . '%'; my $detail = ''; if ( $obj_view =~ /parents|host|externals|service_profiles/ ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
 $title
); my $class = undef; my $bclass = undef; my @lmenus = @menus; my $last_menu = pop @lmenus; my $first_menu = $menus[0]; foreach my $view (@menus) { if ( $obj_view eq $view ) { $class = 'top_menu_selected'; $bclass = 'topbuttonselected'; if ( $view eq $last_menu ) { $class = 'top_menu_selected_right'; } if ( $view eq $first_menu ) { $class = 'top_menu_selected_left'; } } else { $class = 'top_menu_menu'; $bclass = 'topbutton'; if ( $view eq $last_menu ) { $class = 'top_menu_right'; } } my $menu = ''; my @menu = split( /_/, $view ); foreach (@menu) { $menu .= "\u$_ " } chop $menu; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
 
Host name:   $name
); return $detail; } sub apply_select() { my $view = $_[1]; my $selected = $_[2]; my $nagios_ver = $_[3]; my $externals = $_[4]; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %selected = %{$selected}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub service_template_top(@) { my $name = $_[1]; my $session_id = $_[2]; my $obj_view = $_[3]; my $objs = $_[4]; my $selected = $_[5]; my $boxwidth = ($obj_view eq 'service_check') ? '100%' : '90%'; my %objs = (); my $urlstr = ''; my $now = time; $selected = '' if not defined $selected; if ($objs) { %objs = %{$objs}; foreach my $key ( keys %objs ) { if ( $objs{$key} ) { $urlstr .= '&' . $key . '=' . $objs{$key} } } } my $colspan = 3; $urlstr =~ s/ /+/g; my @menus = ( 'service_detail', 'service_check' ); my $width = 100 / $colspan . '%'; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
 Host Profile
); my $class = undef; my @lmenus = @menus; my $last_menu = pop @lmenus; my $first_menu = $menus[0]; foreach my $view (@menus) { if ( $obj_view eq $view ) { $class = 'top_menu_selected'; if ( $view eq $last_menu ) { $class = 'top_menu_selected_right'; } if ( $view eq $first_menu ) { $class = 'top_menu_selected_left'; } } else { $class = 'top_menu_menu'; if ( $view eq $last_menu ) { $class = 'top_menu_right'; } } my $menu = $view; $menu = undef; my @menu = split( /_/, $view ); foreach (@menu) { $menu .= "\u$_ " } my $cname = $name; $cname =~ s/\s/+/g; chop $menu; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
\u$menu
 
Host profile name: $name
); unless ( $view =~ /service$|manage_host|direct_profiles/ ) { my $hostgroups_select = defined( $selected{'hostgroups_select'} ) ? $selected{'hostgroups_select'} : ''; my $hosts_select = defined( $selected{'hosts_select'} ) ? $selected{'hosts_select'} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ( $view =~ /host_profile|manage_host/ ) { my $apply_parents = $selected{'apply_parents'} || ''; my $apply_hostgroups = $selected{'apply_hostgroups'} || ''; my $apply_escalations = $selected{'apply_escalations'} || ''; my $apply_contactgroups = $selected{'apply_contactgroups'} || ''; my $apply_variables = $selected{'apply_variables'} || ''; my $apply_detail = $selected{'apply_detail'} || ''; my $apply_host_externals = $selected{'apply_host_externals'} || ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ( $nagios_ver =~ /^[23]\.x$/ ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ( $nagios_ver eq '3.x' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($externals) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ( $view eq 'service' ) { my $apply_check = $selected{'apply_check'} || ''; my $apply_contact_service = $selected{'apply_contact_service'} || ''; my $apply_variables = $selected{'apply_variables'} || ''; my $apply_extinfo_service = $selected{'apply_extinfo_service'} || ''; my $apply_escalation_service = $selected{'apply_escalation_service'} || ''; my $apply_dependencies = $selected{'apply_dependencies'} || ''; my $apply_service_externals = $selected{'apply_service_externals'} || ''; if ( defined( $selected{'apply_services'} ) && $selected{'apply_services'} eq 'replace' ) { $selected{'replace'} = 'checked'; $selected{'merge'} = ''; } else { $selected{'merge'} = 'checked'; $selected{'replace'} = ''; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ( $nagios_ver eq '3.x' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ($externals) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } unless ( $view eq 'service' ) { if ( defined( $selected{'apply_services'} ) && $selected{'apply_services'} eq 'replace' ) { $selected{'replace'} = 'checked'; $selected{'merge'} = ''; } else { $selected{'merge'} = 'checked'; $selected{'replace'} = ''; } # FIX MINOR: Should this $extra_text be unconditional here? Check all places # where apply_select() is called that invoke this branch of the logic. my $extra_text = ($view =~ /manage_host|direct_profiles/) ? ' service profiles and' : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Hostgroups action:  Apply to hostgroups.
Hosts action:  Apply to hosts.

Host properties action(s):  Apply parents to hosts.
   Apply hostgroups to hosts.
   Apply escalations to hosts.
   Apply contact groups to hosts.
   Apply custom object variables to hosts.
   Apply detail to hosts.
   Apply host externals.

Service properties action(s):  Apply service check.
   Apply contact groups.
   Apply custom object variables.
   Apply service extended info.
   Apply service escalation.
   Apply dependencies.
   Apply service externals.

Host services action:  Replace existing host service properties (force inheritance).
   Merge with existing host service properties (preserve overrides).
Services action:  Replace existing$extra_text services.
   Merge with existing$extra_text services.
); return $detail; } sub service_top(@) { my $name = $_[1]; my $session_id = $_[2]; my $obj_view = $_[3]; my $objs = $_[4]; my $externals = $_[5]; my $selected = $_[6]; my $host_id = $_[7]; my $boxwidth = ($obj_view eq 'service_check') ? '100%' : '90%'; my %objs = (); my $urlstr = ''; my $now = time; if ($objs) { %objs = %{$objs}; foreach my $key ( keys %objs ) { if ( $objs{$key} ) { $urlstr .= '&' . $key . '=' . $objs{$key} } } } my $colspan = 5; $urlstr =~ s/ /+/g; my @menus = ( 'service_detail', 'service_check', 'service_dependencies' ); unless ($host_id) { push @menus, 'service_profiles' } if ($externals) { push @menus, 'service_externals'; $colspan = 6; } unless ($host_id) { push @menus, 'apply_hosts' } $host_id = '' if not defined $host_id; $selected = '' if not defined $selected; my $width = 100 / $colspan . '%'; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
 Manage Service Template
); my $class = undef; my @lmenus = @menus; my $last_menu = pop @lmenus; my $first_menu = $menus[0]; foreach my $view (@menus) { if ( $obj_view eq $view ) { $class = 'top_menu_selected'; if ( $view eq $last_menu ) { $class = 'top_menu_selected_right'; } if ( $view eq $first_menu ) { $class = 'top_menu_selected_left'; } } else { $class = 'top_menu_menu'; if ( $view eq $last_menu ) { $class = 'top_menu_right'; } } my $menu = $view; $menu = undef; my @menu = split( /_/, $view ); foreach (@menu) { $menu .= "\u$_ " } chop $menu; my $ename = uri_escape($name); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
\u$menu  
 
); if ( $obj_view =~ /service_detail|service_profiles/ ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Service template name:   $name
); return $detail; } sub service_profile_top(@) { my $name = $_[1]; my $session_id = $_[2]; my $obj_view = $_[3]; my $objs = $_[4]; my $selected = $_[5]; my %objs = (); my $urlstr = ''; my $now = time; $selected = '' if not defined $selected; if ($objs) { %objs = %{$objs}; foreach my $key ( keys %objs ) { if ( $objs{$key} ) { $urlstr .= '&' . $key . '=' . $objs{$key} } } } my $colspan = 5; $urlstr =~ s/ /+/g; my @menus = ( 'services', 'assign_hosts', 'assign_hostgroups', 'host_profiles', 'apply' ); my $width = 100 / $colspan . '%'; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
 Manage Service
); my $class = undef; my @lmenus = @menus; my $last_menu = pop @lmenus; my $first_menu = $menus[0]; foreach my $view (@menus) { if ( $obj_view eq $view ) { $class = 'top_menu_selected'; if ( $view eq $last_menu ) { $class = 'top_menu_selected_right'; } if ( $view eq $first_menu ) { $class = 'top_menu_selected_left'; } } else { $class = 'top_menu_menu'; if ( $view eq $last_menu ) { $class = 'top_menu_right'; } } my $menu = $view; $menu = undef; my @menu = split( /_/, $view ); foreach (@menu) { $menu .= "\u$_ " } chop $menu; my $ename = $name; $ename = uri_escape($ename); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
\u$menu
 
); if ( $obj_view =~ /service_detail|service_profiles/ ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Service name:   $name
); return $detail; } sub group_top(@) { my $name = $_[1]; my $obj_view = $_[2]; my $now = time; my $colspan = 4; my @menus = ( 'detail', 'hosts', 'sub_groups', 'macros' ); my $width = '25%'; my $title = 'Manage Group'; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
 Service Profile
); my $class = undef; my @lmenus = @menus; my $last_menu = pop @lmenus; my $first_menu = $menus[0]; foreach my $view (@menus) { if ( $obj_view eq $view ) { $class = 'top_menu_selected'; if ( $view eq $last_menu ) { $class = 'top_menu_selected_right'; } if ( $view eq $first_menu ) { $class = 'top_menu_selected_left'; } } else { $class = 'top_menu_menu'; if ( $view eq $last_menu ) { $class = 'top_menu_right'; } } my $menu = $view; $menu = undef; my @menu = split( /_/, $view ); foreach (@menu) { $menu .= "\u$_ " } my $ename = $name; $ename = uri_escape($ename); chop $menu; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
\u$menu
 
); if ( $obj_view =~ /services|assign_hosts|assign_hostgroups|host_profiles/ ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Service profile name:   $name
); return $detail; } sub access_top(@) { my $groupid = $_[1]; my $session_id = $_[2]; my $obj_view = $_[3]; my @menus = @{ $_[4] }; my $urlstr = undef; my $now = time; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
 $title
); if ( $obj_view =~ /detail|hosts/ ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } my $class = undef; my $bclass = undef; my @lmenus = @menus; my $last_menu = pop @lmenus; my $first_menu = $menus[0]; foreach my $view (@menus) { if ( $obj_view eq $view ) { $class = 'top_menu_selected'; $bclass = 'topbuttonselected'; if ( $view eq $last_menu ) { $class = 'top_menu_selected_right'; } if ( $view eq $first_menu ) { $class = 'top_menu_selected_left'; } } else { $class = 'top_menu_menu'; $bclass = 'topbutton'; if ( $view eq $last_menu ) { $class = 'top_menu_right'; } } my $menu = $view; $menu = undef; my @menu = split( /_/, $view ); foreach (@menu) { $menu .= "\u$_ " } chop $menu; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
 
Monarch group name:   $name
); return $detail; } sub escalation_top() { my $name = $_[1]; my $session_id = $_[2]; my $obj_view = $_[3]; my $type = $_[4]; my $nagios_ver = $_[5]; my $colspan = 4; my @menus = ('detail'); if ( $obj_view eq 'assign_contact_groups' ) { push @menus, 'assign_contact_groups'; } else { push( @menus, ( 'assign_hostgroups', 'assign_hosts' ) ); if ( $type eq 'service' ) { if ( $nagios_ver =~ /^[23]\.x$/ ) { push( @menus, ( 'assign_service_groups', 'assign_services' ) ); $colspan = 5; } else { push @menus, 'assign_services'; $colspan = 4; } } } my $width = 100 / $colspan . '%'; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } sub inheritance(@) { my $title = $_[1]; my $body = $_[2]; my $objects = $_[3]; my $tab = $_[4]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %objects = %{$objects}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub group_main(@) { my %group = %{ $_[1] }; my %docs = %{ $_[2] }; my @members = @{ $_[3] }; my @nonmembers = @{ $_[4] }; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %checked = (); $checked{'inactive'} = (defined( $group{'status'} ) && $group{'status'} & 1) ? 'checked' : ''; $checked{'sync_hosts'} = defined( $group{'status'} ) ? (($group{'status'} & 2) ? 'checked' : '') : 'checked'; $checked{'use_hosts'} = $group{'use_hosts'} ? 'checked' : ''; $checked{'inherit_host_active_checks_enabled'} = $group{inherit_host_active_checks_enabled} ? 'checked' : ''; $checked{'inherit_host_passive_checks_enabled'} = $group{inherit_host_passive_checks_enabled} ? 'checked' : ''; $checked{'inherit_service_active_checks_enabled'} = $group{inherit_service_active_checks_enabled} ? 'checked' : ''; $checked{'inherit_service_passive_checks_enabled'} = $group{inherit_service_passive_checks_enabled} ? 'checked' : ''; $checked{'host_active_checks_enabled'} = ( defined( $group{'host_active_checks_enabled'} ) && $group{'host_active_checks_enabled'} eq '1' ) ? 'checked' : ''; $checked{'host_passive_checks_enabled'} = ( defined( $group{'host_passive_checks_enabled'} ) && $group{'host_passive_checks_enabled'} eq '1' ) ? 'checked' : ''; $checked{'service_active_checks_enabled'} = ( defined( $group{'service_active_checks_enabled'} ) && $group{'service_active_checks_enabled'} eq '1' ) ? 'checked' : ''; $checked{'service_passive_checks_enabled'} = ( defined( $group{'service_passive_checks_enabled'} ) && $group{'service_passive_checks_enabled'} eq '1' ) ? 'checked' : ''; my $sync_class = $checked{'inactive'} ? 'top_border' : 'top_border_disabled'; my $sync_disabled = $checked{'inactive'} ? '' : 'disabled'; my $host_active_style = 'visibility: ' . ($checked{'inherit_host_active_checks_enabled'} ? 'hidden' : 'visible'); my $host_passive_style = 'visibility: ' . ($checked{'inherit_host_passive_checks_enabled'} ? 'hidden' : 'visible'); my $service_active_style = 'visibility: ' . ($checked{'inherit_service_active_checks_enabled'} ? 'hidden' : 'visible'); my $service_passive_style = 'visibility: ' . ($checked{'inherit_service_passive_checks_enabled'} ? 'hidden' : 'visible'); my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub group_hosts(@) { my $members = $_[1]; my $nonmembers = $_[2]; my $hostgroup_members = $_[3]; my $hostgroup_nonmembers = $_[4]; my %members = %{$members}; my %nonmembers = %{$nonmembers}; my %hostgroup_members = %{$hostgroup_members}; my %hostgroup_nonmembers = %{$hostgroup_nonmembers}; my $scroll_height = scalar (keys %members) + scalar (keys %hostgroup_members); $scroll_height = 10 if ($scroll_height < 10); $scroll_height = 20 if ($scroll_height > 20); my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub group_children(@) { my $group_hosts = $_[1]; my $order = $_[2]; my $group_child = $_[3]; my $nonmembers = $_[4]; my %group_hosts = %{$group_hosts}; my @order = @{$order}; my %group_child = %{$group_child}; my %nonmembers = %{$nonmembers}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub group_macros(@) { my $macros = $_[1]; my $group_macros = $_[2]; my $label_enabled = $_[3]; my $label = $_[4]; my %macros = %{$macros}; my %group_macros = %{$group_macros}; if ($label_enabled) { $label_enabled = 'checked' } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub macros(@) { my $macros = $_[1]; my $tab = $_[2]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %macros = %{$macros}; my $lasttab = $tab + 1; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } # GWMON-8039 (custom variables) # Internal routine only. sub variable_rows (@) { my $temp_names = $_[0]; my $temp_urls = $_[1]; my $temp_vars = $_[2]; my $obj_vars = $_[3]; my $root_template = $_[4]; my $object = $_[5]; my $default_value = $_[6]; my $color = $_[7]; my $tabindex = $_[8]; my $variables = $object ? $obj_vars : $temp_vars; my @detail = (); my @variables = (); { use locale; @variables = sort keys %$variables; } foreach my $variable (@variables) { my @row = (); push @row, qq( ); ## Note: undef values are not expected/allowed here. If a value exists, it must be defined. my $value = $variables->{$variable}; my $value_disabled = ''; if ( not $root_template ) { my $obj_value = $obj_vars->{$variable}; my $suppress = defined($obj_value) && $obj_value eq 'null' ? 'checked' : ''; push @row, qq( ); if ($object) { my $temp_value = $temp_vars->{$variable}; next if defined($temp_value) && $temp_value ne 'null'; $value = '' if $suppress; push @row, qq( ); } else { next if $value eq 'null'; my $inherit = !defined($obj_value) || $obj_value eq 'null' ? 'checked' : ''; my $inherit_disabled = $suppress ? 'disabled' : ''; if ( defined($obj_value) && $obj_value ne 'null' ) { $default_value->{$variable} = $value; $value = $obj_value; } $value_disabled = 'disabled style="background-color: #CCCCCC;"' if $inherit; push @row, qq( ); } $value_disabled = 'disabled style="background-color: #000000;"' if $suppress; } $value = HTML::Entities::encode($value); push @row, qq( ); if ($object) { push @row, qq( ); } else { push @row, qq( ); } push @row, qq( ); push @detail, @row; $$color = $$color eq 'lt' ? 'dk' : 'lt'; } return join( '', @detail ); } # FIX MINOR: possibly move this routine to either MonarchStorProc.pm or monarch.cgi sub resolve_template_variables(@) { my $session_id = $_[1]; my $hash_chain = $_[2]; # arrayref to a series of template-variable-data hashrefs, ordered from leaf to root of the template chain my %temp_names = (); my %temp_urls = (); my %temp_vars = (); my $now = time; foreach my $hashref ( reverse @$hash_chain ) { my $menu = $hashref->{menu}; my $view = $hashref->{view}; my $type = $hashref->{type}; my $name = $hashref->{name}; my $vars = $hashref->{vars}; foreach my $key ( keys %$vars ) { my $value = $vars->{$key}; if ( $value eq 'null' ) { delete $temp_names{$key}; delete $temp_urls {$key}; delete $temp_vars {$key}; } else { $temp_names{$key} = $name; # FIX MINOR: Use these values for host and service templates, when we implement them: # host template: # menu = 'hosts' # view = 'manage' # type = 'host_templates' # service template: # menu = 'services' # view = 'service_template' # type = 'service_templates' $temp_urls {$key} = "$monarch_cgi/monarch.cgi?CGISESSID=$session_id&update_main=1&nocache=$now&top_menu=$menu&view=$view&obj=$type&task=modify&name=$name"; $temp_vars {$key} = $value; } } } return \%temp_names, \%temp_urls, \%temp_vars; } # Paradigm for call: # %temp_vars contains all applicable higher-level template variables, with all suppressions and overrides between them already resolved # %obj_vars contains all applicable object variables, which may suppress or override template variables sub custom_variables(@) { my $temp_names = $_[1]; my $temp_urls = $_[2]; my $temp_vars = $_[3]; my $obj_vars = $_[4]; my $root_template = $_[5]; my $doc = $_[6]; my $tab = $_[7]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $next_tab = $tab ? "tabindex=\"" . ( $tab + 1 ) . "\"" : ''; my $js_root_template = $root_template ? 1 : 0; my $detail = qq( ); } sub main_cfg_misc(@) { my %misc_vals = %{ $_[1] }; my $misc_name = $_[2]; my $misc_value = $_[3]; my $doc = $_[4]; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
Access Values User Group: $groupid
); my $class = undef; foreach my $view (@menus) { if ( $obj_view eq $view ) { $class = 'top_menu_selected'; } else { $class = 'top_menu_menu'; } my $menu = $view; $menu = undef; my @menu = split( /_/, $view ); foreach (@menu) { $menu .= "\u$_ " } chop $menu; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
\u$menu
); return $detail; } sub escalation_tree(@) { my $ranks = $_[1]; my $templates = $_[2]; my $obj_view = $_[3]; my %ranks = %{$ranks}; my %templates = %{$templates}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub show_list(@) { my $ranks = $_[1]; my $templates = $_[2]; my $obj_view = $_[3]; my %ranks = %{$ranks}; my %templates = %{$templates}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub service_instances(@) { my %instances = %{ $_[1] }; my $doc = $_[2]; my $tab = $_[3]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub toggle_delete() { my $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub wizard_doc(@) { my $title = $_[1]; my $body = $_[2]; my $emphasize = $_[3]; my $title_begin = ''; my $title_end = ''; my $body_begin = ''; my $body_end = ''; if ($emphasize) { $title_begin = ''; $title_end = ''; $body_begin = ''; $body_end = ''; } $title .= '

' if not defined $body; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub process_import(@) { my $import_option = $_[1]; my $escalation = $_[2]; my $nagios_etc = $_[3]; my $abort = $_[4]; my $continue = $_[5]; my $precached_file = $_[6]; my $now = time; $escalation = '' if not defined $escalation; my $input_tags = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my @steps = ('end'); if ( $escalation || $import_option =~ /purge/ ) { push( @steps, ( 'process_service_escalations', 'process_host_escalations' ) ); } push( @steps, ( 'services', 'hosts', 'contacts', 'timeperiods', 'commands', 'stage', 'purge' ) ); my $i = 0; my $array_str = undef; foreach my $step (@steps) { $array_str .= qq(steps[$i]="$step";); $i++; } my $javascript = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } sub import_options(@) { my $import_option = $_[1]; my $precached_file = $_[2]; my $tab = $_[3]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %selected = ( 'update' => '', 'purge_all' => '', 'purge_all_and_import_3x' => '', 'purge_nice' => '', ); if ( !$import_option ) { $import_option = 'update'; } $selected{$import_option} = 'checked'; return qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } sub form_process_hosts(@) { my $unsorted_hosts = $_[1]; my $host_data = $_[2]; my $delimiter = $_[3]; my $fields = $_[4]; my $exists = $_[5]; my $profiles = $_[6]; my $default_profile = $_[7]; my $sort = $_[8]; my $ascdesc = $_[9]; my @unsorted_hosts = @{$unsorted_hosts}; my %host_data = %{$host_data}; my %fields = %{$fields}; my %exists = %{$exists}; my %profiles = %{$profiles}; my @hosts = (); my %checked = (); my %sorted = (); my %sort_order = ( 'exception' => 'asc', 'exists' => 'asc', 'good' => 'asc', 'name' => 'asc', 'alias' => 'asc', 'address' => 'asc', 'os' => 'asc', 'profile' => 'asc', 'other' => 'asc' ); if ($sort) { @{ $sorted{'os'} } = (); @{ $sorted{'address'} } = (); @{ $sorted{'alias'} } = (); @{ $sorted{'profile'} } = (); @{ $sorted{'other'} } = (); @{ $sorted{'exception'} } = (); @{ $sorted{'exists'} } = (); @{ $sorted{'good'} } = (); foreach my $host (@unsorted_hosts) { my @values = split( /$delimiter/, $host_data{$host} ); if ( $delimiter eq 'tab' ) { @values = split( /\t/, $host_data{$host} ); } if ( $sort eq 'os' ) { unless ( $values[ $fields{'os'} ] ) { $values[ $fields{'os'} ] = " --- "; } push @{ $sorted{ $values[ $fields{'os'} ] } }, $values[ $fields{'name'} ]; } elsif ( $sort eq 'address' ) { push @{ $sorted{ $values[ $fields{'address'} ] } }, $values[ $fields{'name'} ]; } elsif ( $sort eq 'alias' ) { unless ( $values[ $fields{'alias'} ] ) { $values[ $fields{'alias'} ] = $values[ $fields{'name'} ]; } push @{ $sorted{ $values[ $fields{'alias'} ] } }, $values[ $fields{'name'} ]; } elsif ( $sort eq 'profile' ) { my $profile = ' --- '; if ( $profiles{ $values[ $fields{'profile'} ] } ) { $profile = $values[ $fields{'profile'} ]; } push @{ $sorted{$profile} }, $values[ $fields{'name'} ]; } elsif ( $sort eq 'other' ) { push @{ $sorted{ $values[ $fields{'other'} ] } }, $values[ $fields{'name'} ]; } elsif ($sort eq 'exception' || $sort eq 'exists' || $sort eq 'good' ) { unless ( $values[ $fields{'alias'} ] ) { $values[ $fields{'alias'} ] = $values[ $fields{'name'} ]; } if ( $values[ $fields{'name'} ] && $values[ $fields{'address'} ] ) { if ( $exists{ $values[ $fields{'name'} ] } ) { push @{ $sorted{'exists'} }, $values[ $fields{'name'} ]; if ( $sort eq 'exists' ) { $checked{$host} = 'checked' } } else { push @{ $sorted{'good'} }, $values[ $fields{'name'} ]; if ( $sort eq 'good' ) { $checked{$host} = 'checked' } } } else { push @{ $sorted{'exception'} }, $values[ $fields{'name'} ]; if ( $sort eq 'exception' ) { $checked{$host} = 'checked' } } } } if ( $sort eq 'exception' || $sort eq 'exists' || $sort eq 'good' ) { my @order = (); if ( $sort eq 'exception' ) { @order = ( 'exception', 'exists', 'good' ); } elsif ( $sort eq 'exists' ) { @order = ( 'exists', 'good', 'exception' ); } else { @order = ( 'good', 'exception', 'exists' ); } foreach my $key (@order) { @{ $sorted{$key} } = sort { lc($a) cmp lc($b) } @{ $sorted{$key} }; push( @hosts, @{ $sorted{$key} } ); } $sort_order{$sort} = 'asc'; } else { if ( $ascdesc eq 'asc' ) { foreach my $key ( sort { lc($a) cmp lc($b) } keys %sorted ) { @{ $sorted{$key} } = sort { lc($a) cmp lc($b) } @{ $sorted{$key} }; push( @hosts, @{ $sorted{$key} } ); } $sort_order{$sort} = 'desc'; } else { foreach my $key ( sort { lc($b) cmp lc($a) } keys %sorted ) { @{ $sorted{$key} } = sort { lc($a) cmp lc($b) } @{ $sorted{$key} }; push( @hosts, @{ $sorted{$key} } ); } $sort_order{$sort} = 'asc'; } } } else { if ( $ascdesc eq 'asc' ) { @hosts = sort { lc($a) cmp lc($b) } @unsorted_hosts; $sort_order{'name'} = 'desc'; } else { @hosts = sort { lc($b) cmp lc($a) } @unsorted_hosts; $sort_order{'name'} = 'asc'; } } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub form_profiles(@) { my $default = $_[1]; my $selected = $_[2]; my $profiles = $_[3]; my $profiles_detail = $_[4]; my $doc = $_[5]; my @profiles = @{$profiles}; my %profiles_detail = %{$profiles_detail}; my %checked = (); my $checked = undef; unless ($selected) { $selected = $default } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } sub get_file_url(@) { my $file = $_[1]; my $line = $_[2]; my $url = ''; # Security check. if ( $file =~ m{^/monarch/workspace/[-a-z0-9._]+$} || $file =~ m{^/profiles/[^./][^/]*$} ) { $url = "$monarch_cgi/monarch_file.cgi?file=$file"; if ($line) { # Position so the desired line is in the middle, not at the top. $line -= 25; $line = 1 if $line <= 0; $url .= "#line$line"; } } return $url; } sub filter_results(@) { my $results = $_[1]; foreach (@$results) { s{.*}{$&} if /Error:|Warning:/; my $file = ''; my $line = 0; if (m{(/usr/local/groundwork/core/monarch/workspace/[-a-z0-9._]+).* [lL]ine (\d+)}) { $file = $1; $line = $2; } elsif (m{(/usr/local/groundwork/core/monarch/workspace/[-a-z0-9._]+)}) { $file = $1; } if ($file) { ( my $relative_file = $file ) =~ s{/usr/local/groundwork/core}{}; my $url = get_file_url( '', $relative_file, $line ); s{$file}{$file}; } } } sub get_ajax_url() { my $nocache = time; return "$monarch_cgi/monarch_ajax.cgi?nocache=$nocache"; } sub get_scan_url() { my $nocache = time; return "$monarch_cgi/monarch_scan.cgi?nocache=$nocache"; } sub scan(@) { my $addresses = $_[1]; my $elements = $_[2]; my $file = $_[3]; my $monarch_home = $_[4]; my @addresses = @{$addresses}; my $input_tags = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $javascript = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
 Escalation Tree
); my $class = undef; my $bclass = undef; my @lmenus = @menus; my $last_menu = pop @lmenus; my $first_menu = $menus[0]; my $menu_str = undef; foreach my $view (@menus) { if ( $obj_view eq $view ) { $class = 'top_menu_selected'; $bclass = 'topbuttonselected'; if ( $view eq $last_menu ) { $class = 'top_menu_selected_right'; } if ( $view eq $first_menu ) { $class = 'top_menu_selected_left'; } } else { $class = 'top_menu_menu'; $bclass = 'topbutton'; if ( $view eq $last_menu ) { $class = 'top_menu_right'; } } my $menu = $view; $menu = undef; my @menu = split( /_/, $view ); foreach (@menu) { $menu .= "\u$_ " } chop $menu; $menu_str .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $menu_str .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); unless ( $obj_view =~ /detail/ ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $menu_str
 
\u$type escalation tree: $name
Escalation detail:  
    ); foreach my $rank ( sort { $a <=> $b } keys %ranks ) { $detail .= "\n
  1. $templates{$ranks{$rank}}{'name'}\n
      "; if ( $templates{ $ranks{$rank} }{'service_description'} ) { unless ( $obj_view eq 'service_detail' || $obj_view eq 'service_names' ) { $detail .= "\n
    • service_description: $templates{$ranks{$rank}}{'service_description'}
    • "; } } if ( $templates{ $ranks{$rank} }{'notification_interval'} ) { my $val = $templates{ $ranks{$rank} }{'notification_interval'}; $val =~ s/-zero-/0/g; $detail .= "\n
    • notification_interval: $val
    • "; } if ( $templates{ $ranks{$rank} }{'first_notification'} ) { my $val = $templates{ $ranks{$rank} }{'first_notification'}; $val =~ s/-zero-/0/g; $detail .= "\n
    • first_notification: $val
    • "; } if ( $templates{ $ranks{$rank} }{'last_notification'} ) { my $val = $templates{ $ranks{$rank} }{'last_notification'}; $val =~ s/-zero-/0/g; $detail .= "\n
    • last_notification: $val
    • "; } if ( $templates{ $ranks{$rank} }{'contactgroups'} ) { $detail .= "\n
    • contactgroups: $templates{$ranks{$rank}}{'contactgroups'}
    • "; } $detail .= "
  2. "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Escalation detail:
    ); foreach my $rank ( sort { $a <=> $b } keys %ranks ) { $detail .= "\n
  1. $templates{$ranks{$rank}}{'name'}\n
      "; if ( $templates{ $ranks{$rank} }{'service_description'} ) { unless ( $obj_view eq 'service_detail' ) { $detail .= "\n
    • service_description: $templates{$ranks{$rank}}{'service_description'}
    • "; } } if ( $templates{ $ranks{$rank} }{'notification_interval'} ) { $detail .= "\n
    • notification_interval: $templates{$ranks{$rank}}{'notification_interval'}
    • "; } if ( $templates{ $ranks{$rank} }{'first_notification'} ) { $detail .= "\n
    • first_notification: $templates{$ranks{$rank}}{'first_notification'}
    • "; } if ( $templates{ $ranks{$rank} }{'last_notification'} ) { my $val = $templates{ $ranks{$rank} }{'last_notification'}; $val =~ s/-zero-/0/g; $detail .= "\n
    • last_notification: $val
    • "; } if ( $templates{ $ranks{$rank} }{'contactgroups'} ) { $detail .= "\n
    • contactgroups: $templates{$ranks{$rank}}{'contactgroups'}
    • "; } $detail .= "
  2. "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
); return $detail; } sub dependency_list(@) { my $name = $_[1]; my $obj = $_[2]; my $service_id = $_[3]; my $session_id = $_[4]; my $dependencies = $_[5]; my $role = $_[6] ? 'Dependent' : 'Master'; my $generic = $_[7]; my %dependencies = %{$dependencies}; my $view = 'manage_host'; if ( $obj eq 'services' ) { $view = 'service' } my $now = time; my $title1 = $generic ? "$role Service" : "$role Service Host"; my $title2 = $generic ? '' : "$role Service"; my $url_base = "$monarch_cgi/$cgi_exe?update_main=1&CGISESSID=$session_id&top_menu=$obj&nocache=$now&view=$view&obj=$obj&name=$name&service_id=$service_id&remove_dependency=1"; if ($role eq 'Master') { if ($generic) { $url_base .= "&obj_view=service_dependencies&generic=1"; } else { $url_base .= "&obj_view=service_dependencies"; } } else { if ($generic) { $url_base .= "&obj_view=confirm_delete_service&selected=$name&submit=remove_service&generic=1"; } else { $url_base .= "&obj_view=confirm_delete_service&selected=$name&submit=remove_service"; } } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub dependency_add(@) { my $dep_template = $_[1]; my $dep_templates = $_[2]; my $hosts = $_[3]; my $service = $_[4]; my $docs = $_[5]; my $tab = $_[6]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my @dep_templates = @{$dep_templates}; my @hosts = @{$hosts}; my %docs = %{$docs}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub display_template(@) { my $template = $_[1]; my $plist = $_[2]; my %template = %{$template}; my @props = split( /,/, $plist ); my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub form_files(@) { my $upload_dir = $_[1]; my $files = $_[2]; my $description = $_[3]; my $tab = $_[4]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my @files = @{$files}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub form_groups(@) { my $groups = $_[1]; my $tab = $_[2]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %groups = %{$groups}; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub service_group(@) { my $session_id = $_[1]; my $view = $_[2]; my $name = $_[3]; my $host_services = $_[4]; my $host = $_[5]; my $host_nonmembers = $_[6]; my $hosts = $_[7]; my $service = $_[8]; my $service_nonmembers = $_[9]; my $services = $_[10]; my $tab = $_[11]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %host_services = %{$host_services}; my @hosts = @{$hosts}; my @host_nonmembers = @{$host_nonmembers}; my @services = @{$services}; my @service_nonmembers = @{$service_nonmembers}; my $now = time; $name =~ s/\s/+/g; my $hostn = defined($host) ? $host : ''; $hostn =~ s/\s/+/g; my $servicen = defined($service) ? $service : ''; $servicen =~ s/\s/+/g; my $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub resource_select() { my $res = $_[1]; my $res_doc = $_[2]; my $selected = $_[3]; my $view = $_[4]; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %resources = %{$res}; my %res_doc = %{$res_doc}; my %selected = %{$selected}; my $user = $selected{'name'}; $user =~ s/user// if defined $user; my $detail = undef; use HTML::Entities; if ( ( $view eq 'control' || $view eq 'groups' ) && $selected{'name'} ) { my $userval = defined( $selected{'value'} ) ? HTML::Entities::encode($selected{'value'}) : ''; my $comment = defined( $resources{"resource_label$user"} ) ? HTML::Entities::encode($resources{"resource_label$user"}) : ''; $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub table_script_links(@) { my $session_id = $_[1]; my $type = $_[2]; my $script = $_[3]; my %script = %{$script}; my $now = time; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub radio_options(@) { my $title = $_[1]; my $name = $_[2]; my $value = $_[3]; my $doc = $_[4]; my $tab = $_[5]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $other = 'Use an interleave factor of:'; my %selected = ( s => '', d => '', n => '', other => '' ); my $text_val = ''; if ( $value eq 's' ) { $selected{'s'} = 'checked'; } elsif ( $value eq 'd' ) { $selected{'d'} = 'checked'; } elsif ( $value eq 'n' ) { $selected{'n'} = 'checked'; } else { $selected{'other'} = 'checked'; $text_val = $value; } $title =~ s/_/ /g; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub log_rotation(@) { my $title = $_[1]; my $name = $_[2]; my $value = $_[3]; my $doc = $_[4]; my %selected = (); if ( $value eq 'n' ) { $selected{'n'} = 'checked'; } elsif ( $value eq 'h' ) { $selected{'h'} = 'checked'; } elsif ( $value eq 'd' ) { $selected{'d'} = 'checked'; } elsif ( $value eq 'w' ) { $selected{'w'} = 'checked'; } elsif ( $value eq 'm' ) { $selected{'m'} = 'checked'; } $title =~ s/_/ /g; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub date_format(@) { my $value = $_[1]; my $doc = $_[2]; my $tab = $_[3]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my %selected = ( 'us' => '', 'euro' => '', 'iso8601' => '', 'strict-iso8601' => '' ); if ( $value eq 'us' ) { $selected{'us'} = 'checked'; } elsif ( $value eq 'euro' ) { $selected{'euro'} = 'checked'; } elsif ( $value eq 'iso8601' ) { $selected{'iso8601'} = 'checked'; } elsif ( $value eq 'strict-iso8601' ) { $selected{'strict-iso8601'} = 'checked'; } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub mas_delete(@) { my %hosts = %{ $_[1] }; my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]} ); return $detail; } sub search_results(@) { my $objects = $_[1]; my $session_id = $_[2]; my $type = $_[3]; my $num_more = $_[4]; use URI::Escape; my $now = time; my %objects = %{$objects}; # NOTE: The blank line here before
); if (%instances) { my @alph_sorted = (); my @num_sorted = (); my %instance_sort = (); foreach my $instance ( keys %instances ) { my $inst = $instance; $inst =~ s/^_//; $inst .= rand(); if ( $inst =~ /^\d+/ ) { push @num_sorted, $inst; } else { push @alph_sorted, $inst; } $instance_sort{$inst} = $instances{$instance}; $instance_sort{$inst}{'name'} = $instance; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $row = 1; foreach my $instance ( sort { $a <=> $b } @num_sorted ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $checked = ''; if ( $instance_sort{$instance}{'status'} ) { $checked = 'checked' } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } foreach my $instance ( sort { lc($a) cmp lc($b) } @alph_sorted ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $checked = ''; if ( $instance_sort{$instance}{'status'} ) { $checked = 'checked' } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Multiple Instances (optional)
$doc
Service instance name suffix:     or enter a numbered range:    –    
  Instance Name Suffix Status Arguments
Active
Active
     
); my $body = undef; $name =~ s/ /+/g; foreach my $id ( sort { $a <=> $b } keys %dependencies ) { my $third_field = $generic ? '' : $dependencies{$id}[2]; $body .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ( !$body ) { $body .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} $body
Dependency $title1 $title2                  
$dependencies{$id}[0] $dependencies{$id}[1] $third_field remove service dependency assignment
no dependencies defined
); if (defined $service) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Dependency:  ?    
Master service host:  ?    
Master service:  ?  $service
Detail:   ); foreach my $p (@props) { if ( $p eq 'name' ) { next } $template{$p} =~ s/-zero-/0/g; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$p $template{$p}
); unless ( $files[0] ) { $detail .= "There are no eligible files in $upload_dir."; } else { my $row = 1; foreach my $file ( sort @files ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $desc = $description->{$file}; $desc = '' if not defined $desc; $desc = HTML::Entities::encode($desc); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$file $desc
  
); unless ( scalar keys %groups ) { $detail .= " There are no groups defined."; } else { foreach my $group ( sort keys %groups ) { my $description = defined( $groups{$group} ) ? $groups{$group} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$group    $description
  
); unless (%host_services) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } foreach my $host ( sort keys %host_services ) { my $hname = $host; $hname =~ s/\s/+/g; foreach my $service ( @{ $host_services{$host} } ) { my $sname = $service; $sname =~ s/\s/+/g; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Host Service  
     
$host $service remove service assignment
Host: Service(s):
Service: Host(s):
\U$selected{'name'}\E value:
Description:
  
); my $class = 'row_dk'; for ( my $i = 1 ; $i < 33 ; $i++ ) { my $value = $resources{"user$i"}; my $description = $res_doc{"resource_label$i"} || $resources{"resource_label$i"}; my $password = 0; if ( $view eq 'commands' && defined($description) && $description =~ /password/i ) { $password = 1; $value = '************'; } if ( $class =~ /^row_lt/ ) { $class = ( defined( $selected{'name'} ) && $selected{'name'} eq "user$i" ) ? 'row_dk_selected' : 'row_dk'; } elsif ( $class =~ /^row_dk/ ) { $class = ( defined( $selected{'name'} ) && $selected{'name'} eq "user$i" ) ? 'row_lt_selected' : 'row_lt'; } my $checked = ( defined( $selected{'name'} ) && $selected{'name'} eq "user$i" ) ? 'checked' : ''; my $userval = defined($value) ? HTML::Entities::encode($value) : ''; my $comment = defined($description) ? HTML::Entities::encode($description) : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Select resource macro:
Macro Value Description
USER$i   $userval $comment
); foreach my $name ( sort keys %script ) { unless ( $name =~ /HASH/ ) { my $url = undef; if ( $script{$name} =~ /Error/ ) { $url = qq(@{[&$Instrument::show_trace_as_html_comment()]}

$name - $script{$name}

); } else { $url = qq(@{[&$Instrument::show_trace_as_html_comment()]}); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}\n\n\n); } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
\u$type Scripts
$url\n
); if ($doc) { $detail .= "\n
\u$title\n ? "; } else { $detail .= "\n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); if ( $name =~ /inter_check_delay_method|service_inter_check_delay_method|host_inter_check_delay_method/ ) { $other = 'Use an inter-check delay of:'; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
None  
Dumb  
Smart  
$other
); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
); if ($doc) { $detail .= "\n
\u$title\n ? "; } else { $detail .= "\n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
None
Hourly
Daily
Weekly
Monthly
); if ($doc) { $detail .= "\n
Date format:\n ? "; } else { $detail .= "\n\n "; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
USA (MM-DD-YYYY HH:MM:SS)
International (DD-MM-YYYY HH:MM:SS)
ISO-8601 (YYYY-MM-DD HH:MM:SS)
strict-ISO-8601 (YYYY-MM-DDTHH:MM:SS)
); my $row = 1; my $sort_num = $hosts{'sort_num'}; delete $hosts{'sort_num'}; foreach my $host ( sort keys %hosts ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $name = uri_escape($host); if ($sort_num) { $name = uri_escape( $hosts{$host} ); } else { $hosts{$host} = ' '; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
   $host $hosts{$host}  
is vital, as JBoss needs it to separate # the (empty) set of header lines from the result contents, so it does not interpret # some content as headers, swallow it, and report an error (bad header lines). my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
); if (%objects) { my @objects = (); if ( $objects{'sort_num'} ) { delete $objects{'sort_num'}; @objects = sort { $objects{$a} cmp $objects{$b} } keys %objects; } else { # We use uc, not lc, here to match MySQL collation vs. punctuation. @objects = sort { uc($a) cmp uc($b) } keys %objects; } my $row = 1; foreach my $object (@objects) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $name = $object; $name =~ s/\s/+/g; $name = uri_escape($name); if ( $type eq 'service' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $type eq 'command' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $type eq 'host_external' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $type eq 'service_external' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $type eq 'ez' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } elsif ( $type eq 'delete_hosts' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { my $ipaddr = ''; if ($object ne $objects{$object}) { $ipaddr = qq( $objects{$object}); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } } } else { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ( $num_more > 0 ) { $detail .= "\n"; } $detail .= "\n
 $objects{$object}
 $objects{$object}
 $objects{$object}
 $objects{$object}
 $objects{$object}
   $objects{$object}
 $object $ipaddr
 Nothing found
($num_more more)
"; return $detail; } sub search(@) { my $session_id = $_[1]; my $type = $_[2]; my $value = $_[3]; my $search_function = ''; my $caption = "Input any part of a host name or address:"; if (defined $type) { if ( $type eq 'services' ) { $caption = "Input any part of a service name:"; } elsif ( $type eq 'commands' ) { $caption = "Input any part of a command name:"; } elsif ( $type eq 'host_externals' ) { $caption = "Input any part of a host external name:"; } elsif ( $type eq 'service_externals' ) { $caption = "Input any part of a service external name:"; } } my $detail = qq(@{[&$Instrument::show_trace_as_html_comment()]}
$caption ); # We impose an imperceptible delay to cut down on excess queries. $search_function = 'find_hosts'; if (defined $type) { if ( $type eq 'services' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $search_function = 'find_services'; } elsif ( $type eq 'commands' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $search_function = 'find_commands'; } elsif ( $type eq 'host_externals' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $search_function = 'find_externals'; } elsif ( $type eq 'service_externals' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $search_function = 'find_externals'; } elsif ( $type eq 'ez' ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); $search_function = 'find_ez_hosts'; } } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Results will appear below.
 
        
); if ( defined($title) ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } if ( defined($body) ) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$title_begin$title$title_end
$body_begin$body$body_end
Status:
$javascript $input_tags
Import Options

The import process will read a set of Nagios configuration files, starting with the nagios.cfg and cgi.cfg files in the /usr/local/groundwork/nagios/etc/ directory. Before you proceed, you must copy your to-import versions of those two files into that location. Also, you must ensure that all the cfg_dir, cfg_file, and resource_file directives in those two files point to the places where your other files to import are located. Then select one of the options below.

Update (default): Add and update objects from the file definitions. Note: Escalations are excluded unless you select "Import escalations" below.
  Import escalations: Replace escalations from the file definitions. There is no option to update escalations.
Purge nice: Clear Nagios service related records, including services, service dependencies, service templates, and escalations; but preserve hosts, commands, time periods, contacts, and profiles (including service profiles). This option will update hosts, commands, time periods, and contacts from the file definitions. Service profiles remain as empty vessels.
Purge all: Completely clear all Nagios records, including profiles and their associations, from the database. This option will repopulate the database from the file definitions. Since Nagios configuration files do not contain all the relationships stored within a GroundWork configuration, some information may be lost. Some relationships, such as host templates assigned to hosts, will be manufactured on a best-guess basis if they are not already established in the incoming files. In other cases, the data will be adjusted to fit within the supported data model, such as collapsing chains of host template references.
Nagios 3.x import: Clears the database of all Nagios records, just as Purge all does, and replaces them with data from the Nagios 3.x configuration files. To use this option, you must have created a Nagios 3.x precached objects file by running nagios -vp /usr/local/groundwork/nagios/etc/nagios.cfg from the command line. The import process also reads the main nagios.cfg file and any files it includes by reference, in order to pull in any templates found in those files. Although the templates will be imported into Monarch, they will not be associated with any objects. You can do this later by adding templates to profiles, then applying the profiles to hosts or other objects. Finally, note that all custom object variables will be capitalized in the precached objects file, and so may not match what is in the Nagios configuration files (merging of names from the different sources may not produce the expected results).
  Precached objects file:
Sort keys:
 
Sort columns:             
); my $class = undef; foreach my $host (@hosts) { unless ($host) { next } my @values = split( /$delimiter/, $host_data{$host} ); if ( $delimiter eq 'tab' ) { @values = split( /\t/, $host_data{$host} ); } unless ( $values[ $fields{'alias'} ] ) { $values[ $fields{'alias'} ] = $values[ $fields{'name'} ]; } if ( $values[ $fields{'name'} ] && $values[ $fields{'address'} ] ) { $class = 'row_good'; if ( $exists{ $values[ $fields{'name'} ] } ) { $class = 'row_exists'; } } else { $class = 'row_exception'; } my $profile = ' --- '; if ( $profiles{ $values[ $fields{'profile'} ] } ) { $profile = $values[ $fields{'profile'} ]; } $host =~ s/^\s+|\s+$//g; $values[ $fields{'alias'} ] =~ s/^\s+|\s+$//g; $values[ $fields{'address'} ] =~ s/^\s+|\s+$//g; $values[ $fields{'os'} ] =~ s/^\s+|\s+$//g; $values[ $fields{'other'} ] =~ s/^\s+|\s+$//g; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$host $values[$fields{'alias'}] $values[$fields{'address'}] $values[$fields{'os'}] $profile $values[$fields{'other'}]
  
); my $row = 1; foreach my $profile (@profiles) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } $checked = undef; if ( $selected eq $profile ) { $checked = 'checked' } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Host profile: Host groups: Service profiles:
$profile $profiles_detail{$profile}{'description'} ); if ( $profiles_detail{$profile}{'hostgroups'} ) { foreach my $hg ( sort { $a <=> $b } @{ $profiles_detail{$profile}{'hostgroups'} } ) { $detail .= "$hg
\n"; } } else { $detail .= " \n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
); delete $profiles_detail{$profile}{'hostgroups'}; delete $profiles_detail{$profile}{'description'}; foreach my $sp ( sort keys %{ $profiles_detail{$profile} } ) { $detail .= "$sp
\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
); foreach my $sp ( sort keys %{ $profiles_detail{$profile} } ) { $detail .= "$profiles_detail{$profile}{$sp}
\n"; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
); return $detail; } sub form_discover() { my $oct1 = $_[1]; my $oct2 = $_[2]; my $oct3 = $_[3]; my $oct4 = $_[4]; my $oct5 = $_[5]; unless ($oct4) { $oct4 = '*' } return qq(@{[&$Instrument::show_trace_as_html_comment()]}
Enter address, range or subnet:  .  .  .  - 
Scanning:
$javascript $input_tags
$title
$body
Contact groups
$docs{'contactgroups'}
Group Status
$docs{'status'}
Set group inactive in Nagios:  ? 
Sync hosts to Foundation:  ? 
Build Instance Properties
$docs{'build_instance_properties'}
Build folder:  ? 
Nagios etc folder:  ? 
Force hosts:  ? 
Host active checks enabled:  ?  Inherit    Enabled
Host passive checks enabled:  ?  Inherit    Enabled
Service active checks enabled:  ?  Inherit    Enabled
Service passive checks enabled:  ?  Inherit    Enabled
); my $row = 1; foreach my $host ( sort { lc($a) cmp lc($b) } keys %members ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } foreach my $hostgroup ( sort { lc($a) cmp lc($b) } keys %hostgroup_members ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $host_text = join ( ', ', @{ $hostgroup_members{$hostgroup} } ); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $scroll_height = scalar (keys %nonmembers); $scroll_height = 10 if ($scroll_height < 10); $scroll_height = 20 if ($scroll_height > 20); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$host host   $members{$host}{'alias'}  
$hostgroup hostgroup   $host_text 
     
); $row = 1; foreach my $host ( sort { lc($a) cmp lc($b) } keys %nonmembers ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $scroll_height = scalar (keys %hostgroup_nonmembers); $scroll_height = 10 if ($scroll_height < 10); $scroll_height = 20 if ($scroll_height > 20); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$host $nonmembers{$host}{'alias'}  $nonmembers{$host}{'address'} 
); $row = 1; foreach my $hostgroup ( sort { lc($a) cmp lc($b) } keys %hostgroup_nonmembers ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $host_text = join ( ', ', @{ $hostgroup_nonmembers{$hostgroup} } ); $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$hostgroup $host_text 
); my %child_parent = (); my $space = undef; my $p_group = 1; my $row = 1; my $class = undef; my %used = (); foreach my $grp (@order) { my $childstr = ''; my $childdesc = ''; delete $nonmembers{$grp}; foreach my $child ( keys %{ $group_child{$grp} } ) { $child_parent{$child} = $grp; $childstr .= "$child
"; $childdesc .= "$group_hosts{$child}{'description'}
"; $used{$child} = 1; delete $nonmembers{$child}; } if ( defined( $child_parent{$grp} ) && $child_parent{$grp} eq $p_group && $childstr ) { $space = " "; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } else { if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } unless ( $used{$grp} ) { my $description = defined( $group_hosts{$grp}{'description'} ) ? $group_hosts{$grp}{'description'} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $space = undef; } $p_group = $grp; } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
  $space $grp   $childstr $childdesc
$grp $description $childstr $childdesc
); $row = 1; foreach my $child ( sort { lc($a) cmp lc($b) } keys %nonmembers ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $description = defined( $nonmembers{$child}{'description'} ) ? $nonmembers{$child}{'description'} : ''; my $hosts = defined( $nonmembers{$child}{'hosts'} ) ? $nonmembers{$child}{'hosts'} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$child $description  $hosts 
Enable label Value:
); my $row = 1; foreach my $macro ( sort { lc($a) cmp lc($b) } keys %group_macros ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $description = defined( $group_macros{$macro}{'description'} ) ? $group_macros{$macro}{'description'} : ''; my $value = defined( $group_macros{$macro}{'value'} ) ? $group_macros{$macro}{'value'} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$macro $description
  Value:
  
); $row = 1; foreach my $macro ( sort { lc($a) cmp lc($b) } keys %macros ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $description = defined( $macros{$macro}{'description'} ) ? $macros{$macro}{'description'} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$macro $description
); my $row = 1; foreach my $macro ( sort { lc($a) cmp lc($b) } keys %macros ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $description = defined( $macros{$macro}{'description'} ) ? $macros{$macro}{'description'} : ''; my $value = defined( $macros{$macro}{'value'} ) ? $macros{$macro}{'value'} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
$macro
  Description:
  Value:
  New Macro
Macro name: 
Description:
Value:
$variable $temp_names->{$variable}
); $detail .= qq(
Custom Object Variables
$doc
); if ( not $root_template ) { $detail .= qq( ); } $detail .= qq( ); my %default_value = (); my $color = 'lt'; $detail .= variable_rows( $temp_names, $temp_urls, $temp_vars, $obj_vars, $root_template, 0, \%default_value, \$color, $tabindex ) if %$temp_vars; $detail .= variable_rows( $temp_names, $temp_urls, $temp_vars, $obj_vars, $root_template, 1, \%default_value, \$color, $tabindex ) if %$obj_vars; unless ( %$temp_vars || %$obj_vars ) { $detail .= qq( ); } $detail .= qq(
Suppress InheritName Value Template
None defined.
); if (%default_value) { foreach my $key (keys %default_value) { $default_value{$key} =~ s/([\\'])/\\$1/g; } my $default_values = join(',', map { "'$_': '$default_value{$_}'" } keys %default_value); $detail .= qq( ); } $detail .= qq(
Each variable name must begin with an underscore ("_"), contain at least one other character, and consist only of letters, numbers, and underscores. Leading and trailing space in both the name and value will be ignored.
Variable name:    
Value: 
); return $detail; } # ############################# # Nagios 3 edit time period ############################# # sub time_period_detail(@) { my %time_period = %{ $_[1] }; my %time_periods = %{ $_[2] }; my $tab = $_[3]; my $tabindex = $tab ? "tabindex=\"$tab\"" : ''; my $detail .= qq( Monarch
); if (%misc_vals) { $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); my $row = 1; foreach my $key ( sort keys %misc_vals ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $value = defined( $misc_vals{$key}{'value'} ) ? $misc_vals{$key}{'value'} : ''; $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]} ); } $detail .= qq(@{[&$Instrument::show_trace_as_html_comment()]}
Misc directives (optional)
$doc
  Name Value
$misc_vals{$key}{'name'}  
     
Directive name:     Value: 
Weekdays
The weekday directives (Sunday through Saturday) are comma-delimited lists of time ranges that are "valid" times for a particular day of the week. Notice that there are seven different days for which you can define time ranges (Sunday through Saturday). Each time range is in the form of HH:MM-HH:MM, where hours are specified on a 24 hour clock. For example, 00:15-24:00 means 12:15 in the morning for this day until 12:00 midnight (a 23 hour, 45 minute total time range). If you wish to exclude an entire day from the time period, simply do not include it in the time period definition.
); my $row = 1; my %got_day = (); my @weekdays = ( 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ); foreach my $day (@weekdays) { my $class = undef; if ( $time_period{'weekday'}{$day} ) { $got_day{$day} = 1; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $hours_style = ''; if ( exists $time_period{'weekday'}{$day}{'bad_hours'} ) { $hours_style = 'style="background-color: #FFFF99;"'; } my $comment = defined( $time_period{'weekday'}{$day}{'comment'} ) ? $time_period{'weekday'}{$day}{'comment'} : ''; $detail .= qq( ); } } unless ( keys %{ $time_period{'weekday'} } ) { $detail .= qq( ); } $detail .= qq(
Name Hours Description  
\u$day
None defined
Select a day and click add to set the hours.
Exceptions (Advanced)
You can specify several different types of exceptions to the standard rotating weekday schedule.

Exceptions can take a number of different forms including single days of a specific or generic month, single weekdays in a month, or single calendar dates. You can also specify a range of days/dates and even specify skip intervals to obtain functionality described by "every 3 days between these dates".

Examples:

2010-01-2800:00-24:00— January 28th, 2010
monday 300:00-24:00— 3rd Monday of every month
day 200:00-24:00— 2nd day of every month
february 1000:00-24:00— February 10th of every year
february -100:00-24:00— Last day in February of every year
friday -200:00-24:00— 2nd to last Friday of every month
thursday -1 november00:00-24:00— Last Thursday in November of every year

Visit http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#timeperiod for more examples of what can be accomplished.

Weekdays and different types of exceptions all have different levels of precedence, so it's important to understand how they can affect each other.

Precedence
  1. Specific month date (January 1st)
  2. Generic month date (Day 15)
  3. Offset weekday of specific month (2nd Tuesday in December)
  4. Offset weekday (3rd Monday)
  5. Weekday
More information on this can be found in the documentation at http://nagios.sourceforge.net/docs/3_0/timeperiods.html .
); $row = 1; foreach my $excp ( sort keys %{ $time_period{'exception'} } ) { my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $day_rule_style = ''; if ( exists $time_period{'exception'}{$excp}{'bad_day_rule'} ) { $day_rule_style = 'style="background-color: #FFFF99;"'; } my $hours_style = ''; if ( exists $time_period{'exception'}{$excp}{'bad_hours'} ) { $hours_style = 'style="background-color: #FFFF99;"'; } my $comment = defined( $time_period{'exception'}{$excp}{'comment'} ) ? $time_period{'exception'}{$excp}{'comment'} : ''; $detail .= qq( ); } unless ( keys %{ $time_period{'exception'} } ) { $detail .= qq( ); } $detail .= qq(
Day Rule Hours Description  
None defined
New day rule:  Enter a new Day Rule and click Add to set the hours.
Exclude
This directive is used to specify other timeperiod definitions whose time ranges should be excluded from this timeperiod.
); $row = 1; foreach my $tname ( sort keys %time_periods ) { my $checked = ''; if ( $tname eq $time_period{'name'} ) { next } foreach my $id ( keys %{ $time_period{'exclude'} } ) { $checked = 'checked' if $id eq $time_periods{$tname}{'id'}; } my $class = undef; if ( $row == 1 ) { $class = 'row_lt'; $row = 2; } elsif ( $row == 2 ) { $class = 'row_dk'; $row = 1; } my $comment = defined( $time_periods{$tname}{'comment'} ) ? $time_periods{$tname}{'comment'} : ''; $detail .= qq( ); } unless ( keys %time_periods ) { $detail .= qq(); } $detail .= qq(
  Time Period Name Alias Description
$tname $time_periods{$tname}{'alias'} $comment
None defined
Session Timeout
Please login.
); } sub login(@) { my $title = $_[1]; my $message = $_[2]; if ($message) { $message = "† $message

"; } else { $message = undef; } # FIX MINOR: the /monarch/images/... references here are probably broken return qq( Monarch

About GroundWork Monitor Architect

GroundWork Monitor Architect is a web-based configuration tool for Nagios. Features in version 4.0 include:
  • Support for the PostgreSQL database
  • Custom Object Variables for Contacts and Hosts
  • Distributed agents reporting to Child Servers
  • Support for most Western European languages

Support:

Visit GroundWork's support forums at: www.gwos.com/forums

Please log in

If you do not have an account, contact your Administrator.

$message
Username

Password


 
); } sub unindent { $_[0] =~ s/^[\n\r]*//; my ($indent) = ( $_[0] =~ /^([ \t]+)/ ); $_[0] =~ s/^$indent//gm; } 1;