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

Send state_id over time to have availability #23

Open
wants to merge 9 commits into
base: refactored
Choose a base branch
from

Conversation

Azef1
Copy link

@Azef1 Azef1 commented Jul 11, 2016

This Pull request send availability for hosts and services in Graphite over time.
It's useful to see when an host/service is down over time.

How it's works ?
The broker receive all data from all check. A function for host read data about state and other function do same for service.
For HOSTS i added:

 def manage_host_check_result_brok(self, b):
    state_id = b.data['state_id'] #Read state_id, it's a number
[...]
#Send state to Graphite        
        state_query = []
        state_query.append("%s.available %s %d" % (path, state_id, check_time))
        state_packet = '\n'.join(state_query) + '\n'
        #Query example: myshost.available 1 ​1458774003
        #logger.error("------ %s", state_packet)
        try:
                self.send_packet(state_packet) 
        except IOError:
                logger.error("[Graphite broker] Failed sendind state o the Graphite Carbon.")
[...]

Same logic for services

The result with Grafana and Graphite as datasource
result

@mohierf
Copy link

mohierf commented Jul 12, 2016

You should make this feature configurable in the module configuration file. Sending state for all hosts and services may be overloading an installed Graphite instance ...

Azef1 added 2 commits July 12, 2016 12:20
In graphite2.cfg, options are:
   state_enable 1 shinken-monitoring#1=enable send state / 0=disable
   state_host   1 shinken-monitoring#1=enable send state for host / 0=disable
   state_service 1 shinken-monitoring#1=enable send state for service / 0=disable
@Azef1
Copy link
Author

Azef1 commented Jul 12, 2016

Thx for your suggestion. I added some options to enable or disable this feature and you will be able to choose sending state for all hosts OR\AND all services.

I am agree with you "Sending state for all hosts or\and all services may be overloading" for Graphite.
Currently, i send state every time a check is executed. This method is too aggressive if check_interval is aggressive (eg: if check_interval 10, all 10 seconds a query is sending to Graphite)
In next release, i will add a function to send state to Graphite only if previous state is different from current state. So, i send a packet to Graphite only if state change.

Other suggestions are welcome.

@mohierf
Copy link

mohierf commented Jul 12, 2016

+1 for the options. I think that this feature should be disabled as default.

Nice idea to send the state only if it changed. As of my memory, you can easily know if the state chaned thanks to the received brok data ... you should find a state and a last_state information in the brok data :)

@Azef1
Copy link
Author

Azef1 commented Jul 12, 2016

So, I disabled this feature as default.
And i send state to Graphite only if last_state_id != state_id
You can test it

@Azef1
Copy link
Author

Azef1 commented Jul 15, 2016

With graphite, I replicated same result than Grafana:
graphaa
Here Service is down between ~9h00 to 15h.

Do you think this feature could be "official" in master branch or other branch ?
Have you test this feature ?
It will be nice to modify ui-graphite module to embed this graph in WebUI (with other size height: 100px width: 100%).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants