Cacti / plugin_monitor

Monitor Plugin for Cacti
GNU General Public License v2.0
36 stars 39 forks source link

Monitor 2.3.6 A DB Exec Failed!, Error: Column 'monitor' cannot be null #126

Closed bmfmancini closed 1 year ago

bmfmancini commented 4 years ago

Monitor Version 2.3.6 cacti Version 1.2.9

Issue:

When you delete all devices and start from 0 devices when you attempt to add a new device either manually or through Autom8 the following error occurs

A DB Exec Failed!, Error: Column 'monitor' cannot be null you will then see all device additions will fail

If you disable the monitor plugin the issue goes away if you re-enable monitor after the first device is created the issue with monitor is resolved as well

bmfmancini commented 4 years ago

I believe the issue could be the monitor colum is set to Null no

monitor | char(3) | NO | | on | |

bmfmancini commented 4 years ago

Ok I was able to fix this issue at least for me

ALTER TABLE host MODIFY monitor varchar(255) null;

monitor | varchar(255) | YES | | NULL | |

No more errors so far still testing

netniV commented 4 years ago

I would say that monitor should always be empty as default not null.

bmfmancini commented 4 years ago

Hmm ok so does the script need to be updated for that ?

By default the entry into the DB is NULL no changing it to yes seems to correct the issue Ive tested it multiple times now in the lab without issues since that change

netniV commented 4 years ago

not sure how you've managed to get that setup then as this is the current table addition code:

api_plugin_db_add_column ('monitor', 'host', array('name' => 'monitor', 'type' => 'char(3)', 'NULL' => false, 'default' => 'on', 'after' => 'disabled'));

As you can see, the default should be set to 'on' which means it's active. You should be able to update this to match by using:

ALTER TABLE `host` MODIFY `monitor` CHAR(3) NOT NULL default 'on';

I would suggest that before you run the above, you run the following before and after to monitor changes:

SHOW CREATE TABLE `host`\G
bmfmancini commented 4 years ago

Ok I made the change seems to be fine but I swear all I have is the dev branch files are we sure something wasn't tweaked in the code that changed that ?

netniV commented 4 years ago

Use git log -L to check the history of lines in a file. It's how I usually tell @cigamit or @TheWitness which one broke something (unless of course I did, then I just quietly fix it).

TheWitness commented 4 years ago

@netniV wise guy. True though.

TheWitness commented 1 year ago

This is resolved in the to be released 2.6