当前位置: 首页>>代码示例>>PHP>>正文


PHP create_sensor_to_state_index函数代码示例

本文整理汇总了PHP中create_sensor_to_state_index函数的典型用法代码示例。如果您正苦于以下问题:PHP create_sensor_to_state_index函数的具体用法?PHP create_sensor_to_state_index怎么用?PHP create_sensor_to_state_index使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_sensor_to_state_index函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

                    $states = array(array($state_index_id, 'unknown', 0, 0, 3), array($state_index_id, 'ready', 1, 1, 0), array($state_index_id, 'failed', 1, 2, 2), array($state_index_id, 'online', 1, 3, 1), array($state_index_id, 'offline', 1, 4, 2), array($state_index_id, 'degraded', 1, 6, 2), array($state_index_id, 'verifying', 1, 7, 1), array($state_index_id, 'resynching', 1, 15, 1), array($state_index_id, 'regenerating', 1, 16, 1), array($state_index_id, 'failedRedundancy', 1, 18, 2), array($state_index_id, 'rebuilding', 1, 24, 1), array($state_index_id, 'formatting', 1, 26, 1), array($state_index_id, 'reconstructing', 1, 32, 1), array($state_index_id, 'initializing', 1, 35, 1), array($state_index_id, 'backgroundInit', 1, 36, 1), array($state_index_id, 'permanentlyDegraded', 1, 52, 2));
                } elseif ($state_name == 'batteryState') {
                    $states = array(array($state_index_id, 'ready', 0, 1, 0), array($state_index_id, 'failed', 1, 2, 2), array($state_index_id, 'degraded', 1, 6, 2), array($state_index_id, 'reconditioning', 1, 7, 1), array($state_index_id, 'high', 1, 9, 1), array($state_index_id, 'low', 1, 10, 1), array($state_index_id, 'charging', 1, 12, 1), array($state_index_id, 'missing', 1, 21, 2), array($state_index_id, 'learning', 1, 36, 1));
                }
                foreach ($states as $value) {
                    $insert = array('state_index_id' => $value[0], 'state_descr' => $value[1], 'state_draw_graph' => $value[2], 'state_value' => $value[3], 'state_generic_value' => $value[4]);
                    dbInsert($insert, 'state_translations');
                }
            }
            foreach ($temp as $index => $entry) {
                if (strpos($index, '54.') === false) {
                    //Because Dell is buggy
                    if ($state_name == 'intrusionStatus') {
                        $descr = $tablevalue[3];
                    } elseif ($state_name == 'batteryState') {
                        $descr = str_replace('"', "", snmp_get($device, "batteryConnectionControllerName." . $index . "", "-Ovqn", $tablevalue[4])) . ' - ' . $temp[$index][$tablevalue[3]];
                    } elseif ($state_name == 'arrayDiskState') {
                        $descr = str_replace('"', "", snmp_get($device, "arrayDiskEnclosureConnectionEnclosureName." . $index . "", "-Ovqn", $tablevalue[4])) . ' - ' . $temp[$index][$tablevalue[3]];
                    } else {
                        $descr = clean($temp[$index][$tablevalue[3]]);
                        // Use clean as virtualDiskDeviceName is user defined
                    }
                    //Discover Sensors
                    discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp[$index][$tablevalue[2]], 'snmp', $index);
                    //Create Sensor To State Index
                    create_sensor_to_state_index($device, $state_name, $index);
                }
            }
        }
    }
}
开发者ID:Rosiak,项目名称:librenms,代码行数:31,代码来源:dell.inc.php

示例2: avtech_add_sensor

/**
 * Helper function to improve readability
 * Can't use mib based polling, because the snmp implentation and mibs are terrible
 *
 * @param (device) array - device array
 * @param (sensor) array(id, oid, type, descr, descr_oid, min, max, divisor)
 */
function avtech_add_sensor($device, $sensor)
{
    global $valid;
    // set the id, must be unique
    if (isset($sensor['id'])) {
        $id = $sensor['id'];
    } else {
        d_echo('Error: No id set for this sensor' . "\n");
        return false;
    }
    d_echo('Sensor id: ' . $id . "\n");
    // set the sensor oid
    if ($sensor['oid']) {
        $oid = $sensor['oid'];
    } else {
        d_echo('Error: No oid set for this sensor' . "\n");
        return false;
    }
    d_echo('Sensor oid: ' . $oid . "\n");
    // get the sensor value
    $value = snmp_get($device, $oid, '-OvQ');
    // if the sensor doesn't exist abort
    if ($value === false || $type == 'temperature' && $value == 0) {
        //issue unfortunately some non-existant sensors return 0
        d_echo('Error: sensor returned no data, skipping' . "\n");
        return false;
    }
    d_echo('Sensor value: ' . $value . "\n");
    // get the type
    $type = $sensor['type'] ? $sensor['type'] : 'temperature';
    d_echo('Sensor type: ' . $type . "\n");
    $type_name = $device['os'];
    if ($type == 'switch') {
        // set up state sensor
        $type_name .= ucfirst($type);
        $type = 'state';
        $state_index_id = create_state_index($type_name);
        //Create State Translation
        if (isset($state_index_id)) {
            $states = array(array($state_index_id, 'Off', 1, 0, -1), array($state_index_id, 'On', 1, 1, 0));
            foreach ($states as $value) {
                $insert = array('state_index_id' => $value[0], 'state_descr' => $value[1], 'state_draw_graph' => $value[2], 'state_value' => $value[3], 'state_generic_value' => $value[4]);
                dbInsert($insert, 'state_translations');
            }
        }
    }
    // set the description
    if ($sensor['descr_oid']) {
        $descr = trim(snmp_get($device, $sensor['descr_oid'], '-OvQ'), '"');
    } elseif ($sensor['descr']) {
        $descr = $sensor['descr'];
    } else {
        d_echo('Error: No description set for this sensor' . "\n");
        return false;
    }
    d_echo('Sensor description: ' . $descr . "\n");
    // set divisor
    if ($sensor['divisor']) {
        $divisor = $sensor['divisor'];
    } elseif ($type == 'temperature') {
        $divisor = 100;
    } else {
        $divisor = 1;
    }
    d_echo('Sensor divisor: ' . $divisor . "\n");
    // set min for alarm
    if ($sensor['min_oid']) {
        $min = snmp_get($device, $sensor['min_oid'], '-OvQ') / $divisor;
    } else {
        $min = null;
    }
    d_echo('Sensor alarm min: ' . $min . "\n");
    // set max for alarm
    if ($sensor['max_oid']) {
        $max = snmp_get($device, $sensor['max_oid'], '-OvQ') / $divisor;
    } else {
        $max = null;
    }
    d_echo('Sensor alarm max: ' . $max . "\n");
    // add the sensor
    discover_sensor($valid['sensor'], $type, $device, $oid, $id, $type_name, $descr, $divisor, '1', $min, null, null, $max, $value / $divisor);
    if ($type == 'state') {
        create_sensor_to_state_index($device, $type_name, $id);
    }
    return true;
}
开发者ID:arrmo,项目名称:librenms,代码行数:93,代码来源:functions.inc.php

示例3: snmp_get

            case "9":
                $descr = "MPG2 codec";
                break;
            case "10":
                $descr = "WVC1 codec";
                break;
            case "11":
                $descr = "MPG4 codec";
                break;
            case "12":
                $descr = "MJPG codec";
                break;
            case "13":
                $descr = "WMV9 codec";
                break;
        }
        $value = snmp_get($device, $oid . $codec, '-Oqv');
        if (!empty($value)) {
            $state_index_id = create_state_index($state);
            if ($state_index_id) {
                $states = array(array($state_index_id, 'enabled', 1, 2, 0), array($state_index_id, 'disabled', 1, 3, 2));
            }
            foreach ($states as $value) {
                $insert = array('state_index_id' => $value[0], 'state_descr' => $value[1], 'state_draw_graph' => $value[2], 'state_value' => $value[3], 'state_generic_value' => $value[4]);
                dbInsert($insert, 'state_translations');
            }
        }
        discover_sensor($valid['sensor'], 'state', $device, $oid . $codec, $codec, $state, $descr, '1', '1', null, null, null, null, $value, 'snmp', $codec);
        create_sensor_to_state_index($device, $state, $codec);
    }
}
开发者ID:Tatermen,项目名称:librenms,代码行数:31,代码来源:linux.inc.php

示例4: trim

    $psu_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16';
    $psu_state_name = 'hpblmos_psustate';
    $psu_state_descr = 'PSU ';
    $psu_state_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.';
    $psus = trim(snmp_walk($device, $psu_oid, '-Osqn'));
    foreach (explode("\n", $psus) as $psu) {
        $psu = trim($psu);
        if ($psu) {
            list($oid, $presence) = explode(' ', $psu, 2);
            if ($presence != 2) {
                $split_oid = explode('.', $oid);
                $current_id = $split_oid[count($split_oid) - 1];
                $current_oid = $psu_state_oid . $current_id;
                $descr = $psu_state_descr . $current_id;
                $state = snmp_get($device, $current_oid, '-Oqv');
                if (!empty($state)) {
                    $state_index_id = create_state_index($psu_state_name);
                    if ($state_index_id) {
                        $states = array(array($state_index_id, 'other', 0, 1, 3), array($state_index_id, 'ok', 1, 2, 0), array($state_index_id, 'degraded', 1, 3, 1), array($state_index_id, 'failed', 1, 4, 2));
                        foreach ($states as $value) {
                            $insert = array('state_index_id' => $value[0], 'state_descr' => $value[1], 'state_draw_graph' => $value[2], 'state_value' => $value[3], 'state_generic_value' => $value[4]);
                            dbInsert($insert, 'state_translations');
                        }
                    }
                }
                discover_sensor($valid['sensor'], 'state', $device, $current_oid, $current_id, $psu_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $current_id);
                create_sensor_to_state_index($device, $psu_state_name, $current_id);
            }
        }
    }
}
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:hpblmos.inc.php

示例5: d_echo

    }
    d_echo("QNAP HDD SMART\n");
    for ($i = 1; $i <= $total_disks; $i++) {
        $state = str_replace('"', '', snmp_get($device, $smart_oid . $i, '-Oqv'));
        $smart_name = 'qnap_hdd_smart_' . $i;
        $smart_descr = 'HDD ' . $i . ' SMART';
        switch ($state) {
            case 'Normal':
                $state = 1;
                break;
            case '--':
                $state = 0;
                break;
            case 'Warning':
                $state = 2;
                break;
        }
        if (is_numeric($state)) {
            $state_index_id = create_state_index($smart_name);
            if ($state_index_id !== null) {
                $states = array(array($state_index_id, 'normal', 1, 1, 0), array($state_index_id, 'no disk', 0, 0, 1), array($state_index_id, 'warning', 2, 2, 2));
                foreach ($states as $value) {
                    $insert = array('state_index_id' => $value[0], 'state_descr' => $value[1], 'state_draw_graph' => $value[2], 'state_value' => $value[3], 'state_generic_value' => $value[4]);
                    dbInsert($insert, 'state_translations');
                }
            }
            discover_sensor($valid['sensor'], 'state', $device, $smart_oid . $i, 1, $smart_name, $smart_descr, '1', '1', null, null, null, null, $state, 'snmp', 1);
            create_sensor_to_state_index($device, $smart_name, 1);
        }
    }
}
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:qnap.inc.php


注:本文中的create_sensor_to_state_index函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。