Nagios Plugin for Cacti (NPC) Released

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
Nemea
Posts: 13
Joined: Tue Nov 15, 2005 10:33 am

Post by Nemea »

yes, it seems to be the mysql version

on a CoLinux system with mysql 5:

mysql>use cacti;

CREATE TABLE `npc_config_params` (`opt` char(64) NOT NULL default '',`value` int(11) default NULL,PRIMARY KEY (`opt`),UNIQUE KEY `opt` (`opt`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Nagios configuration data';
Query OK, 0 rows affected (0.08 sec)

but then

CREATE TABLE `npc_flapping_host` (`id` int(11) NOT NULL default '0',PRIMARY KEY (`id`),CONSTRAINT `flapping_host_ibfk_1` FOREIGN KEY (`id`) REFERENCES `npc_host` (`id`) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Flapping hosts';
ERROR 1005 (HY000): Can't create table './cacti/npc_flapping_host.frm' (errno: 150)


I found this:

http://forums.mysql.com/read.php?22,197 ... #msg-20340

"Try add an index..."


I updated from mysql 4.0.24 to mysql 5, cacti was installed and was working fine.

But after the upgrade cacti wasn't able to write into the db.
I can't add/view graphs.


Now I try mysql-server-4.1 ;)


edit:

Downgrade from mysql-server-5 to mysql-server-4.1 was OK.
Now my graphs in Cacti are visible again :)

but still:

mysql> CREATE TABLE `npc_flapping_host` (`id` int(11) NOT NULL default '0',PRIMARY KEY (`id`),CONSTRAINT `flapping_host_ibfk_1` FOREIGN KEY (`id`) REFERENCES `npc_host` (`id`) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Flapping hosts';
ERROR 1005 (HY000): Can't create table './cacti/npc_flapping_host.frm' (errno: 150)
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

tko, you deffinatley found a syntax error and removing that semi colon was correct.

I am correcting it and will re-upload the release.

Thanks,
Billy
Nemea
Posts: 13
Joined: Tue Nov 15, 2005 10:33 am

Post by Nemea »

with mysql 4.1 those tables have been created.

but I have a problem to get rid of the one created by myswlf:

Table npc_config_params in database cacti

SQL desc `npc_config_params` failed : Can't open file: 'npc_config_params.ibd' (errno: 1)


I tried to drop the table through webmin:

SQL select count(*) from `npc_config_params` failed : Can't open file: 'npc_config_params.ibd' (errno: 1)


and with mysql:

mysql> use cacti
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> drop table npc_config_params;
ERROR 1051 (42S02): Unknown table 'npc_config_params'


same with cacti.npc_config_params ...

what can I do to dropt that table?
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

Nemea, are you saying that you manually created a table called npc_config_params, and are unable to drop it?

Send me the output of this command:

mysql> use cacti;
mysql> SHOW CREATE TABLE npc_config_params \G

~Billy
Nemea
Posts: 13
Joined: Tue Nov 15, 2005 10:33 am

Post by Nemea »

Yes, I created that table as mentioned above.

That was after upgrading to mysql 5.

With mysql 5 the command to create that table was successful (manually with mysql>)

Then I downgraded to 4.1.

With 4.1 all other tables have been created autom. by your setup.php.

But the table that I created before (npc_config_params) isn't accessable anymore.

Maybe the downgrade deletet the file npc_config_params.ibd.

I will try that tomorrow:

mysql> use cacti;
mysql> SHOW CREATE TABLE npc_config_params \G
Nemea
Posts: 13
Joined: Tue Nov 15, 2005 10:33 am

Post by Nemea »

mysql> use cacti
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SHOW CREATE TABLE npc_config_params \G
ERROR 1016 (HY000): Can't open file: 'npc_config_params.ibd' (errno: 1)
mysql>


I will try to export everything from the cacti database without that table and create a new cacti-db.



EDIT:

1st tried to backup whole cacti-db:

Database backup failed : mysqldump failed :

mysqldump: Got error: 1016: Can't open file: 'npc_config_params.ibd' (errno: 1) when using LOCK TABLES


2nd try only the other tables:

Successfully backed up 217407 bytes from database cacti to file /opt/sql/cacti.sql.



Found this: http://bugs.mysql.com/search.php?cmd=di ... milar=5859


12852 2005-08-29
19:33 Server: InnoDB Closed
(78 days) S3 4.1, 5.0 All If .ibd file is missing and a table is opened, it cannot be dropped



I will use a fresh install....
Nemea
Posts: 13
Joined: Tue Nov 15, 2005 10:33 am

Post by Nemea »

It works :)

The downgrade from mysql-server-5 to 4.1 was the problem.

I used a backupimage from my CoLinux and upgraded 4.0.24 to 4.1 and installed nagios with inserter.o, cacti-plugin-arch and your script again.

Now everything is running fine!

Thank you very much.
jlim0930
Posts: 40
Joined: Thu Oct 27, 2005 12:07 am

Post by jlim0930 »

having problems compiling inserter.c for solaris

i am using

gcc -g -O2 -Wall -o inserter.o inserter.c -shared -I../include -I/usr/local/mysql/include/mysql -lmysqlclient -lz -fPIC

since my mysql includes are in /usr/local/mysql/include/mysql


i am getting

Code: Select all

inserter.c:43:25: mysql/mysql.h: No such file or directory
inserter.c:44:26: mysql/errmsg.h: No such file or directory
inserter.c:96: error: parse error before "mysql"
inserter.c:96: warning: type defaults to `int' in declaration of `mysql'
inserter.c:96: warning: data definition has no type or storage class
inserter.c: In function `nebmodule_init':
inserter.c:139: warning: implicit declaration of function `mysql_init'
inserter.c:143: warning: implicit declaration of function `mysql_real_connect'
inserter.c:143: error: `CLIENT_MULTI_STATEMENTS' undeclared (first use in this function)
inserter.c:143: error: (Each undeclared identifier is reported only once
inserter.c:143: error: for each function it appears in.)
inserter.c:144: warning: implicit declaration of function `mysql_error'
inserter.c:144: warning: format argument is not a pointer (arg 3)
inserter.c: In function `nebmodule_deinit':
inserter.c:166: warning: implicit declaration of function `mysql_close'
inserter.c: In function `loadconfig':
inserter.c:196: warning: implicit declaration of function `asprintf'
inserter.c: In function `querify':
inserter.c:911: warning: implicit declaration of function `mysql_real_escape_string'
inserter.c: In function `sql_dump':
inserter.c:1066: warning: implicit declaration of function `mysql_real_query'
inserter.c:1067: warning: implicit declaration of function `mysql_errno'
inserter.c:1067: warning: format argument is not a pointer (arg 2)
but i do have /usr/local/mysql/include/mysql/mysql.h
and /usr/local/mysql/include/mysql/errmsg.h
jlim0930
Posts: 40
Joined: Thu Oct 27, 2005 12:07 am

Post by jlim0930 »

ok so i changed the -I/usr/local/mysql/include/mysql to /usr/local/mysql/include and it went a bit further but still stuck..

Code: Select all

gcc -g -O2 -Wall -o inserter.o inserter.c -shared -I../include -I/usr/local/mysql/include -lmysqlclient -lz -fPIC                     
inserter.c: In function `loadconfig':
inserter.c:196: warning: implicit declaration of function `asprintf'
ld: fatal: library -lmysqlclient: not found
ld: fatal: File processing errors. No output written to inserter.o
collect2: ld returned 1 exit status
jlim0930 wrote:having problems compiling inserter.c for solaris

i am using

gcc -g -O2 -Wall -o inserter.o inserter.c -shared -I../include -I/usr/local/mysql/include/mysql -lmysqlclient -lz -fPIC

since my mysql includes are in /usr/local/mysql/include/mysql


i am getting

Code: Select all

inserter.c:43:25: mysql/mysql.h: No such file or directory
inserter.c:44:26: mysql/errmsg.h: No such file or directory
inserter.c:96: error: parse error before "mysql"
inserter.c:96: warning: type defaults to `int' in declaration of `mysql'
inserter.c:96: warning: data definition has no type or storage class
inserter.c: In function `nebmodule_init':
inserter.c:139: warning: implicit declaration of function `mysql_init'
inserter.c:143: warning: implicit declaration of function `mysql_real_connect'
inserter.c:143: error: `CLIENT_MULTI_STATEMENTS' undeclared (first use in this function)
inserter.c:143: error: (Each undeclared identifier is reported only once
inserter.c:143: error: for each function it appears in.)
inserter.c:144: warning: implicit declaration of function `mysql_error'
inserter.c:144: warning: format argument is not a pointer (arg 3)
inserter.c: In function `nebmodule_deinit':
inserter.c:166: warning: implicit declaration of function `mysql_close'
inserter.c: In function `loadconfig':
inserter.c:196: warning: implicit declaration of function `asprintf'
inserter.c: In function `querify':
inserter.c:911: warning: implicit declaration of function `mysql_real_escape_string'
inserter.c: In function `sql_dump':
inserter.c:1066: warning: implicit declaration of function `mysql_real_query'
inserter.c:1067: warning: implicit declaration of function `mysql_errno'
inserter.c:1067: warning: format argument is not a pointer (arg 2)
but i do have /usr/local/mysql/include/mysql/mysql.h
and /usr/local/mysql/include/mysql/errmsg.h
jlim0930
Posts: 40
Joined: Thu Oct 27, 2005 12:07 am

Post by jlim0930 »

got it

needed the lib

gcc -g -O2 -Wall -o inserter.o inserter.c -shared -L/usr/local/mysql/lib/mysql -I../include -I/usr/local/mysql/include -lmysqlclient -lz -fPIC
inserter.c: In function `loadconfig':
inserter.c:196: warning: implicit declaration of function `asprintf'
jlim0930
Posts: 40
Joined: Thu Oct 27, 2005 12:07 am

Post by jlim0930 »

everything was compiled and installed per instructions.

but now i am unable to get nagios to run

when i run the check on nagios everything checks out fine

but i cant get the process to keep running

this is what i found on the log file

[1132349460] LOG VERSION: 2.0
[1132349460] initializing nagios-db mysql inserter...
[1132349460] nagios-db: inserter locked into db
[1132349460] Event broker module '/usr/local/nagios/modules/inserter.o' initialized successfully.
[1132349460] Finished daemonizing... (New PID=9416)

ps -ef | grep 9416 shows nothing
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

Does Nagios run if you don't try to load the module? Also, what version of Nagios are you using?

Billy
jlim0930
Posts: 40
Joined: Thu Oct 27, 2005 12:07 am

Post by jlim0930 »

divagater wrote:Does Nagios run if you don't try to load the module? Also, what version of Nagios are you using?

Billy
yes the nagios runs stand alone..

i am using the most current version 2.0b5

thanks
User avatar
divagater
Cacti User
Posts: 191
Joined: Wed Nov 17, 2004 5:22 pm
Location: Chapel Hill, NC.
Contact:

Post by divagater »

I verified that the inserter module will run in Nagios 2.0b5 on Linux / i386. Unfortunatley, I do not have access to Solaris to try and debug the issue any further.
jlim0930
Posts: 40
Joined: Thu Oct 27, 2005 12:07 am

Post by jlim0930 »

divagater wrote:I verified that the inserter module will run in Nagios 2.0b5 on Linux / i386. Unfortunatley, I do not have access to Solaris to try and debug the issue any further.
have anyone got it to work on solaris ?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest