Ad Widget

Collapse

Zabbix Server running Status wrong

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • overrider
    Member
    • Oct 2006
    • 36

    #1

    Zabbix Server running Status wrong

    Hello all,

    after a planned shutdown (manual shutdown of all services, machine shutdown and re-powerup), my Zabbix Server Process is running, and all the Items seem to get checked and Update themselves, but on the Web UI, Reports -> Status of Zabbix -> zabbix Server running shows 0, while it should be 1. Where does it get this Value from?

    Thanks,
    Overrider
  • Villain
    Member
    • Aug 2006
    • 84

    #2
    Not sure the exact specs on this, but we found that this was a php issue. It has to do with the safe-mode setting, I believe, but our sysadmin that fixed it for me is currently away.

    Comment

    • glut0r
      Member
      • Mar 2007
      • 38

      #3
      There's a problem running zabbix frontend under safe_mode. That's what might cause your problems.
      If you need additional security (which is important in case there is a bug in php frontend or whatever) you will surely hit against it.

      All seems runnig fine under safe_mode=on, with one exception: Reports/Status of ZABBIX/'ZABBIX server is running' comes up with wrong status of zabbix server. Even if it's running, status page shows it as down.
      If you don't mind, don't read any further. If you do, here's a mini HOWTO.

      You need to set up the following settings in your php.ini
      safe_mode=on
      safe_mode_exec_dir=/trusted/dir

      and restart http server.

      As a power user do the following:
      Code:
      # cp `which pgrep` /trusted/dir
      # chown <http server uid> /trusted/dir/pgrep
      These are due to safe mode requirements, consult php docs for more info.

      The code that makes zabbix server unavailable is the line below in include/config.inc.db , in 1.1.6 line 1929.
      Code:
      if( (exec("ps -ef|grep zabbix_server|grep -v grep|wc -l")>0) || (exec("ps -ax|grep zabbix_server|grep -v grep|wc -l")>0) )
      In safe mode exec and some other functions are disabled to security reasons (check php.net for docs)
      Replace the line above with this:
      Code:
      if(exec('pgrep zabbix_server') )
      If you prepared php.ini and trusted dir as stated above, Zabbix server status will now be show correctly.

      The alternative method which I use, and which is simplier, is to replace bad line like this:
      Code:
      if (fsockopen("localhost", "10051", $errnum, $errstr, 2))
      If the port is down, counting processes is useless IMHO.

      The first method is universal for every OS that has pgrep command (found it on Solaris, Free and OpenBSD and Linux).
      When using the second method, you must remember not to change default zabbix-server port, while it's hardcoded in this line.

      Credit for ideas to Kanedaaa for the first, and dflow for the second one.
      Last edited by glut0r; 11-04-2007, 01:30.

      Comment

      • glut0r
        Member
        • Mar 2007
        • 38

        #4
        When running James Wells bulk patch for 1.1.7, there's still a problem with safe_mode=on. To bypass it according to my previous post, one must change include/config.inc.php line 2138 from:
        Code:
        return (exec($zabbixServer["zabbix_get"]. " -p " .$zabbixServer["port"]. " -s " .$zabbixServer["host"]. " -k 'proc.num[zabbix_server]'") > 0 ) ? S_YES : S_NO;
        to either :

        Code:
        if(exec('pgrep zabbix_server') )
                        {
                                return (S_YES);
                        }
                        else
                        {
                                return (S_NO);
                        }
        or this if using fsockopen version:

        Code:
                        if (fsockopen($zabbixServer["host"], $zabbixServer["port"], $errnum, $errstr, 2) )
                        {
                                return (S_YES);
                        }
                        else
                        {
                                return (S_NO);
                        }
        the code might have been better looking, but forgive me since I'm not really a php programmer

        Comment

        Working...