Ad Widget

Collapse

Zabbix SendEmail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WilliamSG
    Member
    • Jun 2014
    • 41

    #1

    Zabbix SendEmail

    Hi guys...

    I'll be brevity:

    Here my SendMail configurations:

    * this is a test conf, I'll change the "zabbixmailto, subject and body" values to $1, $2, and $3.

    and here the Zabbix result:


    But I'm not receiving the mail.
    If i run the script manualy, on linux console, it works fine.

    Anyone can help me?
  • jvalenzani
    Member
    Zabbix Certified Specialist
    • Sep 2010
    • 53

    #2
    Please, check server log for errors.

    Comment

    • WilliamSG
      Member
      • Jun 2014
      • 41

      #3
      Here follows

      1318:20140729:155819.523 enabling Zabbix agent checks on host "cenw07n05664": host became available
      9110:20140729:155829.317 zbx_popen(): failed to create a process group: [13] Permission denied
      1312:20140729:155905.938 Zabbix agent item "vfs.fs.size[C:,pfree]" on host "cenw07n05664" failed: first network error, wait for 15 seconds
      1318:20140729:155923.529 Zabbix agent item "vfs.fs.size[C:,pfree]" on host "cenw07n05664" failed: another network error, wait for 15 seconds
      1318:20140729:155941.533 Zabbix agent item "agent.ping" on host "cenw07n05664" failed: another network error, wait for 15 seconds
      9128:20140729:155959.324 zbx_popen(): failed to create a process group: [13] Permission denied
      1318:20140729:155959.536 temporarily disabling Zabbix agent checks on host "cenw07n05664": host unavailable
      And here a "ls -la" on Alertscript folder

      -rwxrwxrwx. 1 root root 423 Jul 28 13:59 sendemail.sh
      What the bold line means?
      Last edited by WilliamSG; 29-07-2014, 21:02.

      Comment

      • jvalenzani
        Member
        Zabbix Certified Specialist
        • Sep 2010
        • 53

        #4
        Seems that the user do not have permission to fork the new process.
        Code:
        /******************************************************************************
         *                                                                            *
         * Function: zbx_popen                                                        *
         *                                                                            *
         * Purpose: this function opens a process by creating a pipe, forking,        *
         *          and invoking the shell                                            *
         *                                                                            *
         * Parameters: pid     - [OUT] child process PID                              *
         *             command - [IN] a pointer to a null-terminated string           *
         *                       containing a shell command line                      *
         *                                                                            *
         * Return value: on success, reading file descriptor is returned. On error,   *
         *               -1 is returned, and errno is set appropriately               *
         *                                                                            *
         * Author: Alexander Vladishev                                                *
         *                                                                            *
         ******************************************************************************/
        static int	zbx_popen(pid_t *pid, const char *command)
        {
        	const char	*__function_name = "zbx_popen";
        	int		fd[2];
        
        	zabbix_log(LOG_LEVEL_DEBUG, "In %s() command:'%s'", __function_name, command);
        
        	if (-1 == pipe(fd))
        		return -1;
        
        	if (-1 == (*pid = zbx_fork()))
        	{
        		close(fd[0]);
        		close(fd[1]);
        		return -1;
        	}
        
        	if (0 != *pid)	/* parent process */
        	{
        		close(fd[1]);
        
        		zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __function_name, fd[0]);
        
        		return fd[0];
        	}
        
        	/* child process */
        	close(fd[0]);
        	dup2(fd[1], STDOUT_FILENO);
        	close(fd[1]);
        
        	/* set the child as the process group leader, otherwise orphans may be left after timeout */
        	if (-1 == setpgid(0, 0))
        	{
        		zabbix_log(LOG_LEVEL_ERR, "%s(): failed to create a process group: %s",
        				__function_name, zbx_strerror(errno));
        		exit(0);
        	}
        
        	zabbix_log(LOG_LEVEL_DEBUG, "%s(): executing script", __function_name);
        
        	execl("/bin/sh", "sh", "-c", command, NULL);
        
        	/* execl() returns only when an error occurs */
        	zabbix_log(LOG_LEVEL_WARNING, "execl() failed for [%s]: %s", command, zbx_strerror(errno));
        	exit(0);
        }

        Comment

        • WilliamSG
          Member
          • Jun 2014
          • 41

          #5
          Well... is it an internal error? from "zabbix" user maybe...
          Last edited by WilliamSG; 30-07-2014, 14:12.

          Comment

          Working...