Need help on troubleshooting new plugin

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Moderators, Developers

Post Reply
Cacti User
Posts: 346
Joined: Wed Dec 07, 2011 9:19 am

Need help on troubleshooting new plugin

#1 Post by Rno » Fri Jan 13, 2017 4:28 am

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
Cacti 0.8.8h
Spine 0.8.8h
PIA 3.1
Aggregate 0.75
Monitor 1.3
Settings 0.71
Weathermap 0.98
Thold 0.5
rrdclean 0.41

Own plugin: LinkDiscovery 0.45, Map 0.37

Cacti 1.2.6
Spine 1.2.6
thold 1.0.6
monitor 2.3.5
php 7.2.11
mariadb 5.5.56
Own plugin:
ExtendDB 1.1.2
LinkDiscovery 1.2.6
Map 1.2.6

Cacti User
Posts: 79
Joined: Mon Sep 10, 2012 5:54 pm

Re: Need help on troubleshooting new plugin

#2 Post by smiles » Fri Jan 13, 2017 1:04 pm

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