Handle hostnames with upper-case letters
[webmin.git] / mon / edit_watch.cgi
1 #!/usr/local/bin/perl
2 # edit_watch.cgi
3 # Display a new or existing watch
4
5 require './mon-lib.pl';
6 &ReadParse();
7 $conf = &get_mon_config();
8 $watch = $conf->[$in{'idx'}];
9
10 &ui_print_header(undef, $text{'watch_title'}, "");
11
12 print "<form action=save_watch.cgi>\n";
13 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
14 print "<table border width=100%>\n";
15 print "<tr $tb> <td><b>$text{'watch_header'}</b></td> </tr>\n";
16 print "<tr $cb> <td><table width=100%>\n";
17
18 print "<tr> <td><b>$text{'watch_group'}</b></td>\n";
19 print "<td><select name=group>\n";
20 foreach $s (&find("hostgroup", $conf)) {
21         printf "<option %s>%s\n",
22                 $s eq $watch->{'values'}->[0] ? "selected" : "",
23                 $s->{'values'}->[0];
24         $found++ if ($s eq $watch->{'values'}->[0]);
25         }
26 print "<option selected>$watch->{'values'}->[0]\n" if (!$found);
27 print "</select></td> </tr>\n";
28
29 print "<tr> <td valign=top><b>$text{'watch_services'}</b></td>\n";
30 print "<td colspan=3> <table border width=100%>\n";
31 print "<tr $tb> <td><b>$text{'watch_service'}</b></td> ",
32       "<td><b>$text{'watch_monitor'}</b></td> ",
33       "<td><b>$text{'watch_interval'}</b></td> ",
34       "<td><b>$text{'watch_periods'}</b></td> </tr>\n";
35 foreach $s (&find("service", $watch->{'members'})) {
36         print "<tr $cb>\n";
37         print "<td><a href='edit_service.cgi?idx=$in{'idx'}&",
38               "sidx=$s->{'index'}'>$s->{'value'}</a></td>\n";
39         local $mon = &find_value("monitor", $s->{'members'});
40         print "<td>$mon</td>\n";
41         local $int = &find_value("interval", $s->{'members'});
42         print "<td>$int</td>\n";
43         local @pers = &find("period", $s->{'members'});
44         local $pers = join("&nbsp;,&nbsp;", map { $_->{'value'} } @pers);
45         print "<td>$pers</td>\n";
46         print "</tr>\n";
47         }
48 print "</table>\n";
49 print "<a href='edit_service.cgi?idx=$in{'idx'}&new=1'>",
50       "$text{'watches_sadd'}</a>\n";
51 print "</td> </tr>\n";
52
53 print "</table></td></tr></table>\n";
54
55 print "<table width=100%><tr>\n";
56 if ($in{'new'}) {
57         print "<td><input type=submit value='$text{'create'}'></td>\n";
58         }
59 else {
60         print "<td><input type=submit value='$text{'save'}'></td>\n";
61         print "<td align=right><input type=submit name=delete ",
62               "value='$text{'delete'}'></td>\n";
63         }
64 print "</tr></table></form>\n";
65
66 &ui_print_footer("list_watches.cgi", $text{'watches_return'});
67