mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Start of work on showing history for a service
This commit is contained in:
@@ -6,3 +6,5 @@ snmp_trap=1.3.6.1.4.1.10000.1.1
|
||||
subject_mode=0
|
||||
columns=2
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -7,3 +7,5 @@ snmp_trap=1.3.6.1.4.1.10000.1.1
|
||||
subject_mode=0
|
||||
columns=2
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -8,3 +8,5 @@ snmp_trap=1.3.6.1.4.1.10000.1.1
|
||||
subject_mode=0
|
||||
columns=2
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -7,3 +7,5 @@ snmp_trap=1.3.6.1.4.1.10000.1.1
|
||||
subject_mode=0
|
||||
columns=2
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -7,3 +7,5 @@ snmp_trap=1.3.6.1.4.1.10000.1.1
|
||||
subject_mode=0
|
||||
columns=2
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -7,3 +7,5 @@ subject_mode=0
|
||||
columns=2
|
||||
pinger=linux
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -6,3 +6,5 @@ snmp_trap=1.3.6.1.4.1.10000.1.1
|
||||
subject_mode=0
|
||||
columns=2
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -6,3 +6,5 @@ snmp_trap=1.3.6.1.4.1.10000.1.1
|
||||
subject_mode=0
|
||||
columns=2
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -6,3 +6,5 @@ snmp_trap=1.3.6.1.4.1.10000.1.1
|
||||
subject_mode=0
|
||||
columns=2
|
||||
sched_offset=0
|
||||
history_show=50
|
||||
history_purge=30
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
line1=Configurable options,11
|
||||
index_status=Status to display in list,1,1-Current status,0-From last scheduled check
|
||||
pager_cmd=Command to send message to a pager,3,None
|
||||
refresh=Seconds between page refreshes,3,Don't refresh
|
||||
@@ -12,3 +11,5 @@ snmp_server=Send SNMP traps to server,3,None
|
||||
snmp_version=SNMP protocol version,1,3-v3,2-v2,1-v1
|
||||
snmp_community=SNMP community string,0
|
||||
snmp_trap=SNMP OID for traps,0
|
||||
history_show=Number of historical statuses to show,0
|
||||
history_purge=Days to keep historical statuses,0
|
||||
|
||||
@@ -243,6 +243,54 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
# Show history, in a hidden section
|
||||
if (!$in{'type'}) {
|
||||
@history = &list_history($serv, $config{'history_show'});
|
||||
}
|
||||
if (@history) {
|
||||
print &ui_hidden_table_start($text{'mon_header4'}, "width=100%", 2,
|
||||
"history", 0);
|
||||
@links = ( );
|
||||
if ($in{'changes'}) {
|
||||
push(@links, "<a href='edit_mon.cgi?id=$in{'id'}&changes=0'>".
|
||||
$text{'mon_changes0'}."</a>");
|
||||
}
|
||||
else {
|
||||
push(@links, "<a href='edit_mon.cgi?id=$in{'id'}&changes=1'>".
|
||||
$text{'mon_changes1'}."</a>");
|
||||
}
|
||||
# XXX
|
||||
$table = &ui_links_row(\@links);
|
||||
$table .= &ui_columns_start([ $text{'mon_hwhen'},
|
||||
$text{'mon_hold'},
|
||||
$text{'mon_hnew'},
|
||||
$text{'mon_hvalue'} ]);
|
||||
foreach $h (reverse(@history)) {
|
||||
my @cols = ( &make_date($h->{'time'}) );
|
||||
foreach my $s ($h->{'old'}, $h->{'new'}) {
|
||||
my @ups;
|
||||
my @statuses = split(/\s+/, $s);
|
||||
foreach my $rs (@statuses) {
|
||||
my ($host, $up) = split(/=/, $rs, 2);
|
||||
$img = "<img src=".&get_status_icon($up).">";
|
||||
if ($host ne "*") {
|
||||
$img = $host.$img;
|
||||
}
|
||||
elsif (@statuses > 1) {
|
||||
$img = &get_display_hostname().$img;
|
||||
}
|
||||
push(@ups, $img);
|
||||
}
|
||||
push(@cols, join(" ", @ups));
|
||||
}
|
||||
push(@cols, $h->{'value_show'} || $h->{'value'});
|
||||
$table .= &ui_columns_row(\@cols);
|
||||
}
|
||||
$table .= &ui_columns_end();
|
||||
print &ui_table_row(undef, $table, 2);
|
||||
print &ui_hidden_table_end();
|
||||
}
|
||||
|
||||
# Show create/delete buttons
|
||||
if ($in{'type'}) {
|
||||
print &ui_form_end([ [ "create", $text{'create'} ] ]);
|
||||
|
||||
@@ -148,14 +148,8 @@ foreach $s (@_) {
|
||||
$up = $ups[$i];
|
||||
$h = $remotes[$i];
|
||||
$h = $text{'index_local'} if ($h eq '*');
|
||||
push(@icons, "<img src=images/".
|
||||
($up == 1 ? "up.gif" :
|
||||
$up == -1 ? "not.gif" :
|
||||
$up == -2 ? "webmin.gif" :
|
||||
$up == -3 ? "timed.gif" :
|
||||
$up == -4 ? "skip.gif" :
|
||||
"down.gif").
|
||||
" title='".&html_escape($h)."'>");
|
||||
push(@icons, "<img src=".&get_status_icon($up).
|
||||
" title='".&html_escape($h)."'>");
|
||||
}
|
||||
push(@cols, join("", @icons));
|
||||
}
|
||||
|
||||
@@ -126,6 +126,13 @@ mon_members=$1 members
|
||||
mon_enoremote=No hosts or groups to run on selected
|
||||
mon_tmpl=Template for messages
|
||||
mon_notmpl=None (use Webmin defaults)
|
||||
mon_header4=Status history
|
||||
mon_hwhen=Check date
|
||||
mon_hold=Old status
|
||||
mon_hnew=New status
|
||||
mon_hvalue=Value
|
||||
mon_changes0=Show all history
|
||||
mon_changes1=Show only changes
|
||||
|
||||
sched_title=Scheduled Monitoring
|
||||
sched_header=Scheduled background monitoring options
|
||||
|
||||
@@ -547,7 +547,7 @@ sub list_history
|
||||
{
|
||||
local ($serv, $max) = @_;
|
||||
local $hfile = "$history_dir/$serv->{'id'}";
|
||||
return ( ) if (!-r $hfield);
|
||||
return ( ) if (!-r $hfile);
|
||||
if ($max) {
|
||||
open(HFILE, "tail -".quotemeta($max)." ".quotemeta($hfile)." |");
|
||||
}
|
||||
@@ -558,8 +558,11 @@ local @rv;
|
||||
while(my $line = <HFILE>) {
|
||||
$line =~ s/\r|\n//g;
|
||||
my %h = map { split(/=/, $_, 2) } split(/\t+/, $line);
|
||||
push(@rv, \%h);
|
||||
if ($h{'time'}) {
|
||||
push(@rv, \%h);
|
||||
}
|
||||
}
|
||||
close(HFILE);
|
||||
return @rv;
|
||||
}
|
||||
|
||||
@@ -576,5 +579,18 @@ if (!-d $history_dir) {
|
||||
&close_tempfile(HFILE);
|
||||
}
|
||||
|
||||
# get_status_icon(up)
|
||||
# Given a status code, return the image path to it
|
||||
sub get_status_icon
|
||||
{
|
||||
local ($up) = @_;
|
||||
return "images/".($up == 1 ? "up.gif" :
|
||||
$up == -1 ? "not.gif" :
|
||||
$up == -2 ? "webmin.gif" :
|
||||
$up == -3 ? "timed.gif" :
|
||||
$up == -4 ? "skip.gif" :
|
||||
"down.gif");
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user