Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adagios-2.0.2-1 #671

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/gunicorn.py
*.pyc
*.swp
.project
Expand Down Expand Up @@ -139,4 +140,4 @@ dmypy.json
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
.ionide
8 changes: 5 additions & 3 deletions adagios/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
#
# This program 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 Affero General Public License for more details.
#
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -91,7 +91,9 @@ def on_page_load(request):

def update_global_variables():
"""Updates all required global variables."""
pynag.Model.cfg_file = adagios.settings.nagios_config
if pynag.Model.cfg_file != adagios.settings.nagios_config:
pynag.Model.cfg_file = adagios.settings.nagios_config
Model.ObjectDefinition.objects.reload_cache()


def get_current_time(request):
Expand Down
21 changes: 8 additions & 13 deletions adagios/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
#
# This program 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 Affero General Public License for more details.
#
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

Expand All @@ -22,16 +22,11 @@

class Daemon(daemon):
def __init__(self):
super(Daemon, self).__init__()

# Mapping needed
if settings.nagios_binary:
self.nagios_bin = settings.nagios_binary
if settings.nagios_config:
self.nagios_cfg = settings.nagios_config
if settings.nagios_init_script:
self.nagios_init = settings.nagios_init_script
if settings.nagios_service:
self.service_name = settings.nagios_service
super().__init__(
nagios_bin=settings.nagios_binary,
nagios_cfg=settings.nagios_config,
nagios_init=settings.nagios_init_script,
service_name=settings.nagios_service,
)

# vim: sts=4 expandtab autoindent
1 change: 0 additions & 1 deletion adagios/etc/adagios/adagios.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# If set, adagios will use this file to manage your object
# definitions. If set to None, adagios will search most common
# paths like /etc/nagios/nagios.cfg for it
#nagios_config = "/etc/nagios/nagios.cfg"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is change required? Note the idea of having this commented out by default is for adagios to attempt to discover location of nagios.cfg in common locations and now that functionality becomes broken for default installs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes maybe best to have this commented out by default. I will change this.

nagios_config = "/etc/nagios/nagios.cfg"

# This should be the URL to your nagios server. If set, then
Expand Down
116 changes: 116 additions & 0 deletions adagios/etc/adagios/adagios_naemon.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look at the diff between adagios.conf and adagios_naemon.conf but are they significant?

I'm wondering what it would take to support naemon out of the box without having to fork the config file completely (this causes technical debt long term having to keep both config files in sync).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, best solution would be to support Naemon out of the box. I will look further into that.


# nagios_config - Path to your nagios configuration file
# If set, adagios will use this file to manage your object
# definitions. If set to None, adagios will search most common
# paths like /etc/nagios/nagios.cfg for it
nagios_config = "/etc/naemon/naemon.cfg"

# This should be the URL to your nagios server. If set, then
# Adagios can link you directly from configuration to live object.
# If you don't need this feature. Set nagios_url to '' or None
# nagios_url = "/thruk"
# Thruk - All Unhandled Problems
nagios_url = "/thruk/#cgi-bin/status.cgi?style=combined&hst_s0_hoststatustypes=4&hst_s0_servicestatustypes=31&hst_s0_hostprops=10&hst_s0_serviceprops=0&svc_s0_hoststatustypes=3&svc_s0_servicestatustypes=28&svc_s0_hostprops=10&svc_s0_serviceprops=10&svc_s0_hostprop=2&svc_s0_hostprop=8&title=All Unhandled Problems"

# destination_directory - Where adagios will store new objects
# by default. You should make sure that this directory exists
# and nagios.cfg has a cfg_dir=/etc/nagios/adagios/
destination_directory = "/etc/naemon/adagios/"

# livestatus_path - Path to livestatus socket
livestatus_path = None
# enable_githandler - If set to true, and your /etc/nagios/ directory
# is a git repository. adagios will automatically commit changes when
# they are made.
enable_githandler = True

# enable_loghandler - If set to true, all changes adagios makes to
# object definitions will be logged to a file.
enable_loghandler = False

# auto_reload - If set to True, then nagios is reloaded automatically on
# changes. Not really recommended unless you are sure you want to fire
# a nagios reload after every single change.
auto_reload = False

# nagios_service - Service name used to start/stop nagios
# Adagios uses this to reload nagios after configuration changes
nagios_service = "naemon"

# nagios_init_script - Path to init script used to start/stop nagios
# Adagios uses this to reload nagios after configuration changes
nagios_init_script=""

# nagios_binary - Path to your nagios binary
# Adagios uses this to run "nagios -v /etc/nagios/nagios.cfg"
nagios_binary="/usr/bin/naemon"


# escape_html_tags - Escape html tags in status view
# If this is enabled, html code in plugin outputs is escaped.
# If you set this to False, then plugins will be able to inject
# HTML code into adagios web interface
escape_html_tags = True

# warn_if_selinux_is_active - Check (and warn user) if selinux is running
# You should only turn this off if you have configured your selinux policy
# and know what you are doing
warn_if_selinux_is_active=True


# pnp_filepath - Path to pnp4nagios index.php
# This is used for integrated graphs into the status view
# if you do not use pnp or do not need the status view of adagios
# simply change this to any other file that exists
pnp_filepath="/usr/share/nagios/html/pnp4nagios/index.php"


# contrib_dir - Path to user contributed views
contrib_dir = "/var/lib/adagios/contrib/"

# serverside_includes - Path to user contributed includes
# The files located in this directory can be used to include
# user contributed html into the header and footer of every page respectively
serverside_includes = "/etc/adagios/ssi"

# title_prefix - Title of every page is prefixed with this.
# You can customize this if you have multiple adagios instances
# and you want to distinguish the tabs in browser.
title_prefix = "Adagios -"


# enable_pnp4nagios - Enable pnp4nagios support (True by default).
# Disabling this removes the pnp mouse-over graphs as well as the graphs
# tab from the status views.
enable_pnp4nagios = True

# enable_graphite - Enable graphite integration with graphite
# If set to True, status_detail view of hosts and services
# Will show related graphs.
enable_graphite = False

# graphite_url - URL to your graphite instance
# If specified, and enable_graphite is set to True,
# connect to this graphite instance
graphite_url = "http://localhost:9091"

# graphite_querystring - Customize the querystring that is sent to
# graphite's /render? method. {host} {service} and {metric} will all
# be replaced with actual values while {host_} {service_} and {metric_}
# will apply common escaping techniques, i.e.: example.com becomes example_com
graphite_querystring = "target={host_}.{service_}.{metric_}&width=500&height=200&from={from_}d&lineMode=connected&title={title}&target={host_}.{service_}.{metric_}_warn&target={host_}.{service_}.{metric_}_crit"

# graphite_title - Put this string at the top of graphite graphs
graphite_title = "{host} - {service} - {metric}"

# A list of strings representing the host/domain names that this Django site can
# serve. This is a security measure to prevent HTTP Host header attacks
# Values in this list can be fully qualified names (e.g. www.example.com)
# A value beginning with a period can be used as a subdomain wildcard:
# '.example.com' will match example.com, www.example.com
# A value of '*' will match anything
# ALLOWED_HOSTS = ['*']

# Include configuration options from these config files
include="/etc/adagios/conf.d/*.conf"
1 change: 0 additions & 1 deletion adagios/etc/adagios/conf.d/okconfig.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Activate the okconfig plugin, but only if okconfig python module exists:
try:
import okconfig
#plugins['okconfig'] = 'adagios.okconfig_'
plugins['okconfig'] = 'okconfig_'
except ImportError:
pass
Expand Down
3 changes: 3 additions & 0 deletions adagios/etc/sudoers.d/adagios_naemon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Defaults:%naemon !requiretty
%naemon ALL = (root) NOPASSWD: /sbin/service naemon *
%naemon ALL = (root) NOPASSWD: /usr/bin/naemon -v /etc/naemon/naemon.cfg
5 changes: 2 additions & 3 deletions adagios/media/js/adagios.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ $.extend $.fn.dataTableExt.oStdClasses,
$this = $(this)

current_version = $('#current_version').text()
$.getJSON("https://opensource.ok.is/cgi-bin/version.cgi?version=#{current_version}&callback=?", (data) ->
$.getJSON("https://api.github.com/repos/opinkerfi/adagios/releases/latest", (data) ->
this
).success( (data) ->
$this.text data['version']
$('a#version_info').attr 'href', data['link']
$this.text data['tag_name']
)
this

Expand Down
8 changes: 3 additions & 5 deletions adagios/media/js/adagios.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,12 @@ Generated by coffee-script, any changes should be made to the adagios.coffee fil
return false;
});
$.fn.adagios_version = function() {
var $this, current_version;
var $this
$this = $(this);
current_version = $('#current_version').text();
$.getJSON("https://opensource.ok.is/cgi-bin/version.cgi?version=" + current_version + "&callback=?", function(data) {
$.getJSON("https://api.github.com/repos/opinkerfi/adagios/releases/latest", function(data) {
return this;
}).success(function(data) {
$this.text(data['version']);
return $('a#version_info').attr('href', data['link']);
$this.text(data['tag_name']);
});
return this;
};
Expand Down
6 changes: 3 additions & 3 deletions contrib/apache_gunicorn_adagios.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Alias /media /opt/adagios/adagios/media
ProxyPass !
</Location>

<Location /adagios/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the pull request with information on why this was needed?

It feels like this might cause subtle breakages for other use cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used if you run Adagios with Gunicorn and Apache. What use cases do you think will brake by using this?

<Location /adagios>
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
ProxyPass http://127.0.0.1:8001/
ProxyPassReverse http://127.0.0.1:8001/
ProxyPass http://127.0.0.1:8001
ProxyPassReverse http://127.0.0.1:8001
</Location>