nap wrote:

Thanks for this. So in Mysql it's trivial, and in others it's rather complex :)

In this special use case - yes. It was designed like that, and for sure not by a rdbms guru otherwise the algorithm on update/insert would have been a bit more logical and performing than in originating ndoutils code.


I'll look at your code to see the tricks, sounds quite very good :)

my code is rather dirty too, so don't expect too much. the prepared statements for oracle reside at bottom of db.c and most of them are used in dbqueries.c where the insert/update functions reside. you can also see the first attempt of postgres implementation over there. the oracle stuff binds params using ocilib's functions, so you'd need to keep a bit pastebin aside to the original code in order to build up a full query ;-) the void *data[] is a bit of an dirty not-type-safe way of passing many variables all over the place. makes the code unmaintainable though ;)

although i will change several things in the near future, so please keep an eye on the git master or my branches.

Hopefully here the duplicate is not a "huge problem" because it's really the same data, so it's jsut notice instead of warning. But if we can manage it in a clean way it's better of course :)

as mentioned, i am not aware of the centreon selects, but if they do a select distinct and ignore duplicates within their queries, the unique keys might be removed on the schema, ignoring such things. it only affects xxx rows and slower select/update if not using indexes and such. and those are only the configuration tables for contacts which are 'not that much in use'.


Thanks for all the tips :)

you are very welcome :) at least one stage we can combine knowledge - and not discussing about our different opinions on the coding language ;-)

kind regards,
Michael



Jean


    kind regards,
    Michael



    Jean

    On Sun, Jan 16, 2011 at 12:45 PM, Michael Friedrich
    <michael.friedr...@univie.ac.at
    <mailto:michael.friedr...@univie.ac.at>> wrote:

        On 16.01.2011 08:33, nap wrote:
        Oh thanks a lot, so I'll make it mysql backend only :)

        you might check the unique key instead and adapt the schema a
        bit then (not causing duplicate key violations), if it's not
        up to major changes/many rows then. but i am not sure how the
        centreon select logic works, so i'd vote for a clean (old
        grown compatible) solution then.

        kind regards,
        Michael



        Jean

        On Sat, Jan 15, 2011 at 6:04 PM, Michael Friedrich
        <michael.friedr...@univie.ac.at
        <mailto:michael.friedr...@univie.ac.at>> wrote:

            On 15.01.2011 13:31, nap wrote:
            I think I'll change the insert into replace. There are
            some tables that don't have an id for the configuration
            instance, and so duplicate cannot be avoid.

            consider that replace into is not available for
            postgres/oracle. you'll need kind of an upsert logic
            either realized by merge in oracle, or straight upsert
            procedures. mysql is simple with the insert on duplicate
            key update statement as an alternative, but this is non
            sql standard.

            kind regards,
            Michael




            Jean

            On Fri, Jan 14, 2011 at 5:05 PM, Tanguy von Stebut
            <tanguy.von.ste...@gmail.com
            <mailto:tanguy.von.ste...@gmail.com>> wrote:

                Hello folks,

                I've been trying to use Shinken with Centreon 2 as
                it is actually
                "wired" with a NdoDB over MySQL by default, and I
                also needed to
                produce a PoC of Shinken with a DB broker. For sure
                Centreon is still
                attractive for my boss...

                So, I configured the broker to connect to a
                Centreon - ndo - db that
                resides on an other VM.
                I could verify a simple command line connection
                with the user centreon.

                But now, when looking at the broker' logs, I can
                see Database
                integrity Warning returned by the remote MySQL DB.

                Ok, staying positive, I can say the broker' conf is
                good, but I'm
                worrying about the do-ability of the solution.
                Please let me know if
                you have some clue :)

                Here comes an extract of the broker o' log :

                {code}[CODE]
                IOError: [Errno 2] No such file or directory:
                '/usr/local/shinken/var/archives/nagios-01-14-2011-
                00.log'
                
/usr/lib/python2.6/site-packages/Shinken-0.4-py2.6.egg/shinken/db_mysql.py:58:
                Warning: Out of ra
                nge value adjusted for column 'last_command_check'
                at row 1
                 self.db_cursor.execute(query)
                
/usr/lib/python2.6/site-packages/Shinken-0.4-py2.6.egg/shinken/db_mysql.py:58:
                Warning: Out of ra
                nge value adjusted for column 'last_log_rotation'
                at row 1
                 self.db_cursor.execute(query)
                [MysqlDB] Warning : a query raise an integrity
                error : INSERT INTO
                nagios_contacts  (instance_id , alias ,
                contact_object_id ,
                host_notifications_enabled , pager_address ,
                service_notifications_enabled , email_address ,
                contact_id  ) VALUES
                ('2' , 'none' , '2' , '1' , 'none' , '1' ,
                'napar...@gmail.com <mailto:napar...@gmail.com>' , '2'
                ), (1062, "Duplicate entry '2' for key 1")
                [MysqlDB] Warning : a query raise an integrity
                error : INSERT INTO
                nagios_contactgroups  (contactgroup_id ,
                instance_id , config_type ,
                alias , contactgroup_object_id  ) VALUES ('1' , '2'
                , '0' , 'admins' ,
                '1'  ), (1062, "Duplicate entry '1' for key 1")
                [MysqlDB] Warning : a query raise an integrity
                error : INSERT INTO
                nagios_hostgroups  (instance_id , alias ,
                config_type , hostgroup_id ,
                hostgroup_object_id  ) VALUES ('2' , 'Serveurs de
                la bulle M' , '0' ,
                '1' , '75'  ), (1062, "Duplicate entry '1' for key 1")
                [/CODE]{code}

                Regards,

                Tanguy von Stebut

                
------------------------------------------------------------------------------
                Protect Your Site and Customers from Malware Attacks
                Learn about various malware tactics and how to
                avoid them. Understand
                malware threats, the impact they can have on your
                business, and how you
                can protect your company and customers by using
                code signing.
                http://p.sf.net/sfu/oracle-sfdevnl
                _______________________________________________
                Shinken-devel mailing list
                Shinken-devel@lists.sourceforge.net
                <mailto:Shinken-devel@lists.sourceforge.net>
                https://lists.sourceforge.net/lists/listinfo/shinken-devel




            
------------------------------------------------------------------------------
            Protect Your Site and Customers from Malware Attacks
            Learn about various malware tactics and how to avoid them. 
Understand
            malware threats, the impact they can have on your business, and how 
you
            can protect your company and customers by using code signing.
            http://p.sf.net/sfu/oracle-sfdevnl


            _______________________________________________
            Shinken-devel mailing list
            Shinken-devel@lists.sourceforge.net  
<mailto:Shinken-devel@lists.sourceforge.net>
            https://lists.sourceforge.net/lists/listinfo/shinken-devel


            
------------------------------------------------------------------------------
            Protect Your Site and Customers from Malware Attacks
            Learn about various malware tactics and how to avoid
            them. Understand
            malware threats, the impact they can have on your
            business, and how you
            can protect your company and customers by using code
            signing.
            http://p.sf.net/sfu/oracle-sfdevnl
            _______________________________________________
            Shinken-devel mailing list
            Shinken-devel@lists.sourceforge.net
            <mailto:Shinken-devel@lists.sourceforge.net>
            https://lists.sourceforge.net/lists/listinfo/shinken-devel




        
------------------------------------------------------------------------------
        Protect Your Site and Customers from Malware Attacks
        Learn about various malware tactics and how to avoid them. Understand
        malware threats, the impact they can have on your business, and how you
        can protect your company and customers by using code signing.
        http://p.sf.net/sfu/oracle-sfdevnl


        _______________________________________________
        Shinken-devel mailing list
        Shinken-devel@lists.sourceforge.net  
<mailto:Shinken-devel@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/shinken-devel


        
------------------------------------------------------------------------------
        Protect Your Site and Customers from Malware Attacks
        Learn about various malware tactics and how to avoid them.
        Understand
        malware threats, the impact they can have on your business,
        and how you
        can protect your company and customers by using code signing.
        http://p.sf.net/sfu/oracle-sfdevnl
        _______________________________________________
        Shinken-devel mailing list
        Shinken-devel@lists.sourceforge.net
        <mailto:Shinken-devel@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/shinken-devel




    
------------------------------------------------------------------------------
    Protect Your Site and Customers from Malware Attacks
    Learn about various malware tactics and how to avoid them. Understand
    malware threats, the impact they can have on your business, and how you
    can protect your company and customers by using code signing.
    http://p.sf.net/sfu/oracle-sfdevnl


    _______________________________________________
    Shinken-devel mailing list
    Shinken-devel@lists.sourceforge.net  
<mailto:Shinken-devel@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/shinken-devel


    
------------------------------------------------------------------------------
    Protect Your Site and Customers from Malware Attacks
    Learn about various malware tactics and how to avoid them. Understand
    malware threats, the impact they can have on your business, and
    how you
    can protect your company and customers by using code signing.
    http://p.sf.net/sfu/oracle-sfdevnl
    _______________________________________________
    Shinken-devel mailing list
    Shinken-devel@lists.sourceforge.net
    <mailto:Shinken-devel@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/shinken-devel



------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl


_______________________________________________
Shinken-devel mailing list
Shinken-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shinken-devel


--
DI (FH) Michael Friedrich

Vienna University Computer Center
Universitaetsstrasse 7 A-1010 Vienna, Austria

email:  michael.friedr...@univie.ac.at
phone:  +43 1 4277 14359
fax:    +43 1 4277 14338
web:    http://www.univie.ac.at/zid
        http://www.aco.net

Icinga Core&  IDOUtils Developer
http://www.icinga.org

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Shinken-devel mailing list
Shinken-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shinken-devel

Reply via email to