Announcement

Collapse
No announcement yet.

resource.cfg

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • resource.cfg

    As you may already know, I am running a Nagios 1.3 with a MySQL Database and Oreon (with it Database).
    My Problem actually is the resource.cfg of Nagios. Everytime I generate the Oreon Files my entries in this cfg will be deleted
    Part of my original resource.cfg that I use and that I really need:

    # Sets $USER1$ to be the path to the plugins
    $USER1$=/usr/lib/nagios/plugins

    # Sets $USER2$ to be the path to event handlers
    $USER2$=/usr/lib/nagios/plugins/eventhandlers

    # Store some usernames and passwords (hidden from the CGIs)
    #$USER3$=someuser
    #$USER4$=somepassword
    $USER5$=/usr/local/nagios/libexec

    # DB STATUS DATA
    # Note: These config directives are only used if you compiled
    # in database support for status data!
    # The user you specify here needs SELECT, INSERT, UPDATE, and
    # DELETE privileges on the 'programstatus', 'hoststatus',
    # and 'servicestatus' tables in the database.

    #xsddb_host=xxxxxxx
    #xsddb_port=xxxx
    xsddb_database=xxxxx
    xsddb_username=xxxxx
    xsddb_password=xxxxx
    #xsddb_optimize_data=x
    #xsddb_optimize_interval=xxxx
    You see there is not always somethings with paths to directorys, I need
    it more to handle the Nagios Database (Authorisation)

    How can I deal with Oreon that it won't destroy my resource.cfg or I can add my original resource.cfg lines to the one generated by oreon ?
    I know that I can add lines to oreon resource.cfg with $USERn$ and command lines but nothing more.
    Can you give me tips how to solve this problem or take this as a bug and solve in the near future ???

    Help is very welcome

    dobebo

  • #2
    hi dobebo,

    a quick fix, no tested :?

    in 'include/export/nagios_resource.php' :
    function Create_resource($oreon, $path)
    {
    $str = NULL;
    $handle = create_file($path . "resource.cfg", $oreon->user->get_firstname(), $oreon->user->get_lastname());
    if (isset($oreon->resourcecfg) && count($oreon->resourcecfg)) {
    $resourcecfg = & $oreon->resourcecfg;
    foreach ($resourcecfg as $r){
    if ($r->get_comment()){
    $str .= "#".str_replace("\n", "\n#", $r->get_comment())."\n";
    }
    if ($r->get_line()){$str .= $r->get_line()."\n";}
    unset($r);
    }
    }
    $str .= "xsddb_database=xxxxx\n";
    $str .= "xsddb_username=xxxxx\n";
    $str .= "xsddb_password=xxxxx\n";

    write_in_file($handle, $str, $path . "resource.cfg");
    fclose($handle);
    }
    but you can add a feature request
    StatusMap Module - NDO Tools Module - ImportCSV Module - SNMP-UI Module - PDFReports Module
    Dons Paypal

    Comment


    • #3
      OK, I'll give it a try, but you should make the Options for the resource.cfg more flexible.


      Greets
      dobebo

      Comment


      • #4
        Hi,

        2 steps.

        First correct the class/NagiosConfigFile.class.php line 49 :
        Code:
        if (preg_match("/^[ \t]*[\$]USER([0-9]+)[\$][ \t]*=[ \t]*(.+)/", $lines[$i], $regs))	{
        So now when you upload your resource.cfg file, the comment line will not be upload.

        After, like Wistof said, add the three lines to generate the value you want.
        Romain Le Merlus
        Centreon Forge
        MERETHIS

        Comment


        • #5
          Originally posted by dobebo
          OK, I'll give it a try, but you should make the Options for the resource.cfg more flexible.


          Greets
          dobebo
          Yes for sure, if you can list here the different case we can find it could be great.
          Romain Le Merlus
          Centreon Forge
          MERETHIS

          Comment


          • #6
            I can give you a little Idea of my resource.cfg:
            ################################################## #########################
            #
            # RESOURCE.CFG - Sample Resource File for Nagios
            #
            # You can define $USERx$ macros in this file, which can in turn be used
            # in command definitions in your host config file(s). $USERx$ macros are
            # useful for storing sensitive information such as usernames, passwords,
            # etc. They are also handy for specifying the path to plugins and
            # event handlers - if you decide to move the plugins or event handlers to
            # a different directory in the future, you can just update one or two
            # $USERx$ macros, instead of modifying a lot of command definitions.
            #
            # The CGIs will not attempt to read the contents of resource files, so
            # you can set restrictive permissions (600 or 660) on them.
            #
            # Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$)
            #
            # Resource files may also be used to store configuration directives for
            # external data sources like MySQL...
            #
            ################################################## #########################

            # Sets $USER1$ to be the path to the plugins
            $USER1$=/usr/lib/nagios/plugins

            # Sets $USER2$ to be the path to event handlers
            $USER2$=/usr/lib/nagios/plugins/eventhandlers

            # Store some usernames and passwords (hidden from the CGIs)
            #$USER3$=someuser
            #$USER4$=somepassword
            $USER5$=/usr/local/nagios/libexec

            # DB STATUS DATA
            # Note: These config directives are only used if you compiled
            # in database support for status data!
            # The user you specify here needs SELECT, INSERT, UPDATE, and
            # DELETE privileges on the 'programstatus', 'hoststatus',
            # and 'servicestatus' tables in the database.

            #xsddb_host=localhost
            #xsddb_port=3306
            xsddb_database=
            xsddb_username=
            xsddb_password=
            #xsddb_optimize_data=1
            #xsddb_optimize_interval=3600


            # DB COMMENT DATA
            # Note: These config directives are only used if you compiled
            # in database support for comment data!
            # The user you specify here needs SELECT, INSERT, UPDATE, and
            # DELETE privileges on the 'hostcomments' and 'servicecomments'
            # tables in the database.

            #xcddb_host=somehost
            #xcddb_port=someport
            #xcddb_database=somedatabase
            #xcddb_username=someuser
            #xcddb_password=somepassword
            #xcddb_optimize_data=1

            #xcddb_host=localhost
            #xcddb_port=3306
            xcddb_database=
            xcddb_username=
            xcddb_password=
            #xcddb_optimize_data=1


            # DB DOWNTIME DATA
            # Note: These config directives are only used if you compiled
            # in database support for downtime data!
            # The user you specify here needs SELECT, INSERT, UPDATE, and
            # DELETE privileges on the 'hostdowntime' and 'servicedowntime'
            # tables in the database.

            #xdddb_host=somehost
            #xdddb_port=someport
            #xdddb_database=somedatabase
            #xdddb_username=someuser
            #xdddb_password=somepassword
            #xdddb_optimize_data=1

            #xdddb_host=localhost
            #xdddb_port=3306
            xdddb_database=
            xdddb_username=
            xdddb_password=
            #xdddb_optimize_data=1

            # DB RETENTION DATA
            # Note: These config directives are only used if you compiled
            # in database support for retention data!
            # The user you specify here needs SELECT, INSERT, UPDATE, and
            # DELETE privileges on the 'programretention', 'hostretention',
            # and 'serviceretention' tables in the database.

            #xrddb_host=somehost
            #xrddb_port=someport
            #xrddb_database=somedatabase
            #xrddb_username=someuser
            #xrddb_password=somepassword
            #xrddb_optimize_data=1

            #xrddb_host=localhost
            #xrddb_port=3306
            xrddb_database=
            xrddb_username=
            xrddb_password=
            #xrddb_optimize_data=1
            you see what I missed in my Case ? I think it has a little to do with Nagios and its MySQL Database and their communication. You unterstand.
            I think you will get this going.

            dobebo

            Comment

            Working...
            X