how to set nectar's Graph links?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
imhere
Posts: 2
Joined: Wed Jan 26, 2011 8:05 pm

how to set nectar's Graph links?

Post by imhere »

HI
my nectar is working,but the reports send to email with wrong Graph links,my web's path like this :http://XXX:8080/cacti , but the path send to my email is http://xxx(or server name)/cacti. so where can i set the path?
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: how to set nectar's Graph links?

Post by noname »

Try this patch.
This is for nectar-0.30.
(I imitated the code from 'thold/includes/settings.php'.)

Code: Select all

--- setup.php.org       2010-12-31 04:31:55.000000000 +0900
+++ setup.php           2011-03-02 19:27:34.194259000 +0900
@@ -477,6 +477,14 @@
                        "default" => NECTAR_TYPE_INLINE_PNG,
                        "array" => $attach_types
                        ),
+               'nectar_base_url' => array(
+                       'friendly_name' => 'Nectar Base URL',
+                       'description' => 'Cacti base URL for \'Graph linked\'',
+                       'method' => 'textbox',
+                       // Set the default only if called from 'settings.php'
+                       'default' => ((isset($_SERVER['HTTP_HOST']) && isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) == 'settings.php') ? ('http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/') : ''),
+                       'max_length' => 255,
+                       ),
                "nectar_max_attach" => array(
                        "friendly_name" => "Maximum E-Mail Size",
                        "description" => "The maximum size of the E-Mail message including all attachements.",

Code: Select all

--- nectar_functions.php.org    2010-12-31 04:28:38.000000000 +0900
+++ nectar_functions.php        2011-03-02 19:30:51.508194000 +0900
@@ -669,6 +669,8 @@
        }

        if ($nectar["graph_linked"] == "on" ) {
+           $base_url = read_config_option("nectar_base_url");
+           if ($base_url == '') {
                /* determine our hostname/servername in different environments */
                if (isset($_SERVER["SERVER_NAME"])) {
                        $hostname = $_SERVER["SERVER_NAME"];
@@ -681,8 +683,10 @@
                } else {
                        $hostname = "";
                }
+               $base_url = "http://" . $hostname . $config['url_path'];
+           }

-               $out = "<a href='http://" . $hostname . $config['url_path'] . "graph.php?action=view&local_graph_id=".$item['local_graph_id']."&rra_id=all'>" . $out . "</a>";
+               $out = "<a href='" . $base_url . "graph.php?action=view&local_graph_id=".$item['local_graph_id']."&rra_id=all'>" . $out . "</a>";
                nectar_log(__FUNCTION__ . ", Link: " . $out, false, "NECTAR TRACE", POLLER_VERBOSITY_MEDIUM);
        }

And after patched, go 'Console' -> 'Settings' -> 'Misc' tab, then click 'save'.
(By this operation, 'nectar_base_url' record is added to 'settings' table)
Example in my environment
Example in my environment
nectar_base_url.png (45.26 KiB) Viewed 3137 times
Note: $_SERVER['HTTP_HOST'] is only available when accessed via browser...
(not available from scheduled task)
imhere
Posts: 2
Joined: Wed Jan 26, 2011 8:05 pm

Re: how to set nectar's Graph links?

Post by imhere »

hi man! thanks! :lol:
ari
Posts: 24
Joined: Fri Jan 08, 2010 10:29 am

Re: how to set nectar's Graph links?

Post by ari »

I am using nectar 0.30 on 0.8.7g

While trying to apply both patches, I got errors from the patch utility:

Code: Select all

root@tor-cacti:/var/www/cacti/plugins/nectar# patch --verbose < patch1   
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- setup.php.org       2010-12-31 04:31:55.000000000 +0900
|+++ setup.php           2011-03-02 19:27:34.194259000 +0900
--------------------------
Patching file setup.php using Plan A...
Hunk #1 FAILED at 477.
1 out of 1 hunk FAILED -- saving rejects to file setup.php.rej
done
I tried various patch options (e.g. -p1) with no luck. Similarly with the second patch.

Finally, I manually added the new lines (and deleted the one line marked with '-') and it just worked fine. The new option showed up in cacti > settings > MISC and the links in the reported graphs are OK.

It would be great to have this patch integrated into nectar for the next stable release.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: how to set nectar's Graph links?

Post by noname »

Sorry, probably that error is caused by mismatch between the leading tab and spaces.

Add option "--ignore-white-space" when executing patch command,
or use this file instead.
nectar_base_url.patch.txt
(1.79 KiB) Downloaded 271 times
pabloc
Posts: 2
Joined: Wed Feb 27, 2013 1:36 pm
Location: Buenos Aires, Argentina
Contact:

Re: how to set nectar's Graph links?

Post by pabloc »

Hello 'Noname', thanks a lots for your patch! (It worked fine with Cacti 0.8.8a + Nectar v0.35a).

The only extra-thing I've done (by hand), was to adapt the lines from your patch, to Nectar v0.35a plus the other patch I've submitted to the forum:

http://forums.cacti.net/viewtopic.php?f ... 0&start=30

:)

Note: I'm running Cacti v0.8.8a + Spine v0.8.8 + plugins (including Nectar v0.35a) on a FreeBSD 8.3p4 box at work.

Regards,
Pablo Carboni.
Hengendro
Posts: 3
Joined: Thu Oct 22, 2015 8:51 am

Re: how to set nectar's Graph links?

Post by Hengendro »

Sorry, but i dont understand what file is patched... nectar.php? setup.php???

Regards.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests