Skip to content

Commit

Permalink
Merge branch 'integ' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Subiron committed Dec 2, 2019
2 parents eb42b24 + 1d3b11d commit 0cce606
Show file tree
Hide file tree
Showing 142 changed files with 10,010 additions and 1,838 deletions.
55 changes: 53 additions & 2 deletions etc/alignak.d/alignak-module-webui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ python_name=alignak_webui
;log_level=INFO
# Set log_color=1 to have a (colored) log on the console
;log_console=0
# Declare the log file for the Shinken Web UI log (default is /var/log/alignak/shinken-webui.log)
;log_file=/var/log/alignak/shinken-webui.log
# Declare the log file for the Shinken Web UI log (default is /var/log/alignak/alignak-webui.log)
; If the configured and/or default log file is not allowed, the UI will log to /tmp/alignak-webui.log
;log_file=/var/log/alignak/alignak-webui.log

# Export module metrics to a statsd server.
# By default at localhost:8125 (UDP) with the alignak prefix
Expand All @@ -26,6 +27,18 @@ python_name=alignak_webui
# Default is not enabled
;statsd_enabled=0

## Alignak configuration
# Define the Alignak arbiter API endppont
;alignak_endpoint = http://127.0.0.1:7770

# The webUI will get the Alignak livestate every alignak_check_period seconds
;alignak_check_period = 10

# The WebUI will store internally an events log queue limited to alignak_events_count items
# If ALIGNAK_EVENTS_LOG_COUNT environment variable is set it will take precedence
;alignak_events_count = 1000


## Modules for WebUI
## User authentication:
# - auth-cfg-password (internal) : Use the password set in Shinken contact for auth.
Expand Down Expand Up @@ -80,8 +93,46 @@ python_name=alignak_webui
;username=
;password=

# Groups plugin configuration
# ---
# Allow to hide empty groups
plugin.hostgroups.hide_empty = 1
plugin.servicegroups.hide_empty = 1


# Logs collection from a MongoDB database
# ---
# Logs collection name
# -- For Shinken mongo-logs module logs
;logs_collection=logs
# -- For Alignak logstash parser
logs_collection=alignak_events
# -- For Alignak backend module
;logs_collection=history

# Configure the date format for date range searching
# -- For Shinken mongo-logs module logs (default configuration)
;plugin.logs.date_format=timestamp
# -- For Alignak logstash parser, usual datetime
plugin.logs.date_format=datetime
# -- For Alignak backend module, usual datetime
;plugin.logs.date_format=datetime

# Configure the name of the collected and displayed fields
# -- For Shinken mongo-logs module logs (default configuration)
;plugin.logs.time_field=times
;plugin.logs.other_fields=message
;plugin.logs.types='INFO', 'WARNING', 'ERROR'

# -- For Alignak logstash parser
plugin.logs.time_field=@timestamp
plugin.logs.other_fields=alignak.event,alignak.host_name,alignak.service,alignak.state,alignak.state_type,alignak.message
plugin.logs.types=

# -- For Alignak backend module
;plugin.logs.time_field=_created
;plugin.logs.other_fields=type,host_name,service_name,user_name,message
;plugin.logs.types=

# Hosts availability collection name
;hav_collection=availability
Expand Down
17 changes: 14 additions & 3 deletions etc/modules/webui2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ define module {
# Set log_backup_count to the number of days to keep log files (default is 7 days)
log_backup_count 7

# Groups plugin configuration
# ---
# Allow to hide empty groups
#plugin.hostgroups.hide_empty 1
#plugin.servicegroups.hide_empty 1


## Modules for WebUI
## User authentication:
# - auth-cfg-password (internal) : Use the password set in Shinken contact for auth.
Expand Down Expand Up @@ -241,11 +248,11 @@ define module {
# If not, the comment will be deleted the next time Shinken restarts.
# -----
# the acknowledgement will remain until the host returns to an UP state. Otherwise the acknowledgement will automatically be removed when the host changes state.
#default_ack_sticky=2
#default_ack_sticky 2
# a notification will be sent out to contacts indicating that the current host/service problem has been acknowledged.
#default_ack_notify=1
#default_ack_notify 1
# the comment associated with the acknowledgement will survive across restarts.
#default_ack_persistent=1
#default_ack_persistent 1

## Advanced Options for Bottle Web Server
# Best choice is auto, whereas Bottle chooses the best server it finds amongst:
Expand Down Expand Up @@ -278,4 +285,8 @@ define module {
; Set to the HTTP header containing
; the authentificated user s name, which
; must be a Shinken contact.

# Stats configuration
#stats_command_name_filter notify-service-by-slack # default empty
#stats_contact_name_filter admin # default empty
}
11 changes: 7 additions & 4 deletions module/datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get_hosts(self, user=None):

def get_important_hosts(self, user=None):
return self.search_hosts_and_services(
'type:host bi:>%d' % self.important_problems_business_impact,
'type:host bi:>=%d' % self.important_problems_business_impact,
user
)

Expand Down Expand Up @@ -211,7 +211,7 @@ def get_services(self, user=None):

def get_important_services(self, user=None):
return self.search_hosts_and_services(
'type:service bi:>%d' % self.important_problems_business_impact,
'type:service bi:>=%d' % self.important_problems_business_impact,
user
)

Expand Down Expand Up @@ -529,9 +529,12 @@ def search_hosts_and_services(self, search, user, sorter=None):
except ValueError:
items = []

if t == 'duration':
if t in ['duration', 'last_check']:
seconds_per_unit = {"s": 1, "m": 60, "h": 3600, "d": 86400, "w": 604800}
times = [(i, time.time() - int(i.last_state_change)) for i in items]
if t == 'duration':
times = [(i, time.time() - int(i.last_state_change)) for i in items]
else:
times = [(i, time.time() - int(i.last_chk)) for i in items]
try:
if s.startswith('>='):
s = int(s[2:-1]) * seconds_per_unit[s[-1].lower()]
Expand Down
Loading

0 comments on commit 0cce606

Please sign in to comment.