Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
monitoring
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
monitoring
Commits
8ebf97b3
Commit
8ebf97b3
authored
2 months ago
by
Tibo
Browse files
Options
Downloads
Patches
Plain Diff
implement job throttling
parent
7bc61949
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#19722
passed
2 months ago
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/AgentScheduler.php
+11
-1
11 additions, 1 deletion
app/AgentScheduler.php
resources/views/status.blade.php
+23
-1
23 additions, 1 deletion
resources/views/status.blade.php
with
34 additions
and
2 deletions
app/AgentScheduler.php
+
11
−
1
View file @
8ebf97b3
...
@@ -3,12 +3,13 @@
...
@@ -3,12 +3,13 @@
namespace
App
;
namespace
App
;
use
App\Jobs\RunAgent
;
use
App\Jobs\RunAgent
;
use
App\Server
;
use
App\Sensor\StatusChangeDetector
;
use
App\Sensor\StatusChangeDetector
;
use
Illuminate\Support\Facades\File
;
use
Illuminate\Support\Facades\File
;
use
Illuminate\Support\LazyCollection
;
use
Illuminate\Support\LazyCollection
;
use
Illuminate\Support\Collection
;
use
Illuminate\Support\Collection
;
use
Illuminate\Support\Facades\Queue
;
use
Symfony\Component\Finder\SplFileInfo
;
use
Symfony\Component\Finder\SplFileInfo
;
/**
/**
...
@@ -110,10 +111,19 @@ class AgentScheduler
...
@@ -110,10 +111,19 @@ class AgentScheduler
})
->
toArray
();
})
->
toArray
();
}
}
public
function
throttlingTreshold
()
:
int
{
return
max
(
2
,
Server
::
count
())
*
2
*
$this
->
sensors
()
->
count
();
}
// ------------------ SCHEDULING of agents
// ------------------ SCHEDULING of agents
public
function
notify
(
Record
$record
)
public
function
notify
(
Record
$record
)
{
{
if
(
Queue
::
size
()
>
$this
->
throttlingTreshold
())
{
return
;
}
$trigger_label
=
$record
->
label
;
$trigger_label
=
$record
->
label
;
if
(
!
isset
(
$this
->
triggers
[
$trigger_label
]))
{
if
(
!
isset
(
$this
->
triggers
[
$trigger_label
]))
{
...
...
This diff is collapsed.
Click to expand it.
resources/views/status.blade.php
+
23
−
1
View file @
8ebf97b3
@
extends
(
'layouts.app'
)
@
extends
(
'layouts.app'
)
@
php
$scheduler
=
\App\AgentScheduler
::
get
();
@
endphp
@
section
(
'title'
,
'Status'
)
@
section
(
'title'
,
'Status'
)
@
section
(
'content'
)
@
section
(
'content'
)
...
@@ -7,11 +11,29 @@
...
@@ -7,11 +11,29 @@
<
h1
>
Status
</
h1
>
<
h1
>
Status
</
h1
>
<
h2
>
Jobs
</
h2
>
<
h2
>
Jobs
</
h2
>
<
p
>
Jobs
in
queue
:
{{
Queue
::
size
()
}}
</
p
>
<
p
>
Analysis
jobs
in
queue
:
{{
Queue
::
size
()
}}
</
p
>
<
p
>
Throttling
threshold
:
{{
$scheduler
->
throttlingTreshold
()
}}
</
p
>
<
p
class
=
"text-muted"
>
<
i
class
=
"fas fa-question-circle"
></
i
>
When
queue
size
reaches
threshold
,
any
new
analysis
job
will
be
discarded
until
the
queue
size
falls
below
threshold
.
</
p
>
<
h2
>
Database
</
h2
>
<
h2
>
Database
</
h2
>
<
p
>
Servers
:
{{
\App\Server
::
count
()
}}
</
p
>
<
p
>
Servers
:
{{
\App\Server
::
count
()
}}
</
p
>
<
p
>
Records
:
{{
\App\Record
::
count
()
}}
</
p
>
<
p
>
Records
:
{{
\App\Record
::
count
()
}}
</
p
>
<
p
>
Reports
:
{{
\App\Report
::
count
()
}}
</
p
>
<
p
>
Reports
:
{{
\App\Report
::
count
()
}}
</
p
>
<
h2
>
Agents
</
h2
>
<
p
>
Autodiscovered
<
b
>
{{
$scheduler
->
sensors
()
->
count
()
}}
</
b
>
analysis
agents
</
p
>
<
table
class
=
"table table-sm"
>
@
foreach
(
$scheduler
->
sensors
()
as
$sensor
)
<
tr
>
<
td
>
{{
get_class
(
$sensor
)
}}
</
td
>
</
tr
>
@
endforeach
</
table
>
</
div
>
</
div
>
@
endsection
@
endsection
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment