Page 1 of 2

Fusion - custom links and url's

Posted: Tue Mar 26, 2019 4:12 pm
by vishfx
Hi Nagios Team,

Am using Nagios Fusion 4.1.7

I had a few queries :

a) How can I add custom links or Dashboard links to the Fusion homepage , something like below, hope you get the idea.
add-Capture.PNG
b) Custom URL dashlet does not seem to work with URL's with basic auth like http://user:[email protected]:8080/mypage.html
I see a blank page.

Kindly assist.

Regards,
Vish.

Re: Fusion - custom links and url's

Posted: Tue Mar 26, 2019 4:39 pm
by ssax
NOTE: Please note that while sometimes we may have time to do stuff like this to help you out to get what you want it should not be expected as the standard level of support, not all of us in the support department know how to develop or have the time to do it.

Please download the attached component that I wrote for you to do what you want.

Then go to Admin > Manage Components:
- Click the Browse button and select the downloaded zip file
- Click the Upload & Install button

Now if you go to the Home menu item you will see 3 new links:

Under Server Status you will see:

Code: Select all

Custom Home Link 1
Under Alerts you will see:

Code: Select all

Custom Alerts Link 1
Under Visualizations you will see:

Code: Select all

Custom Visualization Link 1 
To change them, please edit this file and adjust them:

Code: Select all

/usr/local/nagiosfusion/html/includes/components/fusioncustomlinks/fusioncustomlinks.inc.php
For example, you could change the top link from this:

Code: Select all

$menu->add_link(menu_link(_('Custom Home Link 1'), 'includes/components/fusioncustomlinks/tactical_overview.php'), 'home-server-status');
To this:

Code: Select all

$menu->add_link(menu_link(_('My Custom Link'), 'https://username:[email protected]/website/'), 'home-server-status');
Let us know if you have any questions.

Thank you!

Re: Fusion - custom links and url's

Posted: Tue Mar 26, 2019 4:56 pm
by cdienger
You could also add a new section to store the custom links:

Code: Select all

<?php
register_fusioncustomlinks();

function register_fusioncustomlinks() {
       $component_args = array(
           COMPONENT_TYPE              => COMPONENT,
           COMPONENT_NAME              => 'fusioncustomlinks',
           COMPONENT_TITLE             => _('Fusion Custom Links Component'),
           COMPONENT_VERSION           => '1.0.0',
           COMPONENT_DATE              => '03/26/2019',
           COMPONENT_AUTHOR            => 'Nagios Enterprises, LLC',
           COMPONENT_DESCRIPTION       => _('Provides Custom Menu Entries'),
           COMPONENT_REQUIRES_VERSION  => 4100,
           COMPONENT_FUNCTION          => 'fusioncustomlinks_successful_registration',
   );

   register_component($component_args);
}

function fusioncustomlinks_successful_registration() {
   register_fusioncustomlinks_callbacks();
}

function register_fusioncustomlinks_menu($cb, &$menu) {
    
    $menu->add_section('home', _('stuff'), 'home-stuff');
    
   $menu->add_link(menu_link(_('Nagios'), 'http://www.nagios.com'), 'home-stuff');

}

// register callbacks for fusion functionality
function register_fusioncustomlinks_callbacks() {
   register_callback(CALLBACK_MENU_INITIALIZED, 'register_fusioncustomlinks_menu');
}

?>
I wasn't able to reproduce the problem with the basic auth - are there any special characters in the credentials maybe? Try using the browsers dev tools to monitor the network traffic to see what the issue may be.

Re: Fusion - custom links and url's

Posted: Thu Mar 28, 2019 4:59 pm
by vishfx
Thanks, Custom links works !!! I will try it out.


Yes, there are some special chars.
Below is a url which does not work with Custom URL Dashlet :

http://api_key:eyJrIjoiR0ZXZmt1UFc0OEpI ... sk&orgId=1

Also,
The fusion node I use can't talk to the internet.
So, Where can I download all the components listed under "Manage Components" ?
For eg:
Home Page Modification component is 4.0.1 dated 10/04/2017

From where can I download the latest versions ?

Regards,
Vish.

Re: Fusion - custom links and url's

Posted: Fri Mar 29, 2019 10:18 am
by ssax
Run the URLs through a URL encoder such as this and use the encoded URLs instead:

https://meyerweb.com/eric/tools/dencoder/

Or you could change the code to this:

Code: Select all

$menu->add_link(menu_link(_('My Custom Link'), rawurlencode('https://username:[email protected]/website/')), 'home-server-status');

Re: Fusion - custom links and url's

Posted: Fri Mar 29, 2019 10:19 pm
by vishfx
ssax wrote:Run the URLs through a URL encoder such as this and use the encoded URLs instead:

Code: Select all

$menu->add_link(menu_link(_('My Custom Link'), rawurlencode('https://username:[email protected]/website/')), 'home-server-status');
I added the rawurlencode, but I get the below error :
The requested URL /nagiosfusion/http://username:[email protected]/website/ was not found on this server.
It seems to be due to "/nagiosfusion/" to the URL.

I also see the below in chrome inspect :
Subresource requests whose URLs contain embedded credentials (e.g. `https://user:pass@host/`) are blocked. See https://www.chromestatus.com/feature/5669008342777856 for more details.
Kindly advise.

Regards,
Vish.

Re: Fusion - custom links and url's

Posted: Mon Apr 01, 2019 4:19 pm
by ssax
Please PM me your file with the changes so that I can review it.

Re: Fusion - custom links and url's

Posted: Mon Apr 08, 2019 1:24 am
by vishfx
Hi Sean,

I'll circle back with that info at a later point. Can live with it for now.

Meanwhile had another requirement,

I want to create a one-click enable/disable Maintenance page for a bunch of HOSTGROUPS/HOSTS
I know this can be achieved using curl call on the below :

http://nagiosxi-lab/nagiosxi/includes/c ... _HOSTGROUP

My question was , how can I deploy a custom 'host_maintenance.php' in the fusion folder "/usr/local/nagiosfusion/html/" for this functionality ?

The idea is to use Fusion as a single point of control.

Is this something that can be done ? Or if you have any other best practice , Kindly Advice ?

Regards,
Vish.

Re: Fusion - custom links and url's

Posted: Mon Apr 08, 2019 1:12 pm
by ssax
You would likely need to write your own component for this, please see here:

https://assets.nagios.com/downloads/nag ... onents.php

Re: Fusion - custom links and url's

Posted: Tue Apr 09, 2019 6:46 am
by vishfx
Thanks Sean.
I will check .

Meanwhile, I have attached a word doc with screenshots and related queries.
fusion-queries.docx
Kindly advise, if these are possible or the only option is to go with own component.

Regards,
Vish.