Handle hostnames with upper-case letters
[webmin.git] / cluster-cron / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Show all cron jobs that run on multiple servers
4
5 require './cluster-cron-lib.pl';
6 &ui_print_header(undef, $text{'index_title'}, "", "intro", 0, 1);
7
8 @links = ( &select_all_link("d"),
9            &select_invert_link("d"),
10            "<a href='edit.cgi?new=1'>$text{'index_add'}</a>" );
11
12 @jobs = &list_cluster_jobs();
13 if (@jobs) {
14         print &ui_form_start("delete_jobs.cgi", "post");
15         print &ui_links_row(\@links);
16         print &ui_columns_start([ "",
17                                   $cron::text{'index_user'},
18                                   $cron::text{'index_active'},
19                                   $text{'index_servers'},
20                                   $cron::text{'index_command'} ],
21                                 100, 0,
22                                 [ "width=5", undef, undef, undef, "colspan=2" ]);
23         foreach $j (@jobs) {
24                 local @cols;
25                 push(@cols, "<tt>$j->{'cluster_user'}</tt>");
26                 push(@cols, 
27                         $j->{'active'} ? $text{'yes'}
28                                 : "<font color=#ff0000>$text{'no'}</font>");
29                 local @servers = map {
30                         $_ eq "*" ? $text{'edit_this'} :
31                         $_ =~ /^group_(.*)$/ ? &text('edit_group', "$1") : $_
32                                 } split(/\s+/, $j->{'cluster_server'});
33                 if (@servers > 3) {
34                         push(@cols, join(", ", @servers[0 .. 1]).", ".
35                               &text('index_more', @servers-2));
36                         }
37                 else {
38                         push(@cols, join(", ", @servers));
39                         }
40                 local $max = $cron::config{'max_len'} || 10000;
41                 local $cmd = $j->{'cluster_command'};
42                 push(@cols, 
43                    sprintf "<a href='edit.cgi?id=$j->{'cluster_id'}'>%s</a>%s",
44                         length($cmd) > $max ?
45                                 &html_escape(substr($cmd, 0, $max)) :
46                         $cmd !~ /\S/ ? "BLANK" : &html_escape($cmd),
47                         length($cmd) > $max ? " ..." : "");
48                 push(@cols, "<a href='exec.cgi?id=$j->{'cluster_id'}'>".
49                             "$text{'index_run'}</a>");
50                 print &ui_checked_columns_row(
51                         \@cols,
52                         [ "width=5", undef, undef, undef, undef, "width=10" ],
53                         "d", $j->{'cluster_id'});
54                 }
55         print &ui_columns_end();
56         print &ui_links_row(\@links);
57         print &ui_form_end([ [ "delete", $cron::text{'index_delete'} ] ]);
58         }
59 else {
60         print "<b>$text{'index_none'}</b><p>\n";
61         print &ui_links_row([ $links[2] ]);
62         }
63
64 &ui_print_footer("/", $text{'index'});
65