3 # List all services currently being monitored
5 $trust_unknown_referers = 1;
6 require './status-lib.pl';
7 print "Refresh: $config{'refresh'}\r\n"
8 if ($config{'refresh'});
9 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
11 # If we are using SNMP for notification, make sure the Perl module is installed
12 if ($config{'snmp_server'}) {
15 eval "use SNMP_Session";
19 &ui_config_link('index_esnmp',
20 [ "<tt>Net::SNMP</tt>",
21 "../cpan/download.cgi?source=3&cpan=Net::SNMP&mode=2&return=/$module_name/&returndesc=".&urlize($text{'index_return'}),
26 @serv = &list_services();
27 $mid = int((@serv-1) / 2);
28 $oldstatus = &read_file($oldstatus_file, \%oldstatus);
32 if ($config{'sort_mode'} == 1) {
33 @serv = sort { $a->{'desc'} cmp $b->{'desc'} } @serv;
35 elsif ($config{'sort_mode'} == 2) {
36 @serv = sort { $a->{'remote'} cmp $b->{'remote'} } @serv;
38 elsif ($config{'sort_mode'} == 3) {
39 @serv = sort { $oldstatus{$a->{'id'}} <=> $oldstatus{$b->{'id'}} } @serv;
41 if (!$config{'index_status'} && $oldstatus) {
42 local @st = stat("$module_config_directory/oldstatus");
43 local $t = localtime($st[9]);
44 print &text('index_oldtime', $t),"<br>\n";
47 # Show table of defined monitors
49 if ($access{'edit'}) {
50 print &ui_form_start("delete_mons.cgi", "post");
51 push(@links, &select_all_link("d", 1),
52 &select_invert_link("d", 1) );
54 print &ui_links_row(\@links);
55 if ($config{'columns'} == 2) {
56 print "<table width=100%><tr>\n";
57 print "<td width=50% valign=top>\n";
58 &service_table(@serv[0 .. $mid]);
59 print "</td> <td width=50% valign=top>\n";
60 &service_table(@serv[$mid+1 .. $#serv]) if (@serv > 1);
61 print "</td></tr></table>\n";
64 &service_table(@serv);
66 print &ui_links_row(\@links);
67 if ($access{'edit'}) {
68 print &ui_form_end([ [ "delete", $text{'index_delete'} ],
69 [ "refresh", $text{'index_refsel'} ] ]);
73 print "<b>$text{'index_none'}</b><p>\n";
78 print &ui_buttons_start();
79 if ($access{'sched'}) {
80 # Open scheduled monitoring form
81 print &ui_buttons_row("edit_sched.cgi",
83 $text{'index_scheddesc'});
85 if ($access{'edit'}) {
86 # Email templates button
87 print &ui_buttons_row("list_tmpls.cgi",
89 $text{'index_tmplsdesc'});
91 if (!$config{'index_status'}) {
93 print &ui_buttons_row("refresh.cgi",
94 $text{'index_refresh'},
95 $text{'index_refreshdesc'});
97 print "</tr></table>\n";
100 &ui_print_footer("/", $text{'index'});
105 local @tds = $access{'edit'} ? ( "width=5" ) : ( );
106 print &ui_columns_start([
107 $access{'edit'} ? ( "" ) : ( ),
110 $config{'index_status'} ? ( $text{'index_up'} ) :
111 $oldstatus ? ( $text{'index_last'} ) : ( ),
114 # One row per monitor
117 local $esc = &html_escape($s->{'desc'});
118 $esc = "<i>$esc</i>" if ($s->{'nosched'} == 1);
119 if ($access{'edit'}) {
120 push(@cols, "<a href='edit_mon.cgi?id=$s->{'id'}'>$esc</a>");
125 push(@cols, &nice_remotes($s));
127 # Work out and show all the up icons
129 if ($config{'index_status'}) {
130 # Showing the current status
131 @stats = &service_status($s, 1);
132 @ups = map { $_->{'up'} } @stats;
133 @remotes = map { $_->{'remote'} } @stats;
136 # Getting status from last check
137 $stat = &expand_oldstatus($oldstatus{$s->{'id'}});
138 @remotes = &expand_remotes($s);
139 @ups = map { defined($stat->{$_}) ? ( $stat->{$_} ) : ( ) }
147 for(my $i=0; $i<@ups; $i++) {
150 $h = $text{'index_local'} if ($h eq '*');
151 push(@icons, "<img src=images/".
152 ($up == 1 ? "up.gif" :
153 $up == -1 ? "not.gif" :
154 $up == -2 ? "webmin.gif" :
155 $up == -3 ? "timed.gif" :
156 $up == -4 ? "skip.gif" :
158 " title='".&html_escape($h)."'>");
160 push(@cols, join("", @icons));
162 if ($access{'edit'}) {
163 print &ui_checked_columns_row(\@cols, \@tds, "d", $s->{'id'});
166 print &ui_columns_row(\@cols, \@tds);
169 print &ui_columns_end();
174 if ($access{'edit'}) {
175 print "<form action=edit_mon.cgi>\n";
176 print "<input type=submit value='$text{'index_add'}'> ",
177 "<select name=type>\n";
178 foreach $h (sort { $a->[1] cmp $b->[1] } &list_handlers()) {
179 printf "<option value=%s>%s\n",
180 $h->[0], $h->[1] || $h->[0];
182 print "</select></form>\n";