Functions available to Cacti

functions with hooks are red


array_rekey
changes an array in the form: '$arr[0] = array("id" => 23, "name" => "blah")' to the form '$arr = array(23 => "blah")'

arguments:
$array - (array) the original array to manipulate
$key - the name of the key
$key_value - the name of the key value

returns:
the modified array


cacti_log
logs a string to Cacti's log file or optionally to the browser

arguments:
$string - the string to append to the log file
$output - (bool) whether to output the log line to the browser using pring() or not


clean_up_path
takes any path and makes sure it contains the correct directory separators based on the current operating system

arguments:
$path - the path to modify

returns:
the modified path


clean_up_name
runs a string through a series of regular expressions designed to eliminate "bad" characters

arguments:
$string - the string to modify/clean

returns:
the modified string


clear_messages
clears the message cache


config_value_exists
determines if a value exists for the current user/setting specified

arguments:
$config_name - the name of the configuration setting as specified $settings array in 'include/config_settings.php'

returns:
(bool) - true if a value exists, false if a value does not exist


debug_log_insert
inserts a line of text into the debug log

arguments:
$type - the 'category' or type of debug message
$text - the actual debug message


debug_log_clear
clears the debug log for a particular category

arguments:
$type - the 'category' to clear the debug log for. omitting this argument implies all categories


debug_log_return
returns the debug log for a particular category

arguments:
$type - the 'category' to return the debug log for.

returns:
the full debug log for a particular category


display_output_messages
displays all of the cached messages from the raise_message() function and clears the message cache


display_custom_error_message
displays a custom error message to the browser that looks like the pre-defined error messages

arguments:
$text - the actual text of the error message to display


draw_navigation_text
determines the top header navigation text for the current page and displays it to the browser


exec_into_array
executes a command and puts each line of its output into an array

arguments:
$command_line - the command to execute

returns:
(array) an array containing the command output


form_input_validate
validates the value of a form field and takes the appropriate action if the input is not valid

arguments:
$field_value - the value of the form field
$field_name - the name of the $_POST field as specified in the HTML
$regexp_match - (optionally) enter a regular expression to match the value against
$allow_nulls - (bool) whether to allow an empty string as a value or not
$custom_message - (int) the ID of the message to raise upon an error which is defined in the $messages array in 'include/config_arrays.php'

returns:
the original $field_value


generate_data_input_field_sequences
re-numbers the sequences of each field associated with a particular data input method based on its position within the input string

arguments:
$string - the input string that contains the field variables in a certain order
$data_input_id - (int) the ID of the data input method
$inout - ('in' or 'out') whether these fields are from the input or output string


generate_data_source_path
creates a new data source path from scratch using the first data source item name and updates the database with the new value

arguments:
$local_data_id - (int) the ID of the data source to generate a new path for

returns:
the new generated path


generate_graph_def_name
takes a number and turns each digit into its letter-based counterpart for RRDTool DEF names (ex 1 -> a, 2 -> b, etc)

arguments:
$graph_item_id - (int) the ID to generate a letter-based representation of

returns:
a letter-based representation of the input argument


generate_hash
generates a new unique hash

returns:
a 128-bit, hexadecimal hash


get_associated_rras
returns a list of all RRAs referenced by a particular graph

arguments:
$local_graph_id - (int) the ID of the graph to retrieve a list of RRAs for

returns:
(array) an array containing the name and id of each RRA found


get_browser_query_string
returns the full url, including args requested by the browser

returns:
the url requested by the browser


get_data_source_item_name
gets the name of a data source item or generates a new one if one does not already exist

arguments:
$data_template_rrd_id - (int) the ID of the data source item

returns:
the name of the data source item or an empty string for an error


get_data_source_path
gets the full path to the .rrd file associated with a given data source

arguments:
$local_data_id - (int) the ID of the data source
$expand_paths - (bool) whether to expand the <path_rra> variable into its full path or not

returns:
the full path to the data source or an empty string for an error


get_data_source_title
returns the title of a data source without using the title cache

arguments:
$local_data_id - (int) the ID of the data source to get a title for

returns:
the data source title


get_full_script_path
gets the full path to the script to execute to obtain data for a given data source. this function does not work on SNMP actions, only script-based actions

arguments:
$local_data_id - (int) the ID of the data source

returns:
the full script path or (bool) false for an error


get_graph_group
returns an array containing each item in the graph group given a single graph item in that group

arguments:
$graph_template_item_id - (int) the ID of the graph item to return the group of

returns:
(array) an array containing each item in the graph group


get_graph_parent
returns the ID of the next or previous parent graph item id

arguments:
$graph_template_item_id - (int) the ID of the current graph item
$direction - ('next' or 'previous') whether to find the next or previous parent

returns:
(int) the ID of the next or previous parent graph item id


get_graph_title
returns the title of a graph without using the title cache

arguments:
$local_graph_id - (int) the ID of the graph to get a title for

returns:
the graph title


get_graph_tree_array
returns a list of graph trees taking permissions into account if necessary

arguments:
$return_sql - (bool) Whether to return the SQL to create the dropdown rather than an array
$force_refresh - (bool) Force the refresh of the array from the database

returns:
(array) an array containing a list of graph trees


get_hash_cdef
returns the current unique hash for a cdef

arguments:
$graph_template_id - (int) the ID of the cdef to return a hash for
$sub_type (optional) return the hash for a particlar sub-type of this type

returns:
a 128-bit, hexadecimal hash


get_hash_data_input
returns the current unique hash for a data input method

arguments:
$graph_template_id - (int) the ID of the data input method to return a hash for
$sub_type (optional) return the hash for a particlar sub-type of this type

returns:
a 128-bit, hexadecimal hash


get_hash_data_query
returns the current unique hash for a data query

arguments:
$graph_template_id - (int) the ID of the data query to return a hash for
$sub_type (optional) return the hash for a particlar sub-type of this type

returns:
a 128-bit, hexadecimal hash


get_hash_data_template
returns the current unique hash for a data template

arguments:
$graph_template_id - (int) the ID of the data template to return a hash for
$sub_type (optional) return the hash for a particlar sub-type of this type

returns:
a 128-bit, hexadecimal hash


get_hash_gprint
returns the current unique hash for a gprint preset

arguments:
$graph_template_id - (int) the ID of the gprint preset to return a hash for

returns:
a 128-bit, hexadecimal hash


get_hash_graph_template
returns the current unique hash for a graph template

arguments:
$graph_template_id - (int) the ID of the graph template to return a hash for
$sub_type (optional) return the hash for a particlar sub-type of this type

returns:
a 128-bit, hexadecimal hash


get_hash_host_template
returns the current unique hash for a gprint preset

arguments:
$host_template_id - (int) the ID of the host template to return a hash for

returns:
a 128-bit, hexadecimal hash


get_hash_round_robin_archive
returns the current unique hash for a round robin archive

arguments:
$rra_id - (int) the ID of the round robin archive to return a hash for

returns:
a 128-bit, hexadecimal hash


get_hash_version
returns the item type and cacti version in a hash format

arguments:
$type - the type of item to represent ('graph_template','data_template', 'data_input_method','cdef','gprint_preset','data_query','host_template')

returns:
a 24-bit hexadecimal hash (8-bits for type, 16-bits for version)


get_host_array
returns a list of hosts taking permissions into account if necessary

returns:
(array) an array containing a list of hosts


get_item
returns the ID of the next or previous item id

arguments:
$tblname - the table name that contains the target id
$field - the field name that contains the target id
$startid - (int) the current id
$lmt_query - an SQL "where" clause to limit the query
$direction - ('next' or 'previous') whether to find the next or previous item id

returns:
(int) the ID of the next or previous item id


get_sequence
returns the next available sequence id

arguments:
$id - (int) the current id
$field - the field name that contains the target id
$table_name - the table name that contains the target id
$group_query - an SQL "where" clause to limit the query

returns:
(int) the next available sequence id


get_web_browser
determines the current web browser in use by the client

returns:
('ie' or 'moz' or 'other')


graph_config_value_exists
determines if a value exists for the current user/setting specified

arguments:
$config_name - the name of the configuration setting as specified $settings_graphs array in 'include/config_settings.php'
$user_id - the id of the user to check the configuration value for

returns:
(bool) - true if a value exists, false if a value does not exist


is_error_message
finds whether an error message has been raised and has not been outputted to the user

returns:
(bool) whether the messages array contains an error or not


move_graph_group
takes a graph group (parent+children) and swaps it with another graph group

arguments:
$graph_template_item_id - (int) the ID of the (parent) graph item that was clicked
$graph_group_array - (array) an array containing the graph group to be moved
$target_id - (int) the ID of the (parent) graph item of the target group
$direction - ('next' or 'previous') whether the graph group is to be swapped with group above or below the current group


move_item_down
moves an item down by swapping it with the item below it

arguments:
$table_name - the table name that contains the target id
$current_id - (int) the current id
$group_query - an SQL "where" clause to limit the query


move_item_up
moves an item down by swapping it with the item above it

arguments:
$table_name - the table name that contains the target id
$current_id - (int) the current id
$group_query - an SQL "where" clause to limit the query


raise_message
mark a message to be displayed to the user once display_output_messages() is called

arguments:
$message_id - the ID of the message to raise as defined in $messages in 'include/config_arrays.php'


read_config_option
finds the current value of a Cacti configuration setting

arguments:
$config_name - the name of the configuration setting as specified $settings array in 'include/config_settings.php'

returns:
the current value of the configuration option


read_default_config_option
finds the default value of a Cacti configuration setting

arguments:
$config_name - the name of the configuration setting as specified $settings array in 'include/config_settings.php'

returns:
the default value of the configuration option


read_default_graph_config_option
finds the default value of a graph configuration setting

arguments:
$config_name - the name of the configuration setting as specified $settings array in 'include/config_settings.php'

returns:
the default value of the configuration option


read_graph_config_option
finds the current value of a graph configuration setting

arguments:
$config_name - the name of the configuration setting as specified $settings_graphs array in 'include/config_settings.php'

returns:
the current value of the graph configuration option


resolve_navigation_variables
substitute any variables contained in the navigation text

arguments:
$text - the text to substitute in

returns:
the original navigation text with all substitutions made


sanitize_search_string
cleans up a search string submitted by the user to be passed to the database. NOTE: some of the code for this function came from the phpBB project.

arguments:
$string - the original raw search string

returns:
the sanitized search string


stri_replace
a case insensitive string replace

arguments:
$find - needle
$replace - replace needle with this
$string - haystack

returns:
the original string with '$find' replaced by '$replace'


strip_newlines
removes \n\r from lines

arguments:
$string - the string to strip


strip_quotes
Strip single and double quotes from a string in addition remove non-numeric data from strings.

arguments:
$result - (string) the result from the poll

returns:
(string) the string with quotes stripped


title_trim
takes a string of text, truncates it to $max_length and appends three periods onto the end

arguments:
$text - the string to evaluate
$max_length - the maximum number of characters the string can contain before it is truncated

returns:
the truncated string if len($text) is greater than $max_length, else the original string


update_host_status
updates the host table with informaton about it's status. It will also output to the appropriate log file when an event occurs.

arguments:
$status - (int constant) the status of the host (Up/Down)
$host_id - (int) the host ID for the results
$hosts - (array) a memory resident host table for speed
$ping - (class array) results of the ping command


validate_result
determine's if the result value is valid or not. If not valid returns a "U"

arguments:
$result - (string) the result from the poll

returns:
(int) either to result is valid or not


CategoryDeveloper
Page was generated in 0.0659 seconds