Transporter plugin does not work well with a custom plugin
Moderators: Developers, Moderators
-
- Posts: 6
- Joined: Tue Jan 24, 2012 5:35 am
Transporter plugin does not work well with a custom plugin
Hello,
I am using CACTI 0.8.7h along with Plugin Architecture 0.8.7h v3.0 which is the latest. We have installed the latest version of transporter plugin version 0.2 which uses the old plugin architecture. However, transporter plugin works just fine by itself. We have developed a custom plugin that depends on the data generated by transporter plugin. The custom plugin also uses poller_output hook to get a notification as to when there is data in the poller tables.
When the custom plugin is enabled along with the transporter plugin from the plugin management window of CACTI GUI, the transporter stops working. The message is printed as below:
TRANSPORTER: Poller[0] TRANSPORTER: 1 of 1 record(s) processed
TRANSPORTER: Poller[0] TRANSPORTER: wrong or no data
After I disable the plugin and restart apache server, the transporter again starts working.
Any idea on what the problem can be?
Thanks,
Niti
I am using CACTI 0.8.7h along with Plugin Architecture 0.8.7h v3.0 which is the latest. We have installed the latest version of transporter plugin version 0.2 which uses the old plugin architecture. However, transporter plugin works just fine by itself. We have developed a custom plugin that depends on the data generated by transporter plugin. The custom plugin also uses poller_output hook to get a notification as to when there is data in the poller tables.
When the custom plugin is enabled along with the transporter plugin from the plugin management window of CACTI GUI, the transporter stops working. The message is printed as below:
TRANSPORTER: Poller[0] TRANSPORTER: 1 of 1 record(s) processed
TRANSPORTER: Poller[0] TRANSPORTER: wrong or no data
After I disable the plugin and restart apache server, the transporter again starts working.
Any idea on what the problem can be?
Thanks,
Niti
Re: Transporter plugin does not work well with a custom plug
Is transporter returning a value from the function utilizing the poller_output hook?
For instance, Thold uses the same hook. Which calls this function
Make sure it is returning the data given to it via the arguments. If that data isn't returned, it has nothing to pass onto the next plugin.
For instance, Thold uses the same hook. Which calls this function
Code: Select all
function thold_poller_output ($rrd_update_array) {
<SNIP ALL THE CODE>
return $rrd_update_array;
}
-
- Posts: 6
- Joined: Tue Jan 24, 2012 5:35 am
Re: Transporter plugin does not work well with a custom plug
Thanks for the reply. I am now returning $rrd_update_array from the function triggered by the poller_output hook.
However, the problem is still there. What does the variable $rrd_update_array contain?
Also, I would like to share the function which is triggered by the poller_output hook. Any help will be greatly appreciated.
Many thanks,
Niti
===========================================================================
function kpipoll_poller_output($rrd_update_array){
global $config;
global $database_default;
$minutes = read_config_option("initial_polling_time");
if(read_config_option('kpipoll_enable') == 'on' ){
$query1 = "SELECT MAX(timestamp) FROM ".$database_default.".plugin_transporter_poller_output_archive";
$query2 = "SELECT lastcomputed FROM ".$database_default.".Lastcomputedtime";
$result1 = db_fetch_cell($query1);
if(empty($result1)){
kpi_pollerlog(" Source Table is empty");
return;
}
$result2 = db_fetch_cell($query2);
$maxTime=strtotime($result1);
$maxdate=date('o-m-d H:i:s',$maxTime);
if(empty($result2)){
kpi_pollerlog(" Minimum timestamp is null ");
$max5sub1=date('o-m-d H:i:s',$maxTime- $minutes * 60);
$minTime1=strtotime($max5sub1);
if($maxTime==$minTime1){
kpi_pollerlog(" Maximum and Minimum time are equal. No records processed ");
}else{
datas_insert($maxdate,$max5sub1);
}
}else{
kpi_pollerlog(" Last computed Time is ".$result2);
$lctinseconds=strtotime($result2); /* last saved */
$lastsaved=date('o-m-d H:i:s',$lctinseconds);
$minTime2=strtotime($lastsaved);
if($maxTime==$minTime2){
kpi_pollerlog(" Maximum and Minimum time are equal. No records processed ");
}else{
datas_insert($maxdate, $lastsaved);
}
}
$query3 = "TRUNCATE TABLE ".$database_default.".Lastcomputedtime";
$result3 = db_execute($query3);
$query4 = "INSERT INTO ".$database_default.".Lastcomputedtime(id,lastcomputed) values (1,'$maxdate')";
$result4 = db_execute($query4);
}
return $rrd_udpate_array;
}
================================================================================
However, the problem is still there. What does the variable $rrd_update_array contain?
Also, I would like to share the function which is triggered by the poller_output hook. Any help will be greatly appreciated.
Many thanks,
Niti
===========================================================================
function kpipoll_poller_output($rrd_update_array){
global $config;
global $database_default;
$minutes = read_config_option("initial_polling_time");
if(read_config_option('kpipoll_enable') == 'on' ){
$query1 = "SELECT MAX(timestamp) FROM ".$database_default.".plugin_transporter_poller_output_archive";
$query2 = "SELECT lastcomputed FROM ".$database_default.".Lastcomputedtime";
$result1 = db_fetch_cell($query1);
if(empty($result1)){
kpi_pollerlog(" Source Table is empty");
return;
}
$result2 = db_fetch_cell($query2);
$maxTime=strtotime($result1);
$maxdate=date('o-m-d H:i:s',$maxTime);
if(empty($result2)){
kpi_pollerlog(" Minimum timestamp is null ");
$max5sub1=date('o-m-d H:i:s',$maxTime- $minutes * 60);
$minTime1=strtotime($max5sub1);
if($maxTime==$minTime1){
kpi_pollerlog(" Maximum and Minimum time are equal. No records processed ");
}else{
datas_insert($maxdate,$max5sub1);
}
}else{
kpi_pollerlog(" Last computed Time is ".$result2);
$lctinseconds=strtotime($result2); /* last saved */
$lastsaved=date('o-m-d H:i:s',$lctinseconds);
$minTime2=strtotime($lastsaved);
if($maxTime==$minTime2){
kpi_pollerlog(" Maximum and Minimum time are equal. No records processed ");
}else{
datas_insert($maxdate, $lastsaved);
}
}
$query3 = "TRUNCATE TABLE ".$database_default.".Lastcomputedtime";
$result3 = db_execute($query3);
$query4 = "INSERT INTO ".$database_default.".Lastcomputedtime(id,lastcomputed) values (1,'$maxdate')";
$result4 = db_execute($query4);
}
return $rrd_udpate_array;
}
================================================================================
Re: Transporter plugin does not work well with a custom plug
No, I was saying is that the transporter plugin is probably not returning the array. Which is bad.
That array contains the data returned directly by the poller.
Change this
To this
and see if your plugin works any better.
Granted, with all that running in this hook, I can't imagine what its doing to the polling times.
That array contains the data returned directly by the poller.
Change this
Code: Select all
function transporter_poller_output ($rrd_update_array) {
global $config, $database_default, $debug;
if ( read_config_option('transporter_enable') != 'on' ) return;
$T = array ('dbtable','dbhistcycles');
foreach ($T as $t) {
eval("\$$t=read_config_option('transporter_$t');");
}
$dbname=$database_default;
$debug = (read_config_option('transporter_debug')=="0") ? true : false;
transporter_init($dbname,$dbtable);
transporter_process($dbtable,$dbhistcycles,&$rrd_update_array);
}
Code: Select all
function transporter_poller_output ($rrd_update_array) {
global $config, $database_default, $debug;
if ( read_config_option('transporter_enable') != 'on' ) return $rrd_update_array;
$T = array ('dbtable','dbhistcycles');
foreach ($T as $t) {
eval("\$$t=read_config_option('transporter_$t');");
}
$dbname=$database_default;
$debug = (read_config_option('transporter_debug')=="0") ? true : false;
transporter_init($dbname,$dbtable);
transporter_process($dbtable,$dbhistcycles,&$rrd_update_array);
return $rrd_update_array;
}
Granted, with all that running in this hook, I can't imagine what its doing to the polling times.
-
- Posts: 6
- Joined: Tue Jan 24, 2012 5:35 am
Re: Transporter plugin does not work well with a custom plug
Thanks for the quick reply again. I updated the transporter setup.php to return $rrd_update_array exactly as you mentioned. However, there is no luck.
I do not understand the sequence in which poller_output hook triggers events in different plugins. If I comment the registering of poller_output hook in my plugin, transporter starts polling in the data immediately.
As a side note, thold also uses poller_output hook and I have in enabled too but it works well with Transporter being enabled. Only with my custom plugin, the transporter stops working.
Any other thoughts?
Thanks/Niti
I do not understand the sequence in which poller_output hook triggers events in different plugins. If I comment the registering of poller_output hook in my plugin, transporter starts polling in the data immediately.
As a side note, thold also uses poller_output hook and I have in enabled too but it works well with Transporter being enabled. Only with my custom plugin, the transporter stops working.
Any other thoughts?
Thanks/Niti
Re: Transporter plugin does not work well with a custom plug
I do see on yours were you
return $rrd_update_array;
at the end, but you have another return in there that is returning null.
The hook will fire for the different plugin based upon their order. For older style plugins, its based upon where they are in the $plugins array.
return $rrd_update_array;
at the end, but you have another return in there that is returning null.
The hook will fire for the different plugin based upon their order. For older style plugins, its based upon where they are in the $plugins array.
-
- Posts: 6
- Joined: Tue Jan 24, 2012 5:35 am
Re: Transporter plugin does not work well with a custom plug
I updated my function to include the returning of argument as you pointed out. However, no luck.
I wanted to check one thing. I have the plugins array configured as follows and I am using the latest plugin architecture 3.0
$plugins = array();
$plugins[] = 'kpipoll';
$plugins[] = 'transporter';
$plugins[] = 'thold';
$plugins[] = 'settings';
$plugins[] = 'boost';
Is this the correct sequence? Here kpipoll is my custom plugin.
Additionally, I observed my custom plugin log and standard cacti log and I see that functions implementing the hook in both the plugins are triggered at the same time. Is this a normal behavior?
To avoid all this, is it a good idea to implement a transporter_hook similar to poller_hook and refer to that in my custom plugin? If so, what changes do I need to make?
Thanks/Niti
I wanted to check one thing. I have the plugins array configured as follows and I am using the latest plugin architecture 3.0
$plugins = array();
$plugins[] = 'kpipoll';
$plugins[] = 'transporter';
$plugins[] = 'thold';
$plugins[] = 'settings';
$plugins[] = 'boost';
Is this the correct sequence? Here kpipoll is my custom plugin.
Additionally, I observed my custom plugin log and standard cacti log and I see that functions implementing the hook in both the plugins are triggered at the same time. Is this a normal behavior?
To avoid all this, is it a good idea to implement a transporter_hook similar to poller_hook and refer to that in my custom plugin? If so, what changes do I need to make?
Thanks/Niti
Re: Transporter plugin does not work well with a custom plug
Do you want it to execute before or after transporter? As configured it should execute before.
BTW, what do you mean as "at the same time". Depending on how many processes / threads you have running, that hook will execute multiple times for each polling.
BTW, what do you mean as "at the same time". Depending on how many processes / threads you have running, that hook will execute multiple times for each polling.
-
- Posts: 6
- Joined: Tue Jan 24, 2012 5:35 am
Re: Transporter plugin does not work well with a custom plug
I tried including my plugin first in the plugin array inside config.php followed by Transporter plugin. However, it still did not work. Then I removed all the plugins including mine from the plugin array since they follow the new plugin architecture.
Only the transporter plugin uses the old plugin architecture so I kept it in config.php. It didn't help too. Do you think that because Transporter plugin is following the old plugin architecture, it might be the issue?
Also, as I asked earlier, is it possible to create a transporter hook similar to the poller_output hook? And use that in my custom plugin. If so, how can that hook be implemented?
Kindly guide me.....
Thanks/Niti
Only the transporter plugin uses the old plugin architecture so I kept it in config.php. It didn't help too. Do you think that because Transporter plugin is following the old plugin architecture, it might be the issue?
Also, as I asked earlier, is it possible to create a transporter hook similar to the poller_output hook? And use that in my custom plugin. If so, how can that hook be implemented?
Kindly guide me.....
Thanks/Niti
Who is online
Users browsing this forum: No registered users and 1 guest