Skip to content

Commit

Permalink
Python3 version:
Browse files Browse the repository at this point in the history
- improve scheduler daemon statistics
  • Loading branch information
mohierf committed May 18, 2018
1 parent a1b9f51 commit 9cfaede
Show file tree
Hide file tree
Showing 14 changed files with 835 additions and 275 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ script:
if [[ $TEST_SUITE == 'codingstandard' ]]; then
# Static code analysis
# -- pycodestyle (former pep8)
pycodestyle --max-line-length=100 --exclude='*.pyc,alignak/misc/carboniface.py' alignak/*
pycodestyle --max-line-length=100 --exclude='*.pyc' alignak/*
# -- pylint
unset PYTHONWARNINGS
pylint --rcfile=.pylintrc -r no alignak
Expand Down
41 changes: 38 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,49 @@ Presentation of the Alignak project
:alt: License AGPL v3


`Alignak <http://www.alignak.net>`_ is a modern monitoring framework based on Shinken.
Alignak Project
---------------

`Alignak <http://www.alignak.net>`_ is an open source monitoring framework written in Python under the terms of the `GNU Affero General Public License <http://www.gnu.org/licenses/agpl.txt>`_ .

Its main goal is to give users a flexible and complete solution for their monitoring system. Alignak is designed to scale to large environments.

Alignak is backwards-compatible with the Nagios/Shinken configuration standard and plugins. It works on any operating system and architecture that supports Python, which includes Windows (not yet), GNU/Linux and FreeBSD.
The project started in 2015 from a fork of the Shinken project. Since the project creation, we achieved a huge code documentation and cleaning, we tested the application in several environments and we developed some new features.


The main idea when developing Alignak is the flexibility which is our definition of framework. We target the following goals:

* Easy to install: we will always deliver packages (OS and Python) installation.
You can install Alignak with OS packages, Python PIP apckages or *setup.py* directly..

* Easy for new users: this documentation should help you to discover Alignak.
This documentation shows simple use-cases and helps building more complex configurations.

* Easy to migrate from Nagios: Nagios flat-files configuration and plugins will work with Alignak.
We try to keep as much as possible an ascending compatibility with former Nagios configuration...

* Multi-platform: python is available in a lot of Operating Systems.
We try to write generic code to keep this possible. However, Linux and FreeBSD are the most tested OSes so far.
As of now, Alignak is tested with Python 2.7, 3.5 and 3.6 versions but will work with Pypy in the future.

* UTF-8 compliant: whatever you language, we take care of it.
We are testing Alignak I/O with several languages and take care of localization.

* Independent from other monitoring solution:
Alignak is a framework that can integrate with other applications through standard interfaces.
Flexibility first!

* Flexible: in an architecture point of view.
Alignak may be distributed across several servers, datacenters to suit the monitoring needs and constrints.
It is our scalability wish!

* Easy to contribute: contribution has to be an easy process.
Alignak follow pycodestyle (former pep8), pylint and pep257 coding standards to ease code readability.
Step by step help to contribute to the project can be found in :ref:`Contributing <contributing/index>`

Alignak is licensed under the Gnu Affero General Public Licence version 3 (AGPLv3). Unless specified by another header, this licence applies to all the files in this repository.
This is basically what Alignak is made of. May be add the *keep it simple* Linux principle and it's perfect.

There is nothing we don't want, we consider every features / ideas. Feel free to join `by mail <mailto:contact@alignak.net>`_ or on `the IRC #alignak <http://webchat.freenode.net/?channels=%23alignak>`_ to discuss or ask for more information

Documentation
-------------
Expand Down
36 changes: 18 additions & 18 deletions alignak/daemons/arbiterdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ def get_daemon_stats(self, details=False): # pylint: disable=too-many-branches
# Get the information to be published for a satellite
res['daemons_states'][satellite.name] = satellite.give_satellite_json()

res['live_state'] = {
res['livestate'] = {
"timestamp": now,
"daemons": {}
}
Expand All @@ -1671,18 +1671,18 @@ def get_daemon_stats(self, details=False): # pylint: disable=too-many-branches
if satellite == self.link_to_myself:
continue

live_state = 0
livestate = 0
if satellite.active:
if not satellite.reachable:
live_state = 1
livestate = 1
elif not satellite.alive:
live_state = 2
state = max(state, live_state)
livestate = 2
state = max(state, livestate)
else:
live_state = 3
livestate = 3

res['live_state']['daemons'][satellite.name] = live_state
res['live_state'].update({
res['livestate']['daemons'][satellite.name] = livestate
res['livestate'].update({
"state": state,
"output": [
"all daemons are up and running.",
Expand Down Expand Up @@ -1771,16 +1771,16 @@ def push_passive_check(self, details=False):
}

# Create self arbiter service - I am now considered as a service for my Alignak monitor!
if 'live_state' in inner_stats:
live_state = inner_stats['live_state']
if 'livestate' in inner_stats:
livestate = inner_stats['livestate']
res['services'].append({
"name": inner_stats['name'],
"livestate": {
"timestamp": now,
"state": ["ok", "warning", "critical", "unknown"][live_state['state']],
"output": live_state['output'],
"long_output": live_state['long_output'] if 'long_output' in live_state else "",
"perf_data": live_state['perf_data'] if 'perf_data' in live_state else ""
"state": ["ok", "warning", "critical", "unknown"][livestate['state']],
"output": livestate['output'],
"long_output": livestate['long_output'] if 'long_output' in livestate else "",
"perf_data": livestate['perf_data'] if 'perf_data' in livestate else ""
}
})

Expand Down Expand Up @@ -1809,23 +1809,23 @@ def push_passive_check(self, details=False):
"livestate": {
"timestamp": now,
"name": "%s_%s" % (daemon['type'], daemon['name']),
"state": ["ok", "warning", "critical", "unknown"][daemon['live_state']],
"state": ["ok", "warning", "critical", "unknown"][daemon['livestate']],
"output": [
u"daemon is alive and reachable.",
u"daemon is not reachable.",
u"daemon is not alive."
][daemon['live_state']],
][daemon['livestate']],
"long_output": "Realm: %s (%s). Listening on: %s"
% (daemon['realm_name'], daemon['manage_sub_realms'],
daemon['uri']),
"perf_data": "last_check=%.2f" % daemon['last_check']
}
})
state = max(state, daemon['live_state'])
state = max(state, daemon['livestate'])
long_output.append(
"%s - %s" % (daemon_id, [u"daemon is alive and reachable.",
u"daemon is not reachable.",
u"daemon is not alive."][daemon['live_state']]))
u"daemon is not alive."][daemon['livestate']]))

res['livestate'].update({
"state": "up", # Always Up ;)
Expand Down
12 changes: 6 additions & 6 deletions alignak/daemons/brokerdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,12 @@ def get_daemon_stats(self, details=False):
res.update({'name': self.name, 'type': self.type})

counters = res['counters']
counters['external-broks'] = len(self.external_broks)
counters['internal-broks'] = len(self.internal_broks)
counters['arbiter-broks'] = len(self.arbiter_broks)
counters['pollers'] = len(self.pollers)
counters['reactionners'] = len(self.reactionners)
counters['receivers'] = len(self.receivers)
counters['broks-external'] = len(self.external_broks)
counters['broks-internal'] = len(self.internal_broks)
counters['broks-arbiter'] = len(self.arbiter_broks)
counters['satellites.pollers'] = len(self.pollers)
counters['satellites.reactionners'] = len(self.reactionners)
counters['satellites.receivers'] = len(self.receivers)

return res

Expand Down
2 changes: 1 addition & 1 deletion alignak/daemons/receiverdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def get_daemon_stats(self, details=False):

counters = res['counters']
counters['external-commands'] = len(self.external_commands)
counters['unprocessed-external-commands'] = len(self.unprocessed_external_commands)
counters['external-commands-unprocessed'] = len(self.unprocessed_external_commands)

return res

Expand Down
11 changes: 6 additions & 5 deletions alignak/daemons/schedulerdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,12 @@ def get_daemon_stats(self, details=False):
if not self.sched:
return res

# Hosts/services problems counters
counters['hosts_problems'] = m_solver._get_total_host_problems()
counters['hosts_unhandled_problems'] = m_solver._get_total_host_problems_unhandled()
counters['services_problems'] = m_solver._get_total_service_problems()
counters['services_unhandled_problems'] = m_solver._get_total_service_problems_unhandled()
# # Hosts/services problems counters
# m_solver = MacroResolver()
# counters['hosts_problems'] = m_solver._get_total_host_problems()
# counters['hosts_unhandled_problems'] = m_solver._get_total_host_problems_unhandled()
# counters['services_problems'] = m_solver._get_total_service_problems()
# counters['services_unhandled_problems'] = m_solver._get_total_service_problems_unhandled()

# Get statistics from the scheduler
scheduler_stats = self.sched.get_scheduler_stats(details=details)
Expand Down
Loading

0 comments on commit 9cfaede

Please sign in to comment.