ajout heimdall
This commit is contained in:
60
heimdall/config/www/SupportedApps/Cabot/Cabot.php
Executable file
60
heimdall/config/www/SupportedApps/Cabot/Cabot.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php namespace App\SupportedApps\Cabot;
|
||||
|
||||
class Cabot extends \App\SupportedApps implements \App\EnhancedApps {
|
||||
private const ENDPOINT = 'api/services/?format=json';
|
||||
|
||||
private const STATUS_PASSING = 'Passing';
|
||||
private const STATUS_WARNING = 'Warning';
|
||||
private const STATUS_ERROR = 'Error';
|
||||
private const STATUS_CRITICAL = 'Critical';
|
||||
|
||||
public $config;
|
||||
|
||||
public function test()
|
||||
{
|
||||
$test = parent::appTest($this->url(self::ENDPOINT));
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$result = parent::execute($this->url(self::ENDPOINT));
|
||||
$services = json_decode($result->getBody());
|
||||
|
||||
$results = [
|
||||
self::STATUS_PASSING => 0,
|
||||
self::STATUS_WARNING => 0,
|
||||
self::STATUS_ERROR => 0,
|
||||
self::STATUS_CRITICAL => 0,
|
||||
];
|
||||
|
||||
foreach ($services as $service) {
|
||||
$overallStatus = ucfirst(strtolower($service->overall_status ?? ''));
|
||||
|
||||
if (isset($results[$overallStatus])) {
|
||||
$results[$overallStatus]++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($results[self::STATUS_CRITICAL] > 0) {
|
||||
$status = self::STATUS_CRITICAL;
|
||||
} elseif ($results[self::STATUS_ERROR] > 0) {
|
||||
$status = self::STATUS_ERROR;
|
||||
} elseif ($results[self::STATUS_WARNING] > 0) {
|
||||
$status = self::STATUS_WARNING;
|
||||
} else {
|
||||
$status = self::STATUS_PASSING;
|
||||
}
|
||||
|
||||
$data['status_output'] = $status;
|
||||
$data['count_output'] = $results[$status];
|
||||
|
||||
return parent::getLiveStats('inactive', $data);
|
||||
}
|
||||
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url).$endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
}
|
||||
10
heimdall/config/www/SupportedApps/Cabot/app.json
Executable file
10
heimdall/config/www/SupportedApps/Cabot/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "36cf09d76e7173b82ef23504aae37c05784b0215",
|
||||
"name": "Cabot",
|
||||
"website": "https://cabotapp.com",
|
||||
"license": "MIT License",
|
||||
"description": "Self-hosted watchdog for your websites and infrastructure.",
|
||||
"enhanced": true,
|
||||
"tile_background": "light",
|
||||
"icon": "cabot.png"
|
||||
}
|
||||
BIN
heimdall/config/www/SupportedApps/Cabot/cabot.png
Executable file
BIN
heimdall/config/www/SupportedApps/Cabot/cabot.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
10
heimdall/config/www/SupportedApps/Cabot/config.blade.php
Executable file
10
heimdall/config/www/SupportedApps/Cabot/config.blade.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
|
||||
<div class="items">
|
||||
<div class="input">
|
||||
<label>{{ strtoupper(__('app.url')) }}</label>
|
||||
{!! Form::text('config[override_url]', (isset($item) ? $item->getconfig()->override_url : null), array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
6
heimdall/config/www/SupportedApps/Cabot/livestats.blade.php
Executable file
6
heimdall/config/www/SupportedApps/Cabot/livestats.blade.php
Executable file
@@ -0,0 +1,6 @@
|
||||
<ul class="livestats">
|
||||
<li>
|
||||
<span class="title">Overall Status</span>
|
||||
<strong>{!! $count_output !!} {!! $status_output !!}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user