Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Wed May 24, 2017 2:47 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Need help on troubleshooting new plugin
PostPosted: Fri Jan 13, 2017 4:28 am 
Offline
Cacti User

Joined: Wed Dec 07, 2011 9:19 am
Posts: 184
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

_________________
CentOS
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.3


Top
 Profile  
 
 Post subject: Re: Need help on troubleshooting new plugin
PostPosted: Fri Jan 13, 2017 1:04 pm 
Offline
Cacti User

Joined: Mon Sep 10, 2012 5:54 pm
Posts: 60
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group