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

Cannot set downtime to service #3

Open
techadrian opened this issue Jan 26, 2017 · 4 comments
Open

Cannot set downtime to service #3

techadrian opened this issue Jan 26, 2017 · 4 comments

Comments

@techadrian
Copy link

techadrian commented Jan 26, 2017

Hi Guys,

Been trying to implement ninja with merlin and naemon and got stuck at downtime setting for services :
Selecting start time and endtime like this 2017-01-26 01:00:00 and 2017-01-27 01:00:00 I got the following error :

There was an error submitting your command to Ninja.
ERROR: 2017-01-26 00:00:00 is not a valid date, please adjust it

Tried different formats, it does not work .....

Log states :
Failed to submit command 'schedule_downtime' on (services) object 'hplj2605dn;PING' Output: 2017-01-26 01:00:00 is not a valid date, please adjust it

Any chance you can have a look at this ?

Thanks,
Adrian

@chelmertz
Copy link
Contributor

chelmertz commented Jan 27, 2017

Hey @techadrian,

The label of the field is hardcoded as

Start time in the format: YYYY-MM-DD hh:mm:ss

which is incorrect because it does not take the configuration of the date format into account.

You want to double check the actual format you are using. The configuration value you are looking for is "date_format" inside of naemon.cfg. On an OP5 Monitor installation, this can be found through `grep date_format naemon.cfg.

On an OP5 Monitor installation, this should do it for you:

# grep date_format /opt/monitor/etc/naemon.cfg 
date_format=iso8601

If you are using Ninja/Naemon/Merlin on your own hand, you will find naemon.cfg in another path.

Once you got the configuration value, which in my example is iso8601, you can look for the expanded date format in this file: ninja/application/helpers/date.php. Here's a relevant link for you: https://github.com/op5/ninja/blob/eeae3cfeee1/application/helpers/date.php#L148-L160

@techadrian
Copy link
Author

Hi chelmertz,

Thank you so much for pointing me to the right direction.
I have analyzed the code and your response and date_format=iso8601 was in my naemon config, however, taking a closer look at this line of code :
https://github.com/op5/ninja/blob/eeae3cfeee1/application/helpers/date.php#L138-L138
nagios.cfg si hardcoaded into code, this will not work in any case with naemon, as naemon uses naemon.cfg not nagios.cfg as main config file therefore search for date_format in nagios.cfg will always return false.

My fix was : change from nagios.cfg in naemon.cfg in date.php
Dirty fix : symlink /etc/naemon/naemon.cfg to /etc/naemon/nagios.cfg

Do you think we can adjust the code to treat this exception?

Cheers,
Adrian

@chelmertz
Copy link
Contributor

Hi again Adrian,

Thanks for digging in! In OP5 Monitor (the product that we sell, that includes Ninja), we actually symlink nagios.cfg to naemon.cfg as one way to handle legacy installations. I don't think we have ever reflected on this particular issue from the OSS PoV, but I really think that we should abstract it away, so that you do not have to change parts of the code inside of the product.

I'm thinking that the date_format probably should reside in a Ninja configuration file instead (application/config/date.php or such). It may then differ to whatever is inside of nagios.cfg/naemon.cfg but at least it is coherent with the rest of Ninja, which I think is a good thing. What do you think about that?

@techadrian
Copy link
Author

Hi Carl,

Moving date_format setting in ninja from a "complete dinamic" method by looking in nagios.cfg/naemon.cfg to a configuration like application/config/date.php would be too much in my opinion since we create a config file for only one value. If there would have been more values regarding date .....yeah.....that would work ...but using it only for date_format ....

The most easy way I see doing that is in https://github.com/op5/ninja/blob/eeae3cfeee1/application/helpers/date.php and add a default value.
Something like ....if nagios.cfg or naemon.cfg cannot offer the value, use date_format=iso8601 by default.
Doing that you keep the "dinamic" aspect and you also treat the exception in a few lines of code.
If there is a incompatibility like a user has a naemon.cfg with date_format=us and ninja uses the default date_format=iso8601, you see that in the logs of naemon, that an incompatible date format is used. Using iso8601 also makes more sense with "Start time in the format: YYYY-MM-DD hh:mm:ss" that is hardcoaded into the interface: with iso8601 you enter the date in exactly the same format as interface shows you .

Hope that helps.

Cheers,
Adrian

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

No branches or pull requests

2 participants