Ad Widget

Collapse

Compile agent with different config path

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tenchi
    Junior Member
    • Aug 2009
    • 6

    #1

    Compile agent with different config path

    How can I compile the agent to look for the zabbix_agentd.conf at a path different then /etc/zabbix/zabbix_agentd.conf ?
    I tried :

    --prefix=/etc/oph --exec-prefix=/etc/oph --bindir=/etc/oph --sbindir=/etc/oph --libexecdir=/etc/oph --sysconfdir=/etc/oph --datadir=/etc/oph --enable-static --enable-agent

    so it would put all files into /etc/oph but that didn'y work.
  • Tenchi
    Junior Member
    • Aug 2009
    • 6

    #2
    Also, howto change the user it runs as ?

    Comment

    • Tenchi
      Junior Member
      • Aug 2009
      • 6

      #3
      I was able to find that editing zabbix_agentd.c in /src/ folder, on line 53:
      static char DEFAULT_CONFIG_FILE[] =
      can be changed to the path I wanted, however I am still unable to discern howto change what user the zabbix agent runs as.

      Comment

      • Calimero
        Senior Member
        • Nov 2006
        • 481

        #4
        Code:
        --- src/libs/zbxnix/daemon.c    2009-04-03 16:44:05.000000000 +0200
        +++ src/libs/zbxnix/daemon.c.new        2009-06-12 13:27:41.626634000 +0200
        @@ -90,7 +90,7 @@
                pid_t                   pid;
                struct passwd           *pwd;
                struct sigaction        phan;
        -       char                    user[7] = "zabbix";
        +       char                    user[9] = "zabagent";
        
                /* running as root ?*/
                if((0 == allow_root) && (0 == getuid() || 0 == getgid()))
        For example ...

        Comment

        • Tenchi
          Junior Member
          • Aug 2009
          • 6

          #5
          Thank you, that worked perfectly.

          Comment

          • NOB
            Senior Member
            Zabbix Certified Specialist
            • Mar 2007
            • 469

            #6
            Originally posted by Tenchi
            Thank you, that worked perfectly.
            Perfect.

            Do you want to change the source code every time a new ZABBIX version
            comes up ?

            We don't and don't have time for that.

            If you really want to start the ZABBIX agent under a different user,
            just modify the startup script to use this different user.
            That's it.
            You don't have to modify the sources for every version.

            The same is true for the configuration file.
            Just specify it on the commandline in your startup script.

            Just some hints

            Regards

            Norbert.

            Comment

            • Tenchi
              Junior Member
              • Aug 2009
              • 6

              #7
              That sounds good, but what are the command line options to set that ? I did not see it in ./configure --help

              Comment

              • Calimero
                Senior Member
                • Nov 2006
                • 481

                #8
                Modify the startup script (init.d/zabbix_agentd) to setuid() before zabbix is acutally started.

                If you're on debian (and derivatives like ubuntu) you can use start-stop-daemon.
                If you're one RHEL/CentOS, theres the daemon function in /etc/init.d/functions

                Comment

                Working...