Nagios / check_mk - Duplicate host - duplicates

I've been having a dupliate host problem with nagios3 and check_mk from the Jessie repos.
After installing and config nagios3, I added my web.cfg for nagios.
I wanted to additional chekcs done by check_mk, so added the hosts to main.mk.
Then check_mk -I, -II and finally -U
-U will generate the first check_mk_commands but it contains an "host" definition. If I remove it and cat check_mk_commands > web.cfg it has depenceies problems.
If I remove the host definition from my web.cfg of nagios, there is still the same problem: duplicate host entry in "web.cfg"
I checked cfg_dir and nothing is included twice.
I am doing the same thing #work and it works.
Is there a way to tell check_mk not to do the host definition, I've spent 5 days of this.
Let me know if want some pasties, but I nailed the problem: check_mk does an host definition that is already in my nagios webserver monitoring configuration.
Removing the definition from one or the other doesn't work.
Even copyiing check_mk_commands.cfg without the host into my nagios3 config won't work due to missing templates.
Anyone encountered this problem ?
Please let me know, 6th day on this..

/usr/share/check_mk/modules/config.py has a variable that's called 'generate_hostconf' which is True by default.
If you change this to False, check_mk will not generate the host_config.
EDIT: This should be done in main.mk or any conf.d/*.mk files since it's not nice to edit core files.
/etc/check_mk/conf.d/no_host_config.mk:
generate_hostconf = False

Related

How to connect to local MySQL Server 8.0 with DBIish in Perl6

I'm working on a Perl6 project, but having difficulty connecting to MySQL. Even when using the DBIish (or perl6.org tutorial) example code, the connection fails. Any suggestions or advice is appreciated! User credentials have been confirmed accurate too.
I'm running this on Windows 10 with MySQL Server 8.0 and standard Perl6 with Rakudo Star. I have tried modifying the connection string in numerous ways like :$password :password<> :password() etc. but can't get a connection established. Also should note that I have the ODBC, C, C++, and.Net connectors installed.
#!/usr/bin/perl6
use v6.c;
use lib 'lib';
use DBIish;
use Register::User;
# Windows support
%*ENV<DBIISH_MYSQL_LIB> = "C:/Program Files/MySQL/MySQL Server 8.0/liblibmysql.dll"
if $*DISTRO.is-win;
my $dbh = DBIish.connect('mysql', :host<localhost>, :port(3306), :database<dbNameHere>, :user<usernameHere>, :password<pwdIsHere>) or die "couldn't connect to database";
my $sth = $dbh.prepare(q:to/STATEMENT/);
SELECT *
FROM users
STATEMENT
$sth.execute();
my #rows = $sth.allrows();
for #rows { .print }
say #rows.elems;
$sth.finish;
$dbh.dispose;
This should be connecting to the DB. Then the app runs a query, followed by printing out each resulting row. What actually happens is the application hits the 'die' message every time.
This is more of a work around, but being unable to use use a DB is crippling. So even when trying to use the NativeLibs I couldn't get a connection via DBIish. Instead I have opted to using DB::MySQL which is proving to be quite helpful. With a few lines of code this module has your DB needs covered:
use DB::MySQL;
my $mysql = DB::MySQL.new(:database<databaseName>, :user<userName>, :password<passwordHere>);
my #users = $mysql.query('select * from users').arrays;
for #users { say "user #$_[0]: $_[1] $_[2]"; }
#Results would be:
#user #1: FirstName LastName
#user #2: FirstName LastName
#etc...
This will print out a line for each user formatted as shown above. It's not as familiar as DBIish, but this module gets the job done as needed. There's plenty more you can do with it to, so I highly recommend reading the docs.
According to this github DBIish issue 127
The environmental variable DBIISH_MYSQL_LIB was removed. I don't know if anyone brought it back.
However if you add the library's path, and the file is named mysql.dll, it will work. Not a good result for the scientific method.
So more testing is needed - and perhaps
C:\Program Files\MySQL\MySQL Server 8.0\lib>mklink mysql.dll .\libmysql.dll
Oviously you can create your own lib directory and add that to your path and then add this symlink to that directory.
Hope this helps. I've spent hours..
EDIT: Still spending time - accounting later.
Something very transitory is going on. I reset the machine (perhaps always do this from now on), and still got the missing mysql.dll errors. Tried going into the MySQL lib directory to execute raku from there.. worked. changed directories.. didn't work.
Launched administrator cmd - from home directory, tried the raku command. Worked. Ok - not good, but perhaps consistent. Launched non admin cmd, tried it from the MySQL lib directory, worked. And just for giggles, tried it outside of that directory.. worked.
Now I can't get it not to work. Will explore NativeLibs::Searcher as Valle Lukas suggested!
Maybe the example in the dbiish repository is not valid anymore.
The DBIISH_MYSQL_LIB Env seems to be replaced by NativeLibs::Searcher with commit 9bc4191
Looking at NativeLibs::Searcher may help to find the root cause of the problem.

redis.conf include: "Bad directive or wrong number of arguments"

I've created this config for redis [/etc/redis/map.conf]:
include /etc/redis/ideal.conf
port 11235
pidfile /var/run/redis-map.pid
logfile /var/log/redis/map.log
dbfilename map.rdb
As you can see, it includes /etc/redis/ideal.conf; this file actually exists and we have read permissions.
Also there is another file, slightly different; consider [/etc/redis/storage.conf]:
include /etc/redis/ideal.conf
pidfile /var/run/redis-storage.pid
port 8000
bind 192.168.0.3
logfile /var/log/redis/storage.log
dbfilename dump_storage.rdb
My problem is: I can launch redis-server with storage.conf (and everything works fine), but map.conf leads to the following error:
Reading the configuration file, at line 1
>>> 'include /etc/redis/ideal.conf'
Bad directive or wrong number of arguments
failed
Version of redis is 2.2.
Where did I go wrong?
Sorry guys.
I was using different instances of Redis.
Instance for storage.conf was launched by /usr/local/bin/redis-server, but map.conf launched by /usr/bin/redis-server; second one is broken.
Thank you anyway.

add_rosteritem not working with xml_rpc in ejabberd server

I have configure ejabberd server 2.1.10 with mysql database integration,mod_admin_extra module and mod_xmlrpc module.
Issues is ejaberd admin commands like add_rosteritem, delete_rosteritem are notworking with xml_rpc.
When we use direct command line like,
*root#ejabberdserver:~# ejabberdctl add_rosteritem admin domain.com karthik domain.com karthik none both*
it will work and store in to database.
but same command does not work with xml_rpc.
xml_rpc does not return any error, it retun {ok,{response,[0]}}
But it does't store database.
Any permission issue?
Any body please help!!!!!
I meet the similar issue recently, and turn out the root cause was there a bug in (svn)ejabberd_module source code, and this was reported in https://github.com/processone/ejabberd-contrib/issues/22 and fixed in ejabberd-contrib,
So I suggest you download the source https://github.com/processone/ejabberd-contrib and rebuild the mod_admin_extra.

Wordpress ==> SSL ==> MySQL is this configuration possible?

I am trying to put SSL encryption between my Wordpress application and its MySQL database, is anyone aware of a solution/tutorial for this? Haven't managed to find anything on Google or the Wordpress codex.
Further to #ticoombs response, and after some digging / testing, I found that by changing the constant defined in wp-config.php (in the root directory) to the following it worked!
define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);
...note the extra "I" in MYSQLI_CLIENT_SSl.
Symptoms: The symptom I observed was that the call to mysql_connect in /wp-includes/wp-db.php was generating a warning that parameter 8 (i.e. $client_flags) was not an integer.
Version: Vanilla install of 4.8.1, running on php 7.0
Yes. It is possible to connect Wordpress to mysql using SSL. Add define('DB_SSL', true); to your wp-config.php file and take a look at this:
http://wordpress.org/support/topic/wordpress-with-mysql-over-ssl
Just to build on the answer:
File Location: /wordpress/wp-includes/wp-db.php
From:
$client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
To:
$client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : MYSQL_CLIENT_SSL;
Currently WP should be able to handle adding, (below) to the wp-config.php. (But in my findings i have not been able to get it to work.
define('MYSQL_CLIENT_FLAGS', MYSQL_CLIENT_SSl);
I wrote a good blog post on the matter.
Source

MySQL driver segfaulting under mod_perl - where to look for issue

I have a webapp that segfaults when the database in restarted and it tries to use the old connections. Running it under gdb --args apache -X leads to the following output:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1212868928 (LWP 16098)]
0xb7471c20 in mysql_send_query () from /usr/lib/libmysqlclient.so.15
I've checked that the drivers and database are all up to date (DBD::mysql 4.0008, MySQL 5.0.32-Debian_7etch6-log).
Annoyingly I can't reproduce this with a trivial script:
use DBI;
use Test::More tests => 2;
my $dbh = DBI->connect( "dbi:mysql:test", 'root' );
sub test_db {
my ($number) = $dbh->selectrow_array("select 1 ");
return $number;
}
is test_db, 1, "connected to db";
warn "restart db now";
getc;
is test_db, 1, "connected to db";
Which gives the following:
ok 1 - connected to db
restart db now at dbd-mysql-test.pl line 23.
DBD::mysql::db selectrow_array failed: MySQL server has gone away at dbd-mysql-test.pl line 17.
not ok 2 - connected to db
# Failed test 'connected to db'
# at dbd-mysql-test.pl line 26.
# got: undef
# expected: '1'
This behaves correctly, telling me why the request failed.
What stumps me is that it is segfaulting, which it shouldn't do. As it only appears to happen when the whole app is running (which uses DBIx::Class) it is hard to reduce it to a test case.
Where should I start to look to debug this? Has anyone else seen this?
UPDATE: further prodding showed that it being under mod_perl was a red herring. Having reduced it to a simple test script I've now posted to the DBI mailing list. Thanks for your answers.
What this probably means is that there's a difference between your mod_perl environment and the one you were testing via your script. Some things to check:
Was your mod_perl compiled with the same version of Perl
Are the #INC's the same for both
Are you using threads in your mod_perl setup? I don't believe DBD::mysql is completely thread-safe.
I've seen this problem, but I'm not sure it had the same cause as yours. Are you by chance using a certain module for sending mails (forgot the name, sorry) from your application? When we had the problem in a project, after days of debugging we found that this mail module was doing strange things with open file descriptors, then forked off another process which called the console tool sendmail, which again did strange things with file descriptors. I guess one of the file descriptors it messed around with was the connection to the database, but I'm still not sure about that. The problem disappeared when we switched to another module for sending mails. Maybe it's worth a look for you too.
If you're getting a segfault, do you have a core file greated? If not, check ulimit -c. If that returns 0, your system won't create core files and you'll have to change that. If you do have a core file, you can use gdb or similar tools to debug it. It's not particularly fun, but it's possible. The start of the command will look something like:
gbd /usr/bin/httpd core
There are plenty of tutorials for debugging core files scattered about the Web.
Update: Just found a reference for ensuring you get core dumps from mod_perl. That should help.
This is a known problem in old DBD::mysql. Upgrade it (4.008 is not up to date).
There's a simple test script attached to https://rt.cpan.org/Public/Bug/Display.html?id=37027
that will trigger this bug.