Button to refresh selected monitors

This commit is contained in:
Jamie Cameron
2009-11-26 18:08:39 -08:00
parent 8188286368
commit 0d8339f812
5 changed files with 45 additions and 13 deletions
+1
View File
@@ -66,3 +66,4 @@ Added a new monitor type for Dovecot.
Added an option to the SSH monitor type for a port number.
---- Changes since 1.490 ----
Added a new monitor type for detecting large directories.
Added a button to the main page for refreshing only selected monitors, thanks to Michael Mansour.
+32 -12
View File
@@ -1,17 +1,37 @@
#!/usr/local/bin/perl
# Delete multiple monitors at once
# Delete or refresh multiple monitors at once
require './status-lib.pl';
$access{'edit'} || &error($text{'mon_ecannot'});
&ReadParse();
foreach $d (split(/\0/, $in{'d'})) {
$serv = &get_service($d);
$serv || &error($text{'delete_egone'});
push(@dels, $serv);
}
foreach $serv (@dels) {
&delete_service($serv);
}
&webmin_log("deletes", undef, scalar(@dels));
&redirect("");
$in{'d'} || &error($text{'deletes_enone'});
@d = split(/\0/, $in{'d'});
if ($in{'delete'}) {
# Deleting
$access{'edit'} || &error($text{'mon_ecannot'});
foreach $d (@d) {
$serv = &get_service($d);
$serv || &error($text{'deletes_egone'});
push(@dels, $serv);
}
foreach $serv (@dels) {
&delete_service($serv);
}
&webmin_log("deletes", undef, scalar(@dels));
&redirect("");
}
else {
# Refreshing
&ui_print_unbuffered_header(undef, $text{'refresh_title'}, "");
print &text('refresh_doing2', scalar(@d)),"<br>\n";
&foreign_require("cron", "cron-lib.pl");
&cron::create_wrapper($cron_cmd, $module_name, "monitor.pl");
$ids = join(" ", map { quotemeta($_) } @d);
&system_logged("$cron_cmd --force $ids >/dev/null 2>&1 </dev/null");
&webmin_log("refresh");
print $text{'refresh_done'},"<p>\n";
print &js_redirect("index.cgi");
&ui_print_footer("", $text{'index_return'});
}
+2 -1
View File
@@ -65,7 +65,8 @@ if (@serv) {
}
print &ui_links_row(\@links);
if ($access{'edit'}) {
print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
print &ui_form_end([ [ "delete", $text{'index_delete'} ],
[ "refresh", $text{'index_refsel'} ] ]);
}
}
else {
+3
View File
@@ -15,6 +15,7 @@ index_esnmp=The module is configured to send SNMP traps on the <a href='$3'>Modu
index_refresh=Refresh Status
index_refreshdesc=Perform an immediate refresh of all monitor statuses, instead of waiting for the next scheduled update.
index_delete=Delete Selected
index_refsel=Refresh Selected
index_group=Members of $1
index_tmpls=Edit Email Templates
index_tmplsdesc=View and edit templates used to construct email messages sent when monitored services go down.
@@ -301,6 +302,7 @@ iface_iface=Interface to check
refresh_title=Refresh Status
refresh_doing=Refreshing the status of all monitors ..
refresh_doing2=Refreshing the status of $1 selected monitors ..
refresh_done=.. done.
sensors_name=Sensor to check
@@ -374,6 +376,7 @@ monitor_run2=Running $1 ..
monitor_runerr=Failed to run $1 on $2 : $3
deletes_egone=One of the selected monitors no longer exists
deletes_enone=No monitors selected
ftp_host=FTP server host
ftp_port=FTP port
+7
View File
@@ -11,12 +11,16 @@ require './status-lib.pl';
# Check if the monitor should be run now
@tm = localtime(time());
if ($ARGV[0] ne "--force") {
shift(@ARGV);
@hours = split(/\s+/, $config{'sched_hours'});
!@hours || &indexof($tm[2], @hours) >= 0 || exit;
@days = split(/\s+/, $config{'sched_days'});
!@days || &indexof($tm[6], @days) >= 0 || exit;
}
# Check for list of monitors to limit refresh to
%onlycheck = map { $_, 1 } @ARGV;
# Open status and number of fails files
&lock_file($oldstatus_file);
&read_file($oldstatus_file, \%oldstatus);
@@ -26,6 +30,9 @@ if ($ARGV[0] ne "--force") {
# Get the list of services, ordered so that those with dependencies are first
@services = &list_services();
@services = sort { &sort_func($a, $b) } @services;
if (keys %onlycheck) {
@services = grep { $onlycheck{$_->{'id'}} } @services;
}
# Check for services that are down
$nowunix = time();