Private GIT

Skip to content
Snippets Groups Projects
Select Git revision
  • 5c140dd28efa129249eef74063b2e75ef32e226f
  • master default protected
  • MON-2693-new-menu
  • php7-migration
  • poc-redis
  • security-fix-virtual-metrics-sql
  • security-fix-reporting
  • security-fix-menu-username
  • security-fix-export-graph
  • security-fix-metrics-injection
  • security-fix-virtual-metrics
  • security-fix-curves-templates
  • security-fix-command-form
  • security-fix-administration-logs
  • clapi_filter
  • MON2733-C2_Security_fix
  • new-header-2.8.x
  • MON-2725-ldap-passwords
  • 2.8.x
  • 6073-fix-view-contact-notifications
  • MON2703-new-api-menu
  • 2.8.23
  • 2.8.22
  • 2.8.21
  • 2.8.20
  • 2.8.19
  • 2.8.18
  • 2.8.17
  • 2.8.216
  • 2.8.16
  • 2.7.13
  • 2.8.15
  • help
  • 2.8.14
  • 2.8.13
  • 2.8.12
  • 2.7.12
  • 2.8.11
  • 2.8.10
  • 2.8.10-release
  • 2.8.9
41 results

centreond

Blame
  • centreond 3.84 KiB
    #!/usr/bin/perl
    
    use strict;
    use Getopt::Long;
    use Config::IniFiles;
    use Sys::Hostname;
    use DBI;
    use Module::Util qw(:all);
    use centreon::common::logger;
    use centreon::daemon::crypt;
    use centreon::daemon::processus;
    use centreon::daemon::events qw(emit);
    
    my $configFile = '/etc/centreon/centreon.ini';
    my $keygen = 0;
    GetOptions(
      "config=s" => \$configFile,
      "keygen" => \$keygen
    ) or die("Error in command line arguments.");
    
    if (!-f $configFile) {
        print("The configuration file does not exists.\n");
        exit 2;
    }
    
    my $config = Config::IniFiles->new(
      -file => $configFile,
      -nomultiline => 1
    );
    
    # Generate keyfile if ask
    if ($keygen) {
        centreon::daemon::crypt::generateKeys("/tmp", "central", "test");
        exit 1;
    }
    
    # List of server type
    #
    # central : Run server in Central with database
    # poller : Run server to a poller
    my $serverType = "central";
    if ($config->exists("centreond", "type")) {
        $serverType = $config->val("centreond", "type");
    }
    my $pollername = hostname();
    
    # Initialize log file
    our $logger = centreon::common::logger->new();
    if ($config->exists("centreond", "log_lvl")) {
        $logger->severity($config->val("centreond", "log_lvl"));
    }
    if ($config->exists("centreond", "log_file")) {
        $logger->file_mode($config->val("centreond", "log_file"));
    }
    
    # Load module
    my @modules;
    if ($config->exists("centreond", "module")) {
        @modules = $config->val("centreond", "module");
    }
    
    $logger->writeLogInfo("Initialize daemon");
    foreach my $module (@modules) {
        if (find_installed($module)) {
            $logger->writeLogInfo("Load module : $module");
            eval "use ${module}";
            my $registerFunc = "${module}::register_events";
            ${module}->register_events($serverType);
        }
    }