-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add monitors support Added support for Docker Up and Docker Container Up monitor Cleaned up Dockerfile for DIND rootless Minor cleanup
- Loading branch information
Showing
6 changed files
with
125 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/perl | ||
use WebminCore; | ||
|
||
do 'docker-lib.pl'; | ||
|
||
# status_monitor_list() | ||
# Return a list of supported monitor types | ||
sub status_monitor_list | ||
{ | ||
return ( [ "docker_up", "Docker Up"], [ "docker_containerup", "Docker Container Up"], ); | ||
} | ||
|
||
# status_monitor_status(type, &monitor, from-ui) | ||
# Check the docker or container status | ||
sub status_monitor_status | ||
{ | ||
my ($type, $monitor, $fromui) = @_; | ||
|
||
# Basic status check via running docker info and checking return | ||
# This gets around the various ways docker can be run (supervisor, systemctl etc) | ||
if ($type eq "docker_up") { | ||
my ($status, $result) = &get_status(); | ||
return { | ||
'up' => $status == 0 ? 1 : 0, | ||
"desc" => $status != 0 ? $result : '' | ||
}; | ||
} elsif ($type eq "docker_containerup") { | ||
$container = $monitor->{'docker_container'}; | ||
|
||
my ($status, $result) = &get_container_attr($container, "State.Status"); | ||
|
||
my $ok = $status == 0 && $result == "running" ? 1 : 0; | ||
return { | ||
'up' => $ok, | ||
'desc' => ucfirst($result) | ||
}; | ||
} | ||
return { 'up' => -1, | ||
'desc' => $text{'monitor_notype'} }; | ||
} | ||
|
||
# status_monitor_dialog(type, &monitor) | ||
# Return form for configuring monitors | ||
sub status_monitor_dialog | ||
{ | ||
my ($type, $mon) = @_; | ||
|
||
if ($type eq "docker_up") { | ||
# Nada | ||
} elsif ($type eq "docker_containerup") { | ||
return &ui_table_row("Container", # $text{'monitor_container'}, | ||
&ui_textbox("docker_container", html_escape($mon->{'docker_container'}), 50) | ||
); | ||
} else { | ||
return undef; | ||
} | ||
} | ||
|
||
# status_monitor_parse(type, &monitor, &in) | ||
# Parse form for selecting a rule | ||
sub status_monitor_parse | ||
{ | ||
my ($type, $mon, $in) = @_; | ||
if ($type eq "docker_up") { | ||
# Nada | ||
} elsif ($type eq "docker_containerup") { | ||
$mon->{'docker_container'} = $in->{'docker_container'}; | ||
} | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters