热门关键字:  ubuntu  分区  Fedora  linux系统进程  函数

当前位置 :| 主页>Linux教程>编程开发>PHP>

cacti 自定义ping模块修改配置

来源: 作者: 时间:2007-12-07 Tag: 点击:
 vi cacti/cmd.php
vi cacti/plugins/monitor/fast_poller_cmd.php

                        /*if ((!function_exists("socket_create")) || (phpversion() < "4.3")) {*/
                                /* the ping test will fail under PHP < 4.3 without socket support */
                        /*      $ping_availability = AVAIL_SNMP;
                        }else{*/
                                $ping_availability = read_config_option("availability_method");
                        /*}*/



vi cacti/include/config_constants.php

define("AVAIL_SNMP_AND_PING", 1);
define("AVAIL_SNMP", 2);
define("AVAIL_PING", 3);
define("MONITORD_PING", 4);

vi cacti/include/config_arrays.php

$availability_options = array(
        AVAIL_SNMP_AND_PING => "Ping and SNMP - Most Recommended",
        AVAIL_SNMP => "SNMP - Reliable",
        AVAIL_PING => "Ping - Faster Option with Risk",
        MONITORD_PING => "Monitord_Ping");



vi cacti/lib/ping.php

 
function ping_monitord(){
                $host_ip = gethostbyname($this->host["hostname"]);
                if (`sh /data/web/cacti/scripts/monitor_ping.sh $host_ip` == 0)
                {
                        return true;}
                else
                {
                        return false;
                }



switch ($avail_method) {
                        case AVAIL_SNMP_AND_PING:
                                if ($this->host["snmp_community"] == "")
                                        if ($ping_result)
                                                return true;
                                        else
                                                return false;
                                if ($snmp_result)
                                        return true;
                                if ($ping_result)
                                        return true;
                                else
                                        return false;
                        case AVAIL_SNMP:
                                if ($snmp_result)
                                        return true;
                                else
                                        return false;
                        case AVAIL_PING:
                                if ($ping_result)
                                        return true;
                                else
                                        return false;
                        case MONITORD_PING:
                                if ($monitord_result)
                                        return true;
                                else
                                {
                                        $this->ping_response = "MONITORD_PING failed";
                                        return false;
                                }
                        default:
                                return false;
                }
        } /* end_ping */



最新评论共有 4 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
栏目列表