Ad Widget

Collapse

Need Help to connect Zabbix Proxy over SSH

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Matthieu
    Member
    • Mar 2011
    • 41

    #1

    Need Help to connect Zabbix Proxy over SSH

    Hello,

    I've a Zabbix server and I would add a Zabbix Proxy for monitoring my AWS infrastructure. I would configure a ssh connection between the proxy and server with port forwarding. But that doesn't work...


    zabbix-log:

    Code:
     Unable to connect to the server [127.0.0.1]:10050 [*** Cannot connect to [127.0.0.1]:10050 [Connection refused]]
    Zabbix-proxy.conf:


    Code:
    # This is config file for ZABBIX server process
    # To get more information about ZABBIX,
    # go http://www.zabbix.com
    
    ############ GENERAL PARAMETERS #################
    
    # IP address (or hostname) of ZABBIX servers.
    
    Server=127.0.0.1
    
    # Server port for sending active checks
    
    ServerPort=10050
    
    # Unique hostname.
    
    Hostname=proxy

    command ssh:

    Code:
    ssh -vvv -R 10050:localhost:10050 root@ip_router
    Debuging ssh:

    Code:
    Remote connections from LOCALHOST:10050 forwarded to local address localhost:10050
    On my Zabbix-Server:

    Code:
    netstat -na | grep 10050
    
    tcp        0      0 127.0.0.1:10050         0.0.0.0:*               LISTEN
    tcp6       0      0 ::1:10050               :::*                    LISTEN

    Thanks
  • Bennie
    Member
    Zabbix Certified Specialist
    • Feb 2010
    • 73

    #2
    don't think you can forward a port to the same port on the same machine.

    10050 > 10050 is not possible. Well its possible but you are looping then and you will never reach the service you are looking for.

    traffic in on 10050 > forward to 10050 > forward to 10050 > forward to 10050 and so on.

    Try other ports for remote.

    Code:
    10051:localhost:10050

    Comment

    • Matthieu
      Member
      • Mar 2011
      • 41

      #3
      Thanks Bennie for your reply but it's not better. Same error...

      Comment

      • Bennie
        Member
        Zabbix Certified Specialist
        • Feb 2010
        • 73

        #4
        It must be a host/ip problem then. I thought the localhost wasn't placed properly but i cannot see what your plan is of course. The basics about tunneling. Let me try to explain with an example.

        Your ZBX server is yourserver.com
        Your ZBX proxy is yourproxy.com

        you want to create a tunnel from yourproxy.com to yourserver.com

        This is what you need to do and i will use your parameters with ssh for now

        Code:
        ssh -vvv -N -f -L 10050:localhost:10050 [email protected]
        This will reroute all traffic port 10050 on the server you logon to (proxy) to yourserver.com:10050

        When connecting to localhost:10050 on your proxy will get you on port 10050 on your zabbix server.

        As you see the last argument is the server your redirect will be created on. With your example you have created a local loop on port 10050 on your router while connected over ssh.
        Last edited by Bennie; 27-04-2011, 08:44. Reason: Wrong command line options

        Comment

        • Bennie
          Member
          Zabbix Certified Specialist
          • Feb 2010
          • 73

          #5
          I've changed the command line as it was wrong as we worked the other way around.

          Comment

          • Matthieu
            Member
            • Mar 2011
            • 41

            #6
            Ok, it's better but now i've:


            Heartbeat message failed
            on my zabbix proxy....

            (i've created the zabbix proxy on front-end and I've check that the Hostname is the same).
            Last edited by Matthieu; 27-04-2011, 18:50.

            Comment

            • Bennie
              Member
              Zabbix Certified Specialist
              • Feb 2010
              • 73

              #7
              check the server logging for clues

              Comment

              • Matthieu
                Member
                • Mar 2011
                • 41

                #8
                The Server log had no entry for the zabbix-proxy.

                Comment

                • Bennie
                  Member
                  Zabbix Certified Specialist
                  • Feb 2010
                  • 73

                  #9
                  - try to create an active agent item on the proxy (read that somewhere)

                  The proxy is added under administration > DM > proxies?

                  Comment

                  • Matthieu
                    Member
                    • Mar 2011
                    • 41

                    #10
                    Originally posted by Bennie
                    The proxy is added under administration > DM > proxies?
                    Yes.

                    - try to create an active agent item on the proxy (read that somewhere)
                    For use shh port forwarding i put in zabbix_agentd.conf:

                    Server=127.0.0.1

                    Listener failed with error: zbx_tcp_listen() Fatal error: unable to serve on any address. [[(null)]:10050].
                    But if i put the public ip of my zabbix-server it's incorrect because port 10050 is not forwarded on my router. Only the 22...

                    Comment

                    • Bennie
                      Member
                      Zabbix Certified Specialist
                      • Feb 2010
                      • 73

                      #11
                      can you telnet over the tunnel to the zabbix server?

                      Comment

                      • Matthieu
                        Member
                        • Mar 2011
                        • 41

                        #12
                        telnet localhost 10050

                        Trying ::1...
                        Connected to localhost.
                        Escape character is '^]'.
                        This command said that the ssh tunnel is ok?
                        Last edited by Matthieu; 28-04-2011, 16:01.

                        Comment

                        • Matthieu
                          Member
                          • Mar 2011
                          • 41

                          #13
                          How can I check that my zabbix proxy have data from a zabbix agent? In the database?

                          Comment

                          • Bennie
                            Member
                            Zabbix Certified Specialist
                            • Feb 2010
                            • 73

                            #14
                            Looks like the tunnel is working indeed. I will list a few things that could be missing so you can check it.
                            • Make sure you got the agent setup with the local ip on the network of your proxy net in the Zabbix interface.
                            • The host config in zabbix should have the proxy selected under "Monitored by proxy"
                            • Your agent config should point to the proxy for "server"
                            • If you are hosting the proxy and the agent on the same server then make sure to check all ports in use. 10050/10051 can be used in both configs and could conflict resulting in one of them not listening


                            Hope one of these will bring the light!

                            Comment

                            • Matthieu
                              Member
                              • Mar 2011
                              • 41

                              #15
                              Well,


                              On Zabbix Server:

                              * Administration -> DM -> Proxies -> I have

                              Name Last Seen # members
                              "proxy" - 1 membase
                              * configuration -> Host

                              Name Applications Items Triggers Graphs DNS IP Port Templates Status Availability
                              proxy:membase Applications (12) Items (102) Triggers (44) Graphs (0) - 127.0.0.1 10050 Template_Linux Monitored

                              Zabbix Proxy:


                              SSH command:

                              ssh -vvv -N -f -L 10050roxy_ip:10050 root@router_ip
                              SSH Debug:

                              debug1: Connection to port 10050 forwarding to proxy_ip port 10050 requested.
                              debug2: fd 6 setting TCP_NODELAY
                              debug2: fd 6 setting O_NONBLOCK
                              debug3: fd 6 is O_NONBLOCK
                              debug1: channel 2: new [direct-tcpip]
                              root@proxy_ip:~# debug1: Connection to port 10050 forwarding to proxy_ip port 10050 requested.
                              debug2: fd 7 setting TCP_NODELAY
                              debug2: fd 7 setting O_NONBLOCK
                              debug3: fd 7 is O_NONBLOCK
                              debug1: channel 3: new [direct-tcpip]

                              cat /var/log/zabbix-proxy/zabbix_proxy.log

                              22233:20110429:150023.982 Heartbeat message failed
                              22233:20110429:150124.001 Heartbeat message failed
                              cat /etc/zabbix/zabbix_proxy.conf

                              ############ GENERAL PARAMETERS #################

                              # IP address (or hostname) of ZABBIX servers.

                              Server=127.0.0.1

                              # Server port for sending active checks

                              ServerPort=10050

                              # Unique hostname.

                              Hostname=proxy

                              # Number of pre-forked instances of pollers
                              # Default value is 5
                              # This parameter must be between 0 and 255
                              #StartPollers=5

                              # Number of pre-forked instances of IPMI pollers
                              # Default value is 0
                              # This parameter must be between 0 and 255
                              #StartIPMIPollers=0

                              # Number of pre-forked instances of pollers for unreachable hosts
                              # Default value is 1
                              # This parameter must be between 0 and 255
                              #StartPollersUnreachable=1

                              # Number of pre-forked instances of trappers
                              # Default value is 5
                              # This parameter must be between 0 and 255
                              #StartTrappers=5

                              # Number of pre-forked instances of ICMP pingers
                              # Default value is 1
                              # This parameter must be between 0 and 255
                              #StartPingers=1

                              # Number of pre-forked instances of discoverers
                              # Default value is 1
                              # This parameter must be between 0 and 255
                              #StartDiscoverers=1

                              # Number of pre-forked instances of HTTP pollers
                              # Default value is 1
                              # This parameter must be between 0 and 255
                              #StartHTTPPollers=1

                              # Listen port for trapper. Default port number is 10051. This parameter
                              # must be between 1024 and 32767
                              ListenPort=10051

                              # Source IP address for outgouing connections
                              #SourceIP=

                              # Listen interface for trapper. Trapper will listen all network interfaces
                              # if this parameter is missing.
                              ListenIP=proxy_ip

                              # How often ZABBIX will perform sending hearbeat message
                              # (in seconds)
                              # Default value is 60 seconds
                              # Set to 0 to disable heartbeat messages
                              # This parameter must be between 0 and 3600
                              #HeartbeatFrequency=60

                              # How often ZABBIX will perform sync configuration data
                              # (in seconds)
                              # Default value is 3600 seconds (1h)
                              # This parameter must be between 1 and 604800 (1 week)
                              #ConfigFrequency=3600

                              # How often ZABBIX will perform housekeeping procedure
                              # (in hours)
                              # Default value is 1 hour
                              # Housekeeping is removing unnecessary information from
                              # tables history, alert, and alarms
                              # This parameter must be between 1 and 24
                              #HousekeepingFrequency=1

                              # How often ZABBIX will try to send unsent alerts
                              # (in seconds)
                              # Default value is 30 seconds
                              #SenderFrequency=30

                              # Local bufer size in hours. Proxy will keep collected data N hours.
                              # Default value is 0 hours
                              #ProxyLocalBuffer=0

                              # Offline buffer size in hours. It is used when server is not available.
                              # Older data is removed.
                              # Default value is 1 hours
                              #ProxyOfflineBuffer=1

                              # Specifies debug level
                              # 0 - debug is not created
                              # 1 - critical information
                              # 2 - error information
                              # 3 - warnings (default)
                              # 4 - for debugging (produces lots of information)
                              #DebugLevel=3

                              # Specifies how long we wait for agent response (in sec)
                              # Must be between 1 and 30
                              Timeout=5

                              # Specifies how many seconds trapper may spend processing new data
                              # Must be between 1 and 30
                              #TrapperTimeout=5

                              # After how many seconds of unreachability treat a host as unavailable
                              #UnreachablePeriod=45

                              # How ofter check host for availability during the unreachability period
                              #UnavailableDelay=15

                              # How ofter check host for availability during the unavailability period
                              #UnavailableDelay=60

                              # Name of PID file
                              PidFile=/var/run/zabbix-proxy/zabbix_proxy.pid

                              # Name of log file
                              # If not set, syslog is used
                              LogFile=/var/log/zabbix-proxy/zabbix_proxy.log

                              # Maximum size of log file in MB. Set to 0 to disable automatic log rotation.
                              #LogFileSize=1

                              # Location for custom alert scripts
                              AlertScriptsPath=/home/zabbix/bin/

                              # Location of external scripts
                              #ExternalScripts=/etc/zabbix/externalscripts

                              # Location of 'fping. Default is /usr/sbin/fping
                              # Make sure that fping binary has root permissions and SUID flag set
                              FpingLocation=/usr/bin/fping

                              # Location of fping6. Default is /usr/sbin/fping6
                              # Make sure that fping binary has root permissions and SUID flag set
                              #Fping6Location=/usr/sbin/fping6

                              # Temporary directory. Default is /tmp
                              #TmpDir=/tmp

                              # Frequency of ICMP pings (item keys 'icmpping' and 'icmppingsec'). Defauls is 60 seconds.
                              #PingerFrequency=60

                              # Database host name
                              # Default is localhost

                              DBHost=localhost

                              # Database name
                              # SQLite3 note: path to database file must be provided. DBUser and DBPassword are ignored.
                              DBName=zabbix_proxy

                              # Database user

                              DBUser=zabbix_proxy

                              # Database password
                              # Comment this line if no password used

                              DBPassword=xxxxxxxx

                              # Connect to MySQL using Unix socket?

                              #DBSocket=/tmp/mysql.sock
                              telnet 127.0.0.1 10050

                              Trying 127.0.0.1...
                              Connected to 127.0.0.1.
                              Escape character is '^]'.
                              telnet 127.0.0.1 10051

                              Trying 127.0.0.1...
                              telnet: Unable to connect to remote host: Connection refused

                              Zabbix_agent:


                              cat /etc/zabbix/zabbix_agentd.conf

                              ############ GENERAL PARAMETERS #################

                              # List of comma delimited IP addresses (or hostnames) of ZABBIX servers.
                              # No spaces allowed. First entry is used for sending active checks.
                              # Note that hostnames must resolve hostname->IP address and
                              # IP address->hostname.

                              Server=proxy_ip

                              # Server port for sending active checks

                              ServerPort=10051

                              # Unique hostname. Required for active checks.

                              Hostname=membase

                              # Listen port. Default is 10050

                              #ListenPort=10050

                              # IP address to bind agent
                              # If missing, bind to all available IPs

                              ListenIP=agent_ip

                              # Number of pre-forked instances of zabbix_agentd.
                              # Default value is 5
                              # This parameter must be between 1 and 16

                              StartAgents=5

                              # How often refresh list of active checks. 2 minutes by default.

                              #RefreshActiveChecks=120

                              # Disable active checks. The agent will work in passive mode listening server.

                              DisableActive=1

                              # Enable remote commands for ZABBIX agent. By default remote commands disabled.

                              #EnableRemoteCommands=1

                              # Specifies debug level
                              # 0 - debug is not created
                              # 1 - critical information
                              # 2 - error information
                              # 3 - warnings
                              # 4 - information (default)
                              # 5 - for debugging (produces lots of information)

                              DebugLevel=3

                              # Name of PID file

                              PidFile=/var/run/zabbix-agent/zabbix_agentd.pid

                              # Name of log file.
                              # If not set, syslog will be used

                              LogFile=/var/log/zabbix-agent/zabbix_agentd.log

                              # Maximum size of log file in MB. Set to 0 to disable automatic log rotation.
                              #LogFileSize=1

                              # Spend no more than Timeout seconds on processing
                              # Must be between 1 and 30

                              Timeout=3

                              ####### USER-DEFINED MONITORED PARAMETERS #######
                              # Format: UserParameter=<key>,<shell command>
                              # Note that shell command must not return empty string or EOL only
                              #UserParameter=system.test,who|wc -l
                              ### Set of parameter for monitoring MySQL server (v3.23.42 and later)
                              ### Change -u<username> and add -p<password> if required
                              #UserParameter=mysql.ping,mysqladmin -uroot ping|grep alive|wc -l
                              #UserParameter=mysql.uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
                              #UserParameter=mysql.threads,mysqladmin -uroot status|cut -f3 -d":"|cut -f1 -d"Q"
                              #UserParameter=mysql.questions,mysqladmin -uroot status|cut -f4 -d":"|cut -f1 -d"S"
                              #UserParameter=mysql.slowqueries,mysqladmin -uroot status|cut -f5 -d":"|cut -f1 -d"O"
                              #UserParameter=mysql.qps,mysqladmin -uroot status|cut -f9 -d":"
                              #UserParameter=mysql.version,mysql -V
                              cat /var/log/zabbix/zabbix.log

                              14582:20110429:151150 zabbix_agentd started. ZABBIX 1.4.6.
                              14583:20110429:151150 zabbix_agentd collector started
                              14585:20110429:151150 zabbix_agentd listener started
                              14586:20110429:151150 zabbix_agentd listener started
                              14587:20110429:151150 zabbix_agentd listener started
                              14584:20110429:151150 zabbix_agentd listener started
                              telnet proxy_ip 10051

                              Trying proxy_ip...
                              Connected to proxy_ip.
                              Escape character is '^]'.
                              telnet proxy_ip 10050

                              Trying proxy_ip...
                              telnet: Unable to connect to remote host: Connection refused

                              I'm tired

                              Comment

                              Working...