Page 1 of 1

Nagios XI 5.4.3 Rest API

Posted: Tue Apr 04, 2017 2:46 pm
by bennyboy
Hi,

I use a lot your rest api and it's working fine. I think I found 1 exception you have to handle or help me to understand the result I have. I debug a lot my code and the only explaination I have is the rest api is not case sensitive.

I make sure Nagios XI already have that check before :

Code: Select all

           {
                "@attributes": {
                    "id": "8963"
                },
                "instance_id": "1",
                "host_name": "servername",
                "service_description": "Disk Usage on \/opt\/IBM",
                "is_active": "1",
                "config_type": "1",
                "display_name": "Disk Usage on \/opt\/IBM",
                "check_interval": "5",
                "retry_interval": "1",
                "max_check_attempts": "5",
                "first_notification_delay": "0",
                "notification_interval": "60",
                "passive_checks_enabled": "1",
                "active_checks_enabled": "1",
                "notifications_enabled": "1",
                "notes": "",
                "notes_url": "",
                "action_url": "",
                "icon_image": "",
                "icon_image_alt": ""
            },
I try to add another check by the API with that payload :

Code: Select all

{'service_description': u'Disk Usage on /opt/ibm', 'use': 'xi_prod_middle_ncpa_service', 'check_command': u"check_xi_ncpa!-t 'mytoken' -P 5693 -M 'disk/logical/|opt|ibm' -u M -w 90 -c 95!!!!!!!", 'force': '1', 'host_name': 'servername'}
I see an update of my original check instead of add a new check. I really have two file system /opt/IBM and /opt/ibm.
Normaly I use my python script to automagicaly add all the stuff I want to monitor by NCPA to NAgios XI. It's working fine. I also try the same patern with a simple curl -XPOST and I have the same result. I have to use force=1 because I use template. If you need more detail I will do my best but keep in mind I normaly speak/write in french and I do my best to explain :) (Google Translate)


Thank you!

Re: Nagios XI 5.4.3 Rest API

Posted: Wed Apr 05, 2017 9:55 am
by lmiltchev
I was able to recreate the issue, and notified our developers. They will be looking into this problem as soon as they can. Hopefully, we will have a patch/workaround soon. Thanks!

Re: Nagios XI 5.4.3 Rest API

Posted: Wed Apr 05, 2017 10:59 am
by lmiltchev
Update: The problem is caused by the fact that the table collation for tbl_service is utf8_general_ci which is case insensitive (the ci). Unfortunately, it looks like utf8 doesn't have a case sensitive (cs) version for collation. As a "workaround" you could use "utf8_bin", however it could cause issues with ORDER BY... So use it at your own risk.

You can run the following command to convert the character set on tbl_service:

Code: Select all

echo 'ALTER TABLE tbl_service CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;' | mysql -t -uroot -pnagiosxi nagiosql
To verify:

Code: Select all

echo "show table status like 'tbl_service'" | mysql -t -uroot -pnagiosxi nagiosql
You can do the same for tbl_host if you wish:

Code: Select all

echo 'ALTER TABLE tbl_host CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;' | mysql -t -uroot -pnagiosxi nagiosql
echo "show table status like 'tbl_host'" | mysql -t -uroot -pnagiosxi nagiosql
If you decide to change it back, run:

Code: Select all

echo 'ALTER TABLE tbl_service CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' | mysql -t -uroot -pnagiosxi nagiosql
echo 'ALTER TABLE tbl_host CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' | mysql -t -uroot -pnagiosxi nagiosql
Note: If you changed the default root mysql password, you will need to modify the above commands.

Hope this helps.

Re: Nagios XI 5.4.3 Rest API

Posted: Wed Apr 05, 2017 12:28 pm
by bennyboy
Are you sure that the reason for ... I create the service check manually and it's working.

/opt/IBM and /opt/ibm for the same host and it's working. I think the limitation is only by the rest api.

https://imagebin.ca/v/3I2wgFvjhTB6

Re: Nagios XI 5.4.3 Rest API

Posted: Wed Apr 05, 2017 1:53 pm
by mcapra
The technical answer:
https://dev.mysql.com/doc/refman/5.7/en ... ivity.html

When doing inserts into a case-insensitive MySQL database, the data will be represented correctly in regards to case. If I insert FOO, then FOO is what gets stored. The problem comes only when you're executing some sort of search. In case-insensitive collations, like utf8_general_ci, I could search "FOO" or "foo" and get the same result.

Re: Nagios XI 5.4.3 Rest API

Posted: Wed Apr 05, 2017 2:07 pm
by bennyboy
Do you plan to fix that in futur release ? I don't want to alter our mariadb and having problem in future update.

Re: Nagios XI 5.4.3 Rest API

Posted: Wed Apr 05, 2017 4:34 pm
by mcapra
It's unlikely that we will change the table's collation in a future version. Mostly because relying on the default collations available in cent 5/6/7 saves a lot of headaches.