source: npl/monitoring/zabbix/zabbix-foreground.patch @ 225b098

perl-5.22
Last change on this file since 225b098 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 6.9 KB
  • include/common.h

    diff -u -r zabbix-2.2.1/include/common.h zabbix-2.2.1.new/include/common.h
    old new  
    751751        ZBX_TASK_START_SERVICE,
    752752        ZBX_TASK_STOP_SERVICE,
    753753        ZBX_TASK_CHANGE_NODEID,
    754         ZBX_TASK_CONFIG_CACHE_RELOAD
     754        ZBX_TASK_CONFIG_CACHE_RELOAD,
     755        ZBX_TASK_START_FOREGROUND
    755756}
    756757zbx_task_t;
    757758
  • include/daemon.h

    diff -u -r zabbix-2.2.1/include/daemon.h zabbix-2.2.1.new/include/daemon.h
    old new  
    3030
    3131#include "threads.h"
    3232
    33 int     daemon_start(int allow_root);
     33int     daemon_start(int allow_root, int foreground);
    3434void    daemon_stop();
    3535
    3636int     zbx_sigusr_send(zbx_task_t task);
     
    3838#define ZBX_IS_RUNNING()        1
    3939#define ZBX_DO_EXIT()
    4040
    41 #define START_MAIN_ZABBIX_ENTRY(a)      daemon_start(a)
     41#define START_MAIN_ZABBIX_ENTRY(a,b)    daemon_start(a,b)
    4242
    4343#endif  /* ZABBIX_DAEMON_H */
  • src/libs/zbxnix/daemon.c

    Only in zabbix-2.2.1/include: stamp-h1
    diff -u -r zabbix-2.2.1/src/libs/zbxnix/daemon.c zabbix-2.2.1.new/src/libs/zbxnix/daemon.c
    old new  
    140140 * Comments: it doesn't allow running under 'root' if allow_root is zero      *
    141141 *                                                                            *
    142142 ******************************************************************************/
    143 int     daemon_start(int allow_root)
     143int     daemon_start(int allow_root, int foreground)
    144144{
    145145        pid_t                   pid;
    146146        struct passwd           *pwd;
     
    186186#endif
    187187        }
    188188
    189         if (0 != (pid = zbx_fork()))
    190                 exit(0);
     189        /* The actual daemonizing is done here. Since nowadays deamons run as normal processes under service supervisors, we provide a foreground-option as well. edwin@datux.nl */
     190        if (!foreground)
     191        {
     192                if (0 != (pid = zbx_fork()))
     193                        exit(0);
    191194
    192         setsid();
     195                setsid();
    193196
    194         signal(SIGHUP, SIG_IGN);
     197                signal(SIGHUP, SIG_IGN);
    195198
    196         if (0 != (pid = zbx_fork()))
    197                 exit(0);
     199                if (0 != (pid = zbx_fork()))
     200                    exit(0);
     201        }
    198202
    199203        if (-1 == chdir("/"))   /* this is to eliminate warning: ignoring return value of chdir */
    200204                assert(0);
  • src/zabbix_agent/zabbix_agentd.c

    diff -u -r zabbix-2.2.1/src/zabbix_agent/zabbix_agentd.c zabbix-2.2.1.new/src/zabbix_agent/zabbix_agentd.c
    old new  
    8989        "  -c --config <config-file>  Absolute path to the configuration file",
    9090        "  -p --print                 Print known items and exit",
    9191        "  -t --test <item key>       Test specified item and exit",
     92        "  -f --foreground            Start in the foreground. (for running a service supervisor)",
    9293        "  -h --help                  Give this help",
    9394        "  -V --version               Display version number",
    9495#ifdef _WINDOWS
     
    112113{
    113114        {"config",              1,      NULL,   'c'},
    114115        {"help",                0,      NULL,   'h'},
     116        {"foreground",          0,      NULL,   'f'},
    115117        {"version",             0,      NULL,   'V'},
    116118        {"print",               0,      NULL,   'p'},
    117119        {"test",                1,      NULL,   't'},
     
    128130};
    129131
    130132static char     shortopts[] =
    131         "c:hVpt:"
     133        "c:hfVpt:"
    132134#ifdef _WINDOWS
    133135        "idsxm"
    134136#endif
     
    187189                                        TEST_METRIC = strdup(zbx_optarg);
    188190                                }
    189191                                break;
     192                        case 'f':
     193                                t->task = ZBX_TASK_START_FOREGROUND;
     194                                break;
    190195#ifdef _WINDOWS
    191196                        case 'i':
    192197                                t->task = ZBX_TASK_INSTALL_SERVICE;
    193198                                break;
    194                         case 'd':
    195                                 t->task = ZBX_TASK_UNINSTALL_SERVICE;
    196                                 break;
    197199                        case 's':
    198200                                t->task = ZBX_TASK_START_SERVICE;
    199201                                break;
     
    826828                        alias_list_free();
    827829                        exit(SUCCEED);
    828830                        break;
    829                 default:
     831                case ZBX_TASK_START:
    830832                        zbx_load_config(ZBX_CFG_FILE_REQUIRED);
     833                        START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT, 0);
    831834                        break;
     835                case ZBX_TASK_START_FOREGROUND:
     836                        zbx_load_config(ZBX_CFG_FILE_REQUIRED);
     837                        START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT, 1);
     838                        break;
     839               
    832840        }
    833841
    834         START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT);
    835 
    836842        exit(SUCCEED);
    837843}
  • src/zabbix_proxy/proxy.c

    diff -u -r zabbix-2.2.1/src/zabbix_proxy/proxy.c zabbix-2.2.1.new/src/zabbix_proxy/proxy.c
    old new  
    6565const char      *help_message[] = {
    6666        "Options:",
    6767        "  -c --config <file>              Absolute path to the configuration file",
     68        "  -f --foreground                 Run in foreground (under a service supervisor)",
    6869        "  -R --runtime-control <option>   Perform administrative functions",
    6970        "",
    7071        "Runtime control options:",
     
    8485        {"config",              1,      NULL,   'c'},
    8586        {"runtime-control",     1,      NULL,   'R'},
    8687        {"help",                0,      NULL,   'h'},
     88        {"foreground",          0,      NULL,   'f'},
    8789        {"version",             0,      NULL,   'V'},
    8890        {NULL}
    8991};
    9092
    9193/* short options */
    92 static char     shortopts[] = "c:n:hVR:";
     94static char     shortopts[] = "c:n:hfVR:";
    9395
    9496/* end of COMMAND LINE OPTIONS */
    9597
     
    548550                                version();
    549551                                exit(-1);
    550552                                break;
     553                        case 'f':
     554                                task=ZBX_TASK_START_FOREGROUND;
     555                                break;
    551556                        default:
    552557                                usage();
    553558                                exit(-1);
     
    570575        init_ipmi_handler();
    571576#endif
    572577
    573         return daemon_start(CONFIG_ALLOW_ROOT);
     578        return daemon_start(CONFIG_ALLOW_ROOT, task==ZBX_TASK_START_FOREGROUND);
    574579}
    575580
    576581int     MAIN_ZABBIX_ENTRY()
  • src/zabbix_server/server.c

    diff -u -r zabbix-2.2.1/src/zabbix_server/server.c zabbix-2.2.1.new/src/zabbix_server/server.c
    old new  
    7272        "Options:",
    7373        "  -c --config <file>              Absolute path to the configuration file",
    7474        "  -n --new-nodeid <nodeid>        Convert database data to new nodeid",
     75        "  -f --foreground                 Run in foreground. (for use with service supervisors)",
    7576        "  -R --runtime-control <option>   Perform administrative functions",
    7677        "",
    7778        "Runtime control options:",
     
    9293        {"new-nodeid",          1,      NULL,   'n'},
    9394        {"runtime-control",     1,      NULL,   'R'},
    9495        {"help",                0,      NULL,   'h'},
     96        {"foreground",          0,      NULL,   'f'},
    9597        {"version",             0,      NULL,   'V'},
    9698        {NULL}
    9799};
    98100
    99101/* short options */
    100 static char     shortopts[] = "c:n:hVR:";
     102static char     shortopts[] = "c:n:hfVR:";
    101103
    102104/* end of COMMAND LINE OPTIONS */
    103105
     
    512514                                help();
    513515                                exit(-1);
    514516                                break;
     517                        case 'f':
     518                                task = ZBX_TASK_START_FOREGROUND;
     519                                break;
    515520                        case 'n':
    516521                                nodeid = (NULL == zbx_optarg ? 0 : atoi(zbx_optarg));
    517522                                task = ZBX_TASK_CHANGE_NODEID;
     
    547552                case ZBX_TASK_CHANGE_NODEID:
    548553                        exit(SUCCEED == change_nodeid(nodeid) ? EXIT_SUCCESS : EXIT_FAILURE);
    549554                        break;
    550                 default:
     555                case ZBX_TASK_START:
     556                        return daemon_start(CONFIG_ALLOW_ROOT, 0);
     557                        break;
     558                case ZBX_TASK_START_FOREGROUND:
     559                        return daemon_start(CONFIG_ALLOW_ROOT, 1);
    551560                        break;
    552561        }
    553562
    554         return daemon_start(CONFIG_ALLOW_ROOT);
    555563}
    556564
    557565int     MAIN_ZABBIX_ENTRY()
Note: See TracBrowser for help on using the repository browser.