Nectar plugin issue?

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
xefil
Cacti User
Posts: 233
Joined: Tue Jun 20, 2006 2:48 am
Location: Italy
Contact:

Nectar plugin issue?

Post by xefil »

Hello,

After migrating (still in test) from 0.8.8a to 1.0.0 I'm seeing these errors in the log:

Code: Select all

DBCALL ERROR: SQL Assoc Failed!, Error:1054, SQL:"SELECT * FROM reports WHERE mailtime < ? AND enabled="on""
DBCALL ERROR: SQL Assoc Failed!, Error: Unknown column 'mailtime' in 'where clause'
Here the table:

Code: Select all

MariaDB [cacti]> show create table reports\G
*************************** 1. row ***************************
       Table: reports
Create Table: CREATE TABLE `reports` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL DEFAULT '',
  `hour` int(2) NOT NULL DEFAULT '0',
  `minute` int(2) NOT NULL DEFAULT '0',
  `email` text NOT NULL,
  `rtype` varchar(12) NOT NULL DEFAULT 'attach',
  `lastsent` int(32) NOT NULL DEFAULT '0',
  `daytype` text NOT NULL,
  KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mailtime is missing. Maybe upgrade fail?

Ideas?

Thanks,

Simon
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Nectar plugin issue?

Post by Osiris »

The structure was changed in 1.x. Please review the cacti.sql for the new structure and run an alter statement to get to the correct format.
Before history, there was a paradise, now dust.
jaz
Posts: 1
Joined: Thu Apr 05, 2018 1:52 pm

Re: Nectar plugin issue?

Post by jaz »

I imagine not many people are contending with this issue so long after the launch of 1.0.0, but for what it's worth, coming from a very old version of cacti + nectar, here's what I had. The old tables had been "reports" and "reports_data", and when I converted those to current report records, in freshly created "reports" and "reports_items" tables, I did that as follows:
I'm still not current on cacti, and there may be other changes by the time anyone uses this, so move carefully.

1) rename table reports to reports_bk;
rename table reports_data to reports_data_old;
2) Create tables using the sql found in cacti.sql for reports and reports_items;
3) Test the following two queries to convert the backed up data into the current tables, after testing;
For testing, I had created one new report with a variety of items, and I ran the following queries with the "insert" part first commented out, so I could compare the freshly created report to the modified selects on the old report data.
I did several iterations of this til everything seemed to look pretty good.

4) For the date field, I was lucky that I didn't need a large variety of different "first" dates. I knew I wanted them all to run the next day, so I just set the one time for all of them. You might just do that anyway, but once they're inserted, just fix them in the UI, since fixing just the one thing is probably easier than doing all the date math.

5) delete all test reports you've created, from reports and reports items, so the ids don't conflict (or write an offset into the queries below, if you already have other reports you want to keep).

6) so the actual report recreation

Code: Select all

-- insert into reports
SELECT
    id as id,
    1 as user_id,
    name as name,
    '' as cformat,
    'default.format' as format_file,
    16 as font_size,
    1 as alignment,
    '' as graph_linked,
    2 as intrvl,
    1 as count,
    0 as offset,
    unix_timestamp('2018-04-04 10:00:00') as mailtime,
    concat('Cacti Report - ',name) as subject,
    'Zayo Customer Portal' as from_name,
    'cacti@customerportal.zayo.com' as from_email,
    trim(replace(replace(replace(email,'\n',' '),'\r',' '),'\t',' ')) as email,
    '' as bcc,
    1 as attachment_type,
    200 as graph_height,
    600 as graph_width,
    1 as graph_columns,
    '' as thumbnails,
    lastsent as lastsent,
    '' as enabled
FROM cacti.reports_bk

Code: Select all

-- INSERT INTO `cacti`.`reports_items`
-- 	(`id`, `report_id`, `item_type`, `tree_id`,
-- 	`branch_id`, `tree_cascade`, `graph_name_regexp`, `host_template_id`,
-- 	`host_id`,`graph_template_id`, `local_graph_id`, `timespan`,
--     `align`, `item_text`, `font_size`, `sequence`)
SELECT 
	rdo.id,
	reportid,
	case item when 'graph' then 1 when 'text' then 2 when 'tree' then 3 else 0 end as item_type,
	0 as tree_id,
	0 as branch_id,
	'' as tree_cascade,
	'' as graph_name_regexp,
	case when item != 'graph' then 0 else h.host_template_id end as host_template_id, -- host tmpl id
	rdo.hostid,
	case when item != 'graph' then 0 else gl.graph_template_id end as graph_template_id, 
	case when item != 'graph' then 0 else rdo.local_graph_id end as local_graph_id, -- loc gr id
	8,
	1,
	case when data != '' and data is not null then data else '' end as item_text,
	16,
	rdo.gorder -- sequence
FROM reports_data_old rdo
	left join graph_local gl on rdo.local_graph_id = gl.id
	left join `host` h on  h.id = rdo.hostid
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests