Skip to content

Commit df202de

Browse files
authored
Merge pull request #12 from statusengine/elastic
Elasticesearch support for Performance Data
2 parents 7b6008e + a68b623 commit df202de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2204
-67
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
vendor/
44
etc/config.yml
55
.idea/
6+
composer.lock

etc/config.yml.example

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,30 @@ graphite_allow_self_signed_certificates: 0
167167
# Every characters in the key which not match the given regex
168168
# will be replace with an underscore _
169169
graphite_illegal_characters: /[^a-zA-Z^0-9\-\.]/
170+
171+
############
172+
# ELASTICSEARCH CONFIGURATION
173+
############
174+
175+
# Index that will be used to store data in Elasticsearch
176+
elasticsearch_index: statusengine-metric-
177+
178+
# The value of elasticsearch_pattern will be added to the end of your
179+
# defiend elasticsearch_index. It is recommended to terminate
180+
# your elasticsearch_index with an dash, like the example
181+
# index: statusengine-metric-
182+
#
183+
# Available patterns:
184+
# - none => All data in one index, this will also disable deletion of old records!
185+
# - daily => statusengine-metric-YYYY.MM.DD
186+
# - weekly => statusengine-metric-GGGG.WW
187+
# - monthly => statusengine-metric-YYYY.MM
188+
# It is important, that you pick the same pattern, as you use for Statusengine Worker!
189+
elasticsearch_pattern: daily
190+
191+
# Set the ip address or hostname for your Elasticsearch system or cluster
192+
# Statusengine will use the HTTP API
193+
elasticsearch_address: 127.0.0.1
194+
195+
# Port where your Elasticsearch server is listening to
196+
elasticsearch_port: 9200

public/api/index.php

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@
130130
*/
131131
$app->get('/', function (Request $request, Response $response) {
132132
$StorageBackend = $this->get('StorageBackend');
133+
$params = $request->getQueryParams();
134+
$DashboardQueryOptions = new \Statusengine\ValueObjects\DashboardQueryOptions($params);
133135
$DashboardController = new \Statusengine\Controller\Dashboard(
134136
$StorageBackend->getDashboardLoader()
135137
);
136-
$data = $DashboardController->index();
138+
$data = $DashboardController->index($DashboardQueryOptions);
137139

138140
return $response->withJson($data);
139141
});
@@ -684,4 +686,61 @@
684686

685687
});
686688

689+
/**
690+
* Parameters:
691+
* object_type string (host/service)
692+
* hostname__like string
693+
* servicedescription__like string
694+
* limit int
695+
* offset int
696+
* entry_time__lt < timestamp
697+
* entry_time__gt > timestamp
698+
*/
699+
$app->get('/acknowledgements', function (Request $request, Response $response) {
700+
$StorageBackend = $this->get('StorageBackend');
701+
$params = $request->getQueryParams();
702+
703+
$QueryOptions = new \Statusengine\ValueObjects\AcknowledgementQueryOptions($params);
704+
705+
if ($QueryOptions->isHostRequest()) {
706+
$AcknowledgementController = new \Statusengine\Controller\HostAcknowledgement(
707+
$StorageBackend->getHostAcknowledgementLoader()
708+
);
709+
710+
$data = $AcknowledgementController->getCurrentAcknowledgements(
711+
new \Statusengine\ValueObjects\HostAcknowledgementQueryOptions($params)
712+
);
713+
return $response->withJson($data);
714+
715+
}
716+
717+
$AcknowledgementController = new \Statusengine\Controller\ServiceAcknowledgement(
718+
$StorageBackend->getServiceAcknowledgementLoader()
719+
);
720+
721+
$data = $AcknowledgementController->getCurrentAcknowledgements(
722+
new \Statusengine\ValueObjects\ServiceAcknowledgementQueryOptions($params)
723+
);
724+
return $response->withJson($data);
725+
});
726+
727+
/**
728+
* will always return 0 for hosts up and services ok!
729+
* Parameters:
730+
* hide_ack_and_downtime (string true/false)
731+
*/
732+
$app->get('/menustats', function (Request $request, Response $response) {
733+
$StorageBackend = $this->get('StorageBackend');
734+
$params = $request->getQueryParams();
735+
$DashboardQueryOptions = new \Statusengine\ValueObjects\DashboardQueryOptions($params);
736+
$DashboardQueryOptions->setHostStates([1,2]); //DO NET PASS ARGUMENTS FROM $_GET OR $_POST!!!
737+
$DashboardQueryOptions->setServiceStates([1,2,3]);//DO NET PASS ARGUMENTS FROM $_GET OR $_POST!!!
738+
$DashboardController = new \Statusengine\Controller\Dashboard(
739+
$StorageBackend->getDashboardLoader()
740+
);
741+
$data = $DashboardController->menuStats($DashboardQueryOptions);
742+
743+
return $response->withJson($data);
744+
});
745+
687746
$app->run();

public/css/app.css

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
text-align: center;
1313
}
1414

15+
.padding-top-10 {
16+
padding-top: 10px;
17+
}
18+
1519
.small-box:hover .icon {
1620
font-size: 90px;
1721
}
@@ -234,3 +238,52 @@
234238
color: #fff !important;
235239
background-color: #3c8dbc !important;
236240
}
241+
242+
.margin-bottom-5 {
243+
margin-bottom: 5px;
244+
}
245+
246+
/* Overwrite AdminLTE styles */
247+
248+
.sidebar-mini.sidebar-collapse:not(.sidebar-mini-expand-feature) .sidebar-menu > li:hover > a > span:not(.pull-right), .sidebar-mini.sidebar-collapse:not(.sidebar-mini-expand-feature) .sidebar-menu > li:hover > .treeview-menu {
249+
display: block !important;
250+
position: absolute;
251+
width: 180px;
252+
left: 50px;
253+
}
254+
255+
.sidebar-mini.sidebar-collapse:not(.sidebar-mini-expand-feature) .sidebar-menu > li:hover > a > .pull-right-container {
256+
position: relative !important;
257+
float: right;
258+
width: auto !important;
259+
left: 180px !important;
260+
top: -25px !important;
261+
z-index: 900;
262+
}
263+
264+
.sidebar-mini.sidebar-collapse:not(.sidebar-mini-expand-feature) .sidebar-menu > li:hover > a > span {
265+
top: 0;
266+
margin-left: -3px;
267+
padding: 12px 5px 12px 20px;
268+
background-color: inherit;
269+
}
270+
271+
.sidebar-mini.sidebar-collapse .sidebar-menu > li:not(.treeview) > a > span {
272+
border-bottom-right-radius: 4px;
273+
}
274+
275+
.sidebar-mini.sidebar-collapse .main-sidebar .user-panel > .info, .sidebar-mini.sidebar-collapse .sidebar-form, .sidebar-mini.sidebar-collapse .sidebar-menu > li > a > span, .sidebar-mini.sidebar-collapse .sidebar-menu > li > .treeview-menu, .sidebar-mini.sidebar-collapse .sidebar-menu > li > a > .pull-right, .sidebar-mini.sidebar-collapse .sidebar-menu li.header {
276+
display: none !important;
277+
-webkit-transform: translateZ(0);
278+
}
279+
280+
.sidebar-menu li > a > .pull-right-container {
281+
position: absolute;
282+
right: 10px;
283+
top: 50%;
284+
margin-top: -7px;
285+
}
286+
287+
.sidebar-mini.sidebar-collapse:not(.sidebar-mini-expand-feature) .sidebar-menu > li:hover > a > .pull-right-container > .label:not(:first-of-type) {
288+
display: none;
289+
}

public/index.html

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<script type="text/javascript" src="js/scripts/controllers/ServiceAcknowledgementsController.js"></script>
8989
<script type="text/javascript" src="js/scripts/controllers/ServiceNotificationsController.js"></script>
9090
<script type="text/javascript" src="js/scripts/controllers/ScheduledDowntimesController.js"></script>
91-
91+
<script type="text/javascript" src="js/scripts/controllers/AcknowledgementsController.js"></script>
9292

9393
<!-- Model Controllers -->
9494
<script type="text/javascript" src="js/scripts/controllers/SubmitPassiveHostCheckController.js"></script>
@@ -101,6 +101,7 @@
101101
<script type="text/javascript" src="js/scripts/controllers/SubmitServiceDowntimeController.js"></script>
102102
<script type="text/javascript" src="js/scripts/controllers/SubmitServiceAcknowledgementController.js"></script>
103103

104+
104105
<script type="text/javascript" src="js/scripts/directives/NodesearchDirective.js"></script>
105106
<script type="text/javascript" src="js/scripts/directives/GlobalproblemDirective.js"></script>
106107
<script type="text/javascript" src="js/scripts/directives/HoststatusPillDirective.js"></script>
@@ -111,6 +112,7 @@
111112

112113
<script type="text/javascript" src="bower_components/chart.js/dist/Chart.min.js"></script>
113114
<script type="text/javascript" src="bower_components/noty/js/noty/packaged/jquery.noty.packaged.min.js"></script>
115+
<script type="text/javascript" src="js/noty_themes/metroui_adminlte.js"></script>
114116

115117
<script type="text/javascript" src="js/collaps.js"></script>
116118

@@ -178,7 +180,12 @@
178180

179181
<!-- sidebar menu: : style can be found in sidebar.less -->
180182
<ul class="sidebar-menu">
181-
<li class="header">Navigation</li>
183+
<li class="header">
184+
Navigation
185+
<span class="pull-right">
186+
<i class="fa fa-refresh fa-spin" id="menustatsRefresh" style="display:none;"></i>
187+
</span>
188+
</li>
182189
<li class="treeview" ui-sref-active="active">
183190
<a ui-sref="dashboard">
184191
<i class="fa fa-dashboard text-primary"></i> <span>Dashboard</span>
@@ -188,25 +195,63 @@
188195
<li class="treeview" ui-sref-active="active">
189196
<a ui-sref="nodes">
190197
<i class="fa fa-hdd-o text-primary"></i> <span> Nodes</span>
198+
<span class="pull-right-container">
199+
<small class="label pull-right bg-primary"
200+
ng-show="data.hoststatus_overview.unreachable > 0">
201+
{{ data.hoststatus_overview.unreachable }}
202+
</small>
203+
<small class="label pull-right bg-red" ng-show="data.hoststatus_overview.down > 0">
204+
{{ data.hoststatus_overview.down }}
205+
</small>
206+
</span>
191207
</a>
192208
</li>
193209

194210

195211
<li class="treeview" ui-sref-active="active">
196212
<a ui-sref="services">
197213
<i class="fa fa-cog text-primary"></i> <span> Services</span>
214+
<span class="pull-right-container">
215+
<small class="label pull-right bg-primary"
216+
ng-show="data.servicestatus_overview.unknown > 0">
217+
{{ data.servicestatus_overview.unknown }}
218+
</small>
219+
<small class="label pull-right bg-red" ng-show="data.servicestatus_overview.critical > 0">
220+
{{ data.servicestatus_overview.critical }}
221+
</small>
222+
<small class="label pull-right bg-yellow" ng-show="data.servicestatus_overview.warning > 0">
223+
{{ data.servicestatus_overview.warning }}
224+
</small>
225+
</span>
198226
</a>
199227
</li>
200228

201229
<li class="treeview" ui-sref-active="active">
202230
<a ui-sref="problems">
203231
<i class="fa fa-exclamation-triangle text-primary"></i> <span> Issues</span>
232+
<span class="pull-right-container">
233+
<small class="label pull-right bg-purple" ng-show="data.number_of_service_problems > 0">
234+
{{ data.number_of_service_problems }}
235+
</small>
236+
</span>
204237
</a>
205238
</li>
206239

207240
<li class="treeview" ui-sref-active="active">
208241
<a ui-sref="scheduleddowntimes">
209242
<i class="fa fa-plug text-primary"></i> <span> Upcoming downtimes</span>
243+
<small class="label pull-right bg-purple" ng-show="downtimes > 0">
244+
{{ downtimes }}
245+
</small>
246+
</a>
247+
</li>
248+
249+
<li class="treeview" ui-sref-active="active">
250+
<a ui-sref="acknowledgements">
251+
<i class="fa fa-commenting-o text-primary"></i> <span> Acknowledgements</span>
252+
<small class="label pull-right bg-purple" ng-show="acknowledgements > 0">
253+
{{ acknowledgements }}
254+
</small>
210255
</a>
211256
</li>
212257

@@ -258,14 +303,14 @@ <h4 class="modal-title text-center">
258303
<div class="modal-body">
259304
<p>Lost connection to API...</p>
260305
<p>Typically this is due to one of the following reasons:</p>
261-
<p>
306+
<div>
262307
<ul>
263308
<li>Your device lost network connection</li>
264309
<li>You're disconnected from the internet</li>
265310
<li>Statusengine API backend is not running</li>
266311
<li>You're Sysadmin is playing around</li>
267312
</ul>
268-
</p>
313+
</div>
269314
<p>Please try to reload the page to solve the issue.</p>
270315
</div>
271316
<div class="modal-footer">

0 commit comments

Comments
 (0)