Page 1 of 1

Need to change the behavior for Nagios config operations

Posted: Tue Apr 12, 2016 11:22 am
by bosecorp
Hi Team,

This topic needs immediate attention.

If you go to the NagiosXI Core config manager >> Write config File page

You can see 4 different options like "Write Configs to file", Verify.., Delete all hosts... Restart Nagios.

I have noticed that even if you click on the these text, the button gets highlighted automatically and then if you just click on the "text" the option gets activated.

Example: Please see the attached screenshot. So if you click on the highlighted (red) text the option gets triggered.
If you click on the text "Files" which is just above the "Delete" option, it directly gets activated and then we get a message "All the hosts/services are deleted successfully"

This is something which is really scary, so below is what we are expecting
1) Is it possible to change this behavior which i just explained?
2) Can we have a confirmation after we hit on "Delete" option ?
3) Can we restrict the "Delete" option to only specific Nagios admins?

Thanks

Re: Need to change the behavior for Nagios config operations

Posted: Tue Apr 12, 2016 1:40 pm
by tmcdonald
Edit the following:

/usr/local/nagiosxi/html/includes/components/ccm/includes/applyconfig.inc.php

And change lines like these:

<label for='writeConfig'>"._("Write Configs To File")."</label><br />

to this:

<label>"._("Write Configs To File")."</label><br />

and save. There should be 4, one for each button. Basically we are just removing the for='something' parts.

Regarding points 2 and 3, I would need a dev to take a closer look.

Re: Need to change the behavior for Nagios config operations

Posted: Tue Apr 12, 2016 4:44 pm
by bosecorp
That worked, please keep me about the other 2 areas.

Re: Need to change the behavior for Nagios config operations

Posted: Wed Apr 13, 2016 9:05 am
by lmiltchev
I posted an internal feature request for 2) and 3) - (TASK ID 8268). Thank you!

Re: Need to change the behavior for Nagios config operations

Posted: Fri Apr 15, 2016 12:34 pm
by bosecorp
Thanks and i highly appreciate your update. Can you please let me know how to track those task (8268) which you created.

Re: Need to change the behavior for Nagios config operations

Posted: Fri Apr 15, 2016 1:38 pm
by lmiltchev
The internal tasks are not publicly available, but if you asked us (on the forum) about a specific task (providing the TASK ID), we would give you an update.
Another option would be to post a feature request on our public tracker, where you can monitor the progress.

Re: Need to change the behavior for Nagios config operations

Posted: Fri Apr 15, 2016 1:54 pm
by ssax
*** Note: This will get reverted if you upgrade and will need to be reimplemented.
*** Make sure that you have known-good backups/vm snapshots before making any modifications

For 2 and 3, edit this file:

Code: Select all

/usr/local/nagiosxi/html/includes/components/ccm/javascript/main_js.js
Around line 186, change this:

Code: Select all

function doConfig(mode)
{
    $('#type').val(mode);
    $('#writeConfigForm').submit();
}
To this:

Code: Select all

function doConfig(mode)
{
    if (mode = 'delete') {
        var name = '<%= session.getAttribute("username") %>';
        var allowed_admins = ['nagiosadmin', 'user1', 'user2'];

        if (!jQuery.inArray(name, allowed_admins)) {
            alert('Sorry, you are not authorized.');
            return;
        }

        if (!confirm("Are you sure you want to delete all config files?")) {
            return;
        }
    }

    $('#type').val(mode);
    $('#writeConfigForm').submit();
}
Make sure that you change this line to who you want to allow:

Code: Select all

var allowed_admins = ['nagiosadmin', 'user1', 'user2'];