Giter VIP home page Giter VIP logo

Comments (18)

HenriWahl avatar HenriWahl commented on June 6, 2024

A cleaner approach will be the support for hostgroups in general. This is planned but not yet implemented. Another Monitor CGI URL would lead to more mess in my opinion.

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

That's fully true, however I assume it's not an easy task and would probably take some time to get that feature in. In the meanwhile, it would be nice if Acknowledgements and Downtime would work when using a custom Monitor CGI URL (like the one mentioned in the description).
If the planned feature is going to come out soon, then please disregard this and close as "won't fix".

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

With the latest version the usage of a custom URL in Monitor CGI URL has stopped working. I've turned on debugging and below are a few lines from the log file:

DEBUG: 2013-07-15 15:38:03.208000 Icinga   Created server.
DEBUG: 2013-07-15 15:38:03.208000 Icinga Infra   Created server.
DEBUG: 2013-07-15 15:38:03.349000 Icinga Infra   FetchURL: http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=own_Infrastructure&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/tac.cgi?jsonoutput CGI Data: None
DEBUG: 2013-07-15 15:38:03.349000 Icinga   FetchURL: http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=hgroupa&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/tac.cgi?jsonoutput CGI Data: None
DEBUG: 2013-07-15 15:38:03.349000    Checking for new version...
DEBUG: 2013-07-15 15:38:03.349000 Icinga Infra   FetchURL: https://nagstamon.ifw-dresden.de/files-nagstamon/latest_version_0.9.11-devel CGI Data: None
DEBUG: 2013-07-15 15:38:16.753000 Icinga Infra   FetchURL: http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=own_Infrastructure&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/status.cgi?style=hostdetail&hoststatustypes=12&hostprops=262144 CGI Data: None
DEBUG: 2013-07-15 15:38:16.873000 Icinga   FetchURL: http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=hgroupa&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/status.cgi?style=hostdetail&hoststatustypes=12&hostprops=262144 CGI Data: None
ERROR: 2013-07-15 15:38:18.841000 Icinga   Traceback (most recent call last):
  File "c:\Nagstamon\build\build\pyi.win32\nagstamon\out00-PYZ.pyz\Nagstamon.Server.Icinga", line 361, in _get_status_HTML
UnboundLocalError: local variable 'htobj' referenced before assignment

DEBUG: 2013-07-15 15:38:18.841000 Icinga   server return values:  
DEBUG: 2013-07-15 15:38:18.841000 Icinga   Refreshing output - server is already checking: False
ERROR: 2013-07-15 15:38:18.861000 Icinga Infra   Traceback (most recent call last):
  File "c:\Nagstamon\build\build\pyi.win32\nagstamon\out00-PYZ.pyz\Nagstamon.Server.Icinga", line 292, in _get_status_HTML
KeyError: 1

ERROR: 2013-07-15 15:38:18.861000 Icinga Infra   Traceback (most recent call last):
  File "c:\Nagstamon\build\build\pyi.win32\nagstamon\out00-PYZ.pyz\Nagstamon.Server.Icinga", line 361, in _get_status_HTML
UnboundLocalError: local variable 'htobj' referenced before assignment

DEBUG: 2013-07-15 15:38:18.861000 Icinga Infra   server return values:  
DEBUG: 2013-07-15 15:38:18.861000 Icinga Infra   Refreshing output - server is already checking: False

It would be great if at least previous functionality could be restored until host groups get implemented.

from nagstamon.

HenriWahl avatar HenriWahl commented on June 6, 2024

What does your custom CGI_URL look like?
Please consider testing latest Github commit 29bc1ca where the htobj bug should be fixed.

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

Here it is (hostname sanitized):
http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=own_Infrastructure%2FHosts&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10
I've also tested with the 12th of July build and still doesn't work.

from nagstamon.

HenriWahl avatar HenriWahl commented on June 6, 2024

Check it out from Github - just the source at the moment is changed.

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

Ok, I just did a git clone then ran it. Here's the output:

DEBUG: 2013-07-16 12:23:03.434000 Icinga   Created server.
DEBUG: 2013-07-16 12:23:03.444000 Icinga Infra   Created server.
DEBUG: 2013-07-16 12:23:03.554000 Icinga Infra   FetchURL: http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=own_Infrastructure%2FHosts&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/tac.cgi?jsonoutput CGI Data: None
DEBUG: 2013-07-16 12:23:03.554000 Icinga   FetchURL: http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=own_Infra&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/tac.cgi?jsonoutput CGI Data: None
DEBUG: 2013-07-16 12:23:03.554000    Checking for new version...
DEBUG: 2013-07-16 12:23:03.554000 Icinga Infra   FetchURL: https://nagstamon.ifw-dresden.de/files-nagstamon/latest_version_0.9.11-devel CGIData: None
DEBUG: 2013-07-16 12:23:16.076000 Icinga Infra   FetchURL: http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=own_Infrastructure%2FHosts&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/status.cgi?style=hostdetail&hoststatustypes=12&hostprops=262144 CGI Data: None
DEBUG: 2013-07-16 12:23:16.236000 Icinga   FetchURL: http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=own_Infra&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/status.cgi?style=hostdetail&hoststatustypes=12&hostprops=262144 CGI Data: None
ERROR: 2013-07-16 12:23:17.906000 Icinga Infra   Traceback (most recent call last):
  File "D:\cygwin\home\aneagoe\checkouts\Nagstamon\Nagstamon\Nagstamon\Server\Icinga.py", line 280, in _get_status_HTML
    trs.pop(0)
IndexError: pop from empty list

DEBUG: 2013-07-16 12:23:17.906000 Icinga Infra   server return values:
DEBUG: 2013-07-16 12:23:17.906000 Icinga Infra   Refreshing output - server is already checking: False
ERROR: 2013-07-16 12:23:17.986000 Icinga   Traceback (most recent call last):
  File "D:\cygwin\home\aneagoe\checkouts\Nagstamon\Nagstamon\Nagstamon\Server\Icinga.py", line 280, in _get_status_HTML
    trs.pop(0)
IndexError: pop from empty list

DEBUG: 2013-07-16 12:23:17.986000 Icinga   server return values:
DEBUG: 2013-07-16 12:23:17.986000 Icinga   Refreshing output - server is already checking: False

Looking closer at FetchURL, I noticed it's adding part of the URL again (status.cgi shows up twice in URL):
http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=own_Infra&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10/status.cgi?style=hostdetail&hoststatustypes=12&hostprops=262144

from nagstamon.

HenriWahl avatar HenriWahl commented on June 6, 2024

Well, adding Nagstamons' own status cgi stuff makes sense as it just takes the given CGI_URL expecting it being the CGI root. I even wonder how it worked in your setup at all before...

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

Not really sure, but used to work like a charm in 0.9.9. I'll try to get that and compare DEBUG outputs... maybe it reveals a clue.

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

Although just partial (only Icinga and without GUI update function) I've created the following patch for hostgroup support. It's quite basic but does the trick, so if you've got time please consider including.

--- Nagstamon.orig/Nagstamon/Nagstamon/Actions.py       2013-07-17 14:28:40.507608100 +0200
+++ Nagstamon/Nagstamon/Nagstamon/Actions.py    2013-07-16 18:06:34.316365300 +0200
@@ -715,6 +715,7 @@
     nagiosserver.type = server.type
     nagiosserver.monitor_url = server.monitor_url
     nagiosserver.monitor_cgi_url = server.monitor_cgi_url
+    nagiosserver.hostgroup = server.hostgroup
     # add resources, needed for auth dialog
     nagiosserver.Resources = resources
     nagiosserver.username = server.username
diff -ur Nagstamon.good/Nagstamon/Nagstamon/Config.py Nagstamon/Nagstamon/Nagstamon/Config.py
--- Nagstamon.good/Nagstamon/Nagstamon/Config.py        2013-07-17 14:28:40.507608100 +0200
+++ Nagstamon/Nagstamon/Nagstamon/Config.py     2013-07-16 18:05:24.747267400 +0200
@@ -495,6 +495,7 @@
             self.servers[server_name].name = server_name
             self.servers[server_name].monitor_url = self.nagios_url
             self.servers[server_name].monitor_cgi_url = self.nagios_cgi_url
+            self.servers[server_name].hostgroup = self.hostgroup
             self.servers[server_name].username = self.username
             self.servers[server_name].password = self.password
             # convert VERY old config files
@@ -685,6 +686,7 @@
         self.name = ""
         self.monitor_url = ""
         self.monitor_cgi_url = ""
+        self.hostgroup = ""
         self.username = ""
         self.password = ""
         self.save_password = True
diff -ur Nagstamon.good/Nagstamon/Nagstamon/Server/Icinga.py Nagstamon/Nagstamon/Nagstamon/Server/Icinga.py
--- Nagstamon.good/Nagstamon/Nagstamon/Server/Icinga.py 2013-07-17 14:28:40.517608200 +0200
+++ Nagstamon/Nagstamon/Nagstamon/Server/Icinga.py      2013-07-16 18:11:58.491821600 +0200
@@ -97,12 +97,16 @@
             # hosts (up or down or unreachable)
             self.cgiurl_hosts = {"hard": self.monitor_cgi_url + "/status.cgi?style=hostdetail&hoststatustypes=12&hostprops=262144",\
                                  "soft": self.monitor_cgi_url + "/status.cgi?style=hostdetail&hoststatustypes=12&hostprops=524288"}
+        if self.hostgroup:
+           for status_type in "hard", "soft":
+               self.cgiurl_services[status_type] += "&hostgroup=" + self.hostgroup
+               self.cgiurl_hosts[status_type] += "&hostgroup=" + self.hostgroup
+
         if self.json:
             for status_type in "hard", "soft":
                self.cgiurl_services[status_type] += "&jsonoutput"
                self.cgiurl_hosts[status_type] += "&jsonoutput"

-
     def _get_status(self):
         """
         Get status from Icinga Server, prefer JSON if possible

from nagstamon.

HenriWahl avatar HenriWahl commented on June 6, 2024

Thank you. I will check this when back to work.

from nagstamon.

HenriWahl avatar HenriWahl commented on June 6, 2024

Is this meant to work only with one hostgroup?

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

Yes. Until now I didn't know you can use more than one at a time but I just checked and that's possible. The way I use it is to specify two server definitions in Nagstamon. Like this the hostgroups are clearly delimited and visible. However, I recon it's also possible to create a list of hostgroups, iterate through it and append to URL (more appealing for users who need to see a lot of hostgroups).
I also wasn't sure how to handle versions older than 1.7, so there the behavior is not modified.
Wish I could help more, but I'm not very familiar with python or programming for that matter :)

from nagstamon.

HenriWahl avatar HenriWahl commented on June 6, 2024

Hm... every Nagios derivatives seems to handle hostgroups differently... I want at least Nagstamon having kind of a unified interface to hostgroups, but this looks like a bigger task. :-(
Anyway, why don't you just define the hostgroups that interest you for your username in Icinga monitor? Wouldn't this be the easiest way to focus one user to some hostgroups?

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

Had a quick look at the code and they all seem to be different (Centreon, Ninja etc.). This patch could easily be extended to Nagios.py but the rest look completely different and I got nothing to test on.
I'll also look at what you suggested, but for me the problem is solved anyway (I can just apply the patch I posted here).

from nagstamon.

HenriWahl avatar HenriWahl commented on June 6, 2024

A solution might be to give desired hostgroups in server settings dialog and run a loop through all given hostgroups and request their stauts like

for hg in hostgroups:
    get_status(hg)

Default will be "all". This of course will increase the number of requests to the poor monitor server.

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

Well, not exactly. At least for Icinga, things can go better, by adding more hostgroup definition to the URL like this:

http://my.icinga.server/icinga/cgi-bin/status.cgi?hostgroup=Hgroup1&hostgroup=Hgroup2&hostgroup=Hgroup3&style=detail&servicestatustypes=28&serviceprops=10&hostprops=10&scroll=0

I've already tested this and it works just fine, but I'm not sure about the rest (I guess it also works for nagios).

In this case, the following might do the trick when multiple hostgroups are defined:

        for hg in self.hostgroup:
           for status_type in "hard", "soft":
               self.cgiurl_services[status_type] += "&hostgroup=" + hg
               self.cgiurl_hosts[status_type] += "&hostgroup=" + hg

from nagstamon.

aneagoe avatar aneagoe commented on June 6, 2024

I've picked this up again and made a more complete implementation of hostgroups for Icinga. I've sent the patch your way for review.
The code now allows for hostgroup adding/editing (in Settings->Server->Edit) and one can specify multiple hostgroups per server definition. For Icinga, as discussed earlier it's not necessary to make a request for every hostgroup definition and the code respects that (it just builds the correct url containing all specified hostgroups).

Although I understand your concern that hostgroups should be unified, I don't think that's straightforward since every monitor handles them differently like you already pointed out. If we specify hostgroups the same way in nagstamon but handle them differently in the Server part (ie Server/Icinga.py) that should be good enough, right?

from nagstamon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.