-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6718d90
commit 7c5f2de
Showing
7 changed files
with
121 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Testing "Performance log stream" | ||
|
||
## Workstation/server | ||
|
||
Setting `tool_heartbeat | logstream` to both a file path, eg `/tmp/perf.log' or a syslog url, eg `syslog://local0/TEST` or just `syslog://local0/` should just work. | ||
|
||
## Docker container | ||
|
||
I test with standard `php:[Maj].[Min].-cli` base, running the ap as `php -S 0.0.0.0:80`. That should not matter, but just for the reference. | ||
|
||
Whatever your way is, Setting `tool_heartbeat | logstream` to a file path should just work. Of course, if the destination is not mounted you'll need to get into the container and check the file. | ||
|
||
### Syslog | ||
|
||
To get syslog to work, I did following: | ||
|
||
* Installer `rsyslog` in the image: `Dockerfile: apt-get install rsyslog` | ||
* mounted host's `/dev/log`: `docker run ... -v /dev/log:/dev/log ...` | ||
|
||
That makes container's syslog going straight to your workstation's syslog, so you can check your `/var/log/syslog`. |
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,66 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
/** | ||
* Auth method health check. | ||
* | ||
* @package tool_heartbeat | ||
* @author Srdjan Janković <[email protected]> | ||
* @copyright Catalyst IT | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* | ||
* This can be run either as a web api, or on the CLI. When run on the | ||
* CLI it conforms to the Nagios plugin standard. | ||
* | ||
* See also: | ||
* - http://nagios.sourceforge.net/docs/3_0/pluginapi.html | ||
* - https://nagios-plugins.org/doc/guidelines.html#PLUGOUTPUT | ||
*/ | ||
|
||
namespace tool_heartbeat\check; | ||
|
||
use core\check\check; | ||
use core\check\result; | ||
|
||
use tool_heartbeat\logger; | ||
use Exception; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
class logcheck extends check { | ||
|
||
public function get_action_link(): ?\action_link { | ||
$url = new \moodle_url('/admin/tool/heartbeat/settings.php', ['section' => 'log']); | ||
return new \action_link($url, get_string('logstream', 'tool_heartbeat')); | ||
} | ||
|
||
public function get_result() : result { | ||
if ($logstream = get_config('tool_heartbeat', 'logstream')) { | ||
try { | ||
logger::log_to_stream(, ['check']); | ||
$status = result::OK; | ||
$summary = ''; | ||
} catch (Exception $e) { | ||
$status = result::WARNING; | ||
$summary = get_string('logstreamerror', 'tool_heartbeat', "$logstream ".$e->getMessage()); | ||
} | ||
} else { | ||
$status = result::WARNING; | ||
$summary = get_string('logstreamnotset', 'tool_heartbeat'); | ||
} | ||
|
||
return new result($status, $summary); | ||
} | ||
} |
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