url-item '&name=' - please help!

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

Moderators: Developers, Moderators

Post Reply
pfeufjoeadidas
Posts: 11
Joined: Tue May 10, 2011 4:24 am
Location: Germany

url-item '&name=' - please help!

Post by pfeufjoeadidas »

Hi everyone!

I opened a thread in the wrong sub-section yesterday. So i hope this is the correct section now.
Old thread: http://forums.cacti.net/viewtopic.php?f=5&t=42717

As mentioned in the above listet thread my url-item '&name=HOSTNAME' isn't working anymore. Till now i verified even elder versions - back to 0.8.7d - in none it's working. Somehow very strange, cause with 0.8.7e on opensuse 10.3 it worked like a charm!

Is there another url-item or variable i can use call the desired device via url? host_id isn't an alternative cause in nagios my systems are listed via hostname.
I hope someone can help - i'm very confused about this behavior. Especially cause the old system is still running fine and working like a charm... oO

Best regards from germany,

Jörg
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: url-item '&name=' - please help!

Post by noname »

I've not heard about "name=" parameter ever...

Instead, try this: "filter=$HOSTALIAS$"
pfeufjoeadidas
Posts: 11
Joined: Tue May 10, 2011 4:24 am
Location: Germany

Re: url-item '&name=' - please help!

Post by pfeufjoeadidas »

Hi noname,

'filter=...' is not working, cause the browser is saving last host_id, so when i set a filter, i manually have to set the correct device. Just then i will see the correct graphs. When i manually switch to another device, the filter is still applied, so no graphs are shown until i remove '&filter=...' from the url.

Do you know another parameter to directly call a device by it's hostname/devicename? Or is there an list existing that show's all url-parameter?

Thanks in advance,

Jörg
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: url-item '&name=' - please help!

Post by noname »

I tested "name=" in Cacti 0.8.7e (fresh installed), but not worked.

Some discussions existed in the past...
- http://forums.cacti.net/viewtopic.php?f=21&t=17984
- http://forums.cacti.net/viewtopic.php?f=21&t=29431
- http://forums.cacti.net/viewtopic.php?f=21&t=30162

Okay, I'll try too.

In 'graph_view.php' (0.8.7g) at around line 180:

Code: Select all

        /* if the user pushed the 'clear' button */
        if (isset($_REQUEST["clear_x"])) {
                kill_session_var("sess_graph_view_current_page");
                kill_session_var("sess_graph_view_filter");
                kill_session_var("sess_graph_view_graph_template");
                kill_session_var("sess_graph_view_host");

                unset($_REQUEST["page"]);
                unset($_REQUEST["filter"]);
                unset($_REQUEST["host_id"]);
                unset($_REQUEST["graph_template_id"]);
                unset($_REQUEST["graph_list"]);
                unset($_REQUEST["graph_add"]);
                unset($_REQUEST["graph_remove"]);
+               unset($_REQUEST["hostname"]);
        }

+       /* determine host_id from hostname */
+       if (isset($_REQUEST["hostname"])) {
+               $_REQUEST["host_id"] = db_fetch_cell("SELECT id FROM host WHERE hostname = '" . $_REQUEST["hostname"] . "'");
+       }

        /* reset the page counter to '1' if a search in initiated */
        if (isset($_REQUEST["filter"])) {
                $_REQUEST["page"] = "1";
        }

        load_current_session_value("host_id", "sess_graph_view_host", "0");
        load_current_session_value("graph_template_id", "sess_graph_view_graph_template", "0");
        load_current_session_value("filter", "sess_graph_view_filter", "");
        load_current_session_value("page", "sess_graph_view_current_page", "1");
Result is:
Image

This works in preview mode only. But at your own risk.
pfeufjoeadidas
Posts: 11
Joined: Tue May 10, 2011 4:24 am
Location: Germany

Re: url-item '&name=' - please help!

Post by pfeufjoeadidas »

@noname:

Thanks man, you made my day!!!!
I'm not into php - so a very thank you to you. I guess it's time dig into that...

Best regards,

Jörg
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: url-item '&name=' - please help!

Post by noname »

NOTICE:
"Clear" button works, but hostname in URL is still remain as well as "filter=" (and other parameters),
so "hostname=" is applied again when you clicked "graph" tab. Sorry.
pfeufjoeadidas
Posts: 11
Joined: Tue May 10, 2011 4:24 am
Location: Germany

Re: url-item '&name=' - please help!

Post by pfeufjoeadidas »

is there an option to clean up the url when calling another device or by clicking the "graphs"-button?

may this be a interesting patch for regular cacti-releases? especially for nagios-integration.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: url-item '&name=' - please help!

Post by noname »

pfeufjoeadidas wrote:is there an option to clean up the url when calling another device or by clicking the "graphs"-button?
It seems to be able to partly resolve.
Add this line:

Code: Select all

        /* determine host_id from hostname */
        if (isset($_REQUEST["hostname"])) {
                $_REQUEST["host_id"] = ...
+               unset($_SESSION["sess_graph_view_url_cache"]);
        }
URL for preview mode will be cleaned up, but "Host:" selection in "Graph Filters" is remain.
eclypse
Posts: 1
Joined: Mon May 16, 2011 10:46 pm

Re: url-item '&name=' - please help!

Post by eclypse »

Nice! Thanks for posting this!

Another option you would have is to query the description field instead. If you always set that to the system's shortname (and you know your devices have unique short names), you could use the shortname in the URL.

Here's my REQUEST line:

Code: Select all

  $_REQUEST["host_id"] = db_fetch_cell("SELECT id FROM host WHERE description = '" . $_REQUEST["hostname"] . "'");
pfeufjoeadidas
Posts: 11
Joined: Tue May 10, 2011 4:24 am
Location: Germany

Re: url-item '&name=' - please help!

Post by pfeufjoeadidas »

This is exactly what i have done. I needed to change to description, cause i have my systems different times in my devices-list - always with other options.
I'm using this setup to create specified reports.

And nagios infront of it is the best i know - especially combined with ninja.

Best regards,

Jörg
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests