Need help on troubleshooting new plugin

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

Post Reply
Rno
Cacti Pro User
Posts: 658
Joined: Wed Dec 07, 2011 9:19 am

Need help on troubleshooting new plugin

Post by Rno »

I'm trying to write a new plugin, and I didn't find 2 informations on the doc neither on other plugin:
1: How ca I read back on a function the value of a settings ? (should I do a global at the beggining of the function, in also in the plugin_config_settings ?
2: how can i send information to a log file ? (which log ?)

my problem is that I made some mistake in the code, and cacti won't load anymore, and I can't find why it's wrong (even if I have and error into the httpd/error_log file), so I'd like to output some value before the error, and see what I have)

thanks for your help
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
smiles
Cacti User
Posts: 79
Joined: Mon Sep 10, 2012 5:54 pm

Re: Need help on troubleshooting new plugin

Post by smiles »

You should be a bit more specific in your question for someone to help.

You can use var_dump to see what the values of most any variable values are, even if they are in arrays, which most of the variables in cacti are. For example, to see the result of a SQL query:

print "Query Result: " . var_dump($qresult) . "\n";

For logging, there is a built in function within cacti in lib/functions.php:

/* cacti_log - logs a string to Cacti's log file or optionally to the browser
@arg $string - the string to append to the log file
@arg $output - (bool) whether to output the log line to the browser using print() or not
@arg $environ - (string) tell's from where the script was called from
@arg $level - (int) only log if above the specified log level */
function cacti_log($string, $output = false, $environ = 'CMDPHP', $level = '')

I would suggest looking at one of the plugins on the cacti github as reference, like syslog or thold.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest