Case-insensitive objects in NDOutils

Ton Voon ton.voon at opsera.com
Thu Oct 22 05:33:27 CEST 2009


Hi Hendrik,

Quick note. I saw this change below and wondered if this is best done  
in the database. For Opsview, we made this change about 2 years ago  
for the same effect:

     ALTER TABLE nagios_objects MODIFY name1 varchar(128) COLLATE  
latin1_bin NOT NULL default '';
     ALTER TABLE nagios_objects MODIFY name2 varchar(128) COLLATE  
latin1_bin default NULL;

The code then stayed the same. Also it means anything trying to read  
the data doesn't need to remember to specify BINARY either.

I agree it is bad to consider them as the same object.

I thought I had blogged about it, but maybe it was a permanent draft ...

Ton


Begin forwarded message:

> From: Hendrik Baecker <hendrikb at users.sourceforge.net>
> Date: 21 October 2009 20:18:39 BST
> To: nagios-checkins at lists.sourceforge.net
> Subject: [Nagios-checkins] ndoutils/src dbhandlers.c,1.13,1.14
>
> Update of /cvsroot/nagios/ndoutils/src
> In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv411/src
>
> Modified Files:
> 	dbhandlers.c
> Log Message:
> Fix case insensitive behavior in ndo2db
>
> NDO2DB now handles renamed objects like Nagios itself. Renaming is  
> deleting
> the old and creating a new object.
>
> Why change this and possibly loose historical data based on the same  
> database
> object id?
> Think about the following:
> Nagios knows a "localhost" and a "LOCALHOST" two different objects.
> NDOUtils (without this patch) would handle both objects as the same
> including all references like services, state changes and so on.
>
> NDOUtils would mix two different objects together - this can't be  
> right.
>
>
>
> Index: dbhandlers.c
> ===================================================================
> RCS file: /cvsroot/nagios/ndoutils/src/dbhandlers.c,v
> retrieving revision 1.13
> retrieving revision 1.14
> diff -C2 -d -r1.13 -r1.14
> *** dbhandlers.c	6 Oct 2009 06:34:52 -0000	1.13
> --- dbhandlers.c	21 Oct 2009 19:18:37 -0000	1.14
> ***************
> *** 82,86 ****
>  	else{
>  		es[0]=ndo2db_db_escape_string(idi,name1);
> ! 		if(asprintf(&buf1,"name1='%s'",es[0])==-1)
>  			buf1=NULL;
>  	        }
> --- 82,86 ----
>  	else{
>  		es[0]=ndo2db_db_escape_string(idi,name1);
> ! 		if(asprintf(&buf1,"BINARY name1='%s'",es[0])==-1)
>  			buf1=NULL;
>  	        }
> ***************
> *** 93,97 ****
>  	else{
>  		es[1]=ndo2db_db_escape_string(idi,name2);
> ! 		if(asprintf(&buf2,"name2='%s'",es[1])==-1)
>  			buf2=NULL;
>  	        }
> --- 93,97 ----
>  	else{
>  		es[1]=ndo2db_db_escape_string(idi,name2);
> ! 		if(asprintf(&buf2,"BINARY name2='%s'",es[1])==-1)
>  			buf2=NULL;
>  	        }
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart  
> your
> developing skills, take BlackBerry mobile applications to market and  
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Nagios-checkins mailing list
> Nagios-checkins at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-checkins

Ton Voon
Product Architect




Opsera Limited | Unit 69 Suttons Business Park
Reading | Berkshire | RG6 1AZ | UK

Phone:   +44 (0) 845 057 7887
Mobile:   +44 (0) 7931 365796
Skype:   tonvoon     Email:   ton.voon at opsera.com
www.opsera.com
This e-mail is confidential, intended only for the named recipient(s)  
above and may contain information that is privileged and confidential.  
If you receive this message in error, or are not the named  
recipient(s), please notify the sender at the phone number above, do  
not copy this message, do not disclose its contents to anyone, and  
delete this e-mail message from your computer. Although Opsera  
routinely screens for viruses, addressees should scan this e-mail and  
any attachments for viruses. Opsera makes no representation or  
warranty as to the absence of viruses in this e-mail or any  
attachments. Opsera Limited is registered in the UK under Company  
Number 5396532. Our registered office is Gorse View, Horsell Rise,  
Woking, Surrey, GU21 4RB.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20091022/ee204b2a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 749 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20091022/ee204b2a/attachment.gif>
-------------- next part --------------
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list