Getting the Notes URL and Action URL

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Getting the Notes URL and Action URL

Post by Box293 »

I am writing a component for internal use called the "Actions Tab".
Action Tab.png
When a user is looking at a specific service like disk space check, we want to provide them with a link that has our procedure on disk space checks.

I thought the Notes URL and the Action URL would be handy for these types of links. That way we put the specific link in the service based on the type of service it is.

Then it is a simple matter of pulling the Notes URL or the Action URL from the database. That way it is dynamic on the Actions tab based on the particular service I am looking at.

Make sense?
CCM Misc Settings.png
Do you have an example of the code I need to use to pull this information from the database? I've been playing with the function get_service_objects_xml_output() and it retrieves the information for all services however I don't know how to get the specific information for a) the service I am looking at and b)the Notes URL or Action URL.

My programming skills are stretched at this point. :o
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Getting the Notes URL and Action URL

Post by tonyyarusso »

I don't know the PHP functions for accessing or setting them (if any easily), but I can tell you that they are the notes_url and action_url fields in the tbl_service table of the nagiosql MySQL database.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Getting the Notes URL and Action URL

Post by Box293 »

Hi Tony,
I've been able to easily access the MySQL Database using the following php code:

Code: Select all

mysql_connect("localhost","root","nagiosxi")
I am just wondering if the MySQL username and password are stored in a variable? This way I don't need to hard code the username and password into the php code.

Cheers :)
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Getting the Notes URL and Action URL

Post by mguthrie »

You shouldn't need to mess with DB connections at all if you include the 'componenthelper.inc.php' script at the top of your file. Here's an outline of the important stuff that should save you a bunch of time. XI uses controlled access to the data on the backend, but here are the key items you should need to get your data.

Code: Select all

//necessary include file
 include_once(dirname(__FILE__).'/../componenthelper.inc.php');

//grab the GET variables and clean them
$host=grab_request_var("host","");
$service=grab_request_var("service","");

//get the unique service ID
$service_id=get_service_id($host,$service);

// get service details, create required arguments for backend 
	$args=array(
		"cmd" => "getservices",
		"service_id" => $service_id,
		);

//this will give you an XML object, loaded from the simplexml_load_string function
	$xml=get_backend_xml_data($args);	

//you should be able to access the variables you need with something like the following
 $notes = $xml->service->notes_url;
$action = $xml->service->action_url; 

//use  print_r($xml) to see a dumped output of the XML if there are other values that you need. 
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Getting the Notes URL and Action URL

Post by Box293 »

Cheers Mike, this is exactly what I am after.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
rdedon
Posts: 578
Joined: Sat Nov 20, 2010 4:51 pm

Re: Getting the Notes URL and Action URL

Post by rdedon »

Very neat Troy! :-)
Rene deDon
Technical Team
___
Nagios Enterprises, LLC
Web: http://www.nagios.com
Locked