• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP format_unixtime函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: isset

     $error_rate = isset($error_codes[$error_db['error_code']]['rate']) && $error_codes[$error_db['error_code']]['rate'] < $error_db['error_rate'];
     if ($error_both) {
         $error_exceeded = $error_count && $error_rate;
     } else {
         $error_exceeded = $error_count || $error_rate;
     }
     if ($error_exceeded) {
         $error_class = 'danger';
         $error_class2 = 'error';
     } else {
         $error_class = $error_class2 = 'warning';
     }
     $text_class = count(explode(' ', $error_db['oid'])) > 3 ? '' : 'text-nowrap';
     echo '<tr width="100%" class="' . $error_class2 . '"><td style="width: 50%;" class="' . $text_class . '"><strong><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;' . $error_db['oid'] . '</strong></td>' . PHP_EOL;
     $timediff = $GLOBALS['config']['time']['now'] - $error_db['updated'];
     echo '<td style="width: 100px; white-space: nowrap; text-align: right;">' . generate_tooltip_link('', formatUptime($timediff, "short-3") . ' ago', format_unixtime($error_db['updated'])) . '</td>' . PHP_EOL;
     echo '<td style="width: 80px; white-space: nowrap;"><span class="text-' . $error_class . '">' . $error_codes[$error_db['error_code']]['reason'] . '</span></td>' . PHP_EOL;
     echo '<td style="width: 40px; text-align: right;"><span class="label">' . $error_db['error_count'] . '</span></td>' . PHP_EOL;
     echo '<td style="width: 80px; text-align: right;"><span class="label">' . round($error_db['error_rate'], 2) . '/poll</span></td>' . PHP_EOL;
     echo '<td>' . PHP_EOL;
     $form = array('type' => 'simple');
     // Elements
     $form['row'][0]['mib'] = array('type' => 'hidden', 'value' => $mib);
     $form['row'][0]['toggle_oid'] = array('type' => 'hidden', 'value' => $error_db['oid']);
     $form['row'][0]['submit'] = array('type' => 'submit', 'name' => '', 'class' => 'btn-mini btn-' . $error_class, 'icon' => $btn_icon, 'right' => TRUE, 'readonly' => $readonly, 'disabled' => TRUE, 'value' => 'toggle_oid');
     print_form($form);
     unset($form);
     echo '</td>' . PHP_EOL;
     echo '</td></tr>' . PHP_EOL;
 }
 echo '  </table>
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:mibs.inc.php


示例2: testFormatUnixtime

 /**
  * @dataProvider providerFormatUnixtime
  */
 public function testFormatUnixtime($value, $format, $result)
 {
     // override local timezone settings or these tests may fail
     date_default_timezone_set('UTC');
     $this->assertSame($result, format_unixtime($value, $format));
 }
开发者ID:skive,项目名称:observium,代码行数:9,代码来源:IncludesCommonTest.php


示例3: print_message

        }
        if (count($m_disabled)) {
            print_message('Disabled poller modules:');
            print_message('  ' . implode("\n  ", $m_disabled));
        }
        exit;
    }
}
if (!isset($options['q'])) {
    print_cli_banner();
    $latest['version'] = get_obs_attrib('latest_ver');
    $latest['revision'] = get_obs_attrib('latest_rev');
    $latest['date'] = get_obs_attrib('latest_rev_date');
    if ($latest['revision'] > OBSERVIUM_REV) {
        print_message("%GThere is a newer revision of Observium available!%n", 'color');
        print_message("%GVersion %r" . $latest['version'] . "%G (" . format_unixtime(datetime_to_unixtime($latest['date']), 'jS F Y') . ") is %r" . ($latest['revision'] - OBSERVIUM_REV) . "%G revisions ahead.%n\n", 'color');
    }
    //  print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WPoller%n\n", 'color');
    if (OBS_DEBUG) {
        print_versions();
    }
}
if ($options['h'] == "odd") {
    $options['n'] = "1";
    $options['i'] = "2";
} elseif ($options['h'] == "even") {
    $options['n'] = "0";
    $options['i'] = "2";
} elseif ($options['h'] == "all") {
    $where = " ";
    $doing = "all";
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:poller.php


示例4: poll_status


//.........这里部分代码省略.........
                } else {
                    print_warning("No agent status data available.");
                    continue;
                }
            } else {
                if ($status_db['poller_type'] == "ipmi") {
                    if (isset($ipmi_sensors['state'])) {
                        $status_value = $ipmi_sensors['state'][$status_db['status_type']][$status_db['status_index']]['current'];
                    } else {
                        print_warning("No IPMI status data available.");
                        continue;
                    }
                } else {
                    print_warning("Unknown status poller type.");
                    continue;
                }
            }
        }
        $status_polled_time = time();
        // Store polled time for current status
        // Write new value and humanize (for alert checks)
        $state_array = get_state_array($status_db['status_type'], $status_value, $status_db['poller_type']);
        $status_poll['status_value'] = $state_array['value'];
        $status_poll['status_name'] = $state_array['name'];
        if ($status_db['status_ignore'] || $status_db['status_disable']) {
            $status_poll['status_event'] = 'ignore';
        } else {
            $status_poll['status_event'] = $state_array['event'];
        }
        // If last change never set, use current time
        if (empty($status_db['status_last_change'])) {
            $status_db['status_last_change'] = $status_polled_time;
        }
        if ($status_poll['status_event'] != $status_db['status_event']) {
            // Status event changed, log and set status_last_change
            $status_poll['status_last_change'] = $status_polled_time;
            if ($status_poll['status_event'] == 'ignore') {
                print_message("[%ystatus Ignored%n]", 'color');
            } else {
                if ($status_db['status_event'] != '') {
                    // If old state not empty and new state not equals to new state
                    $msg = 'Status ';
                    switch ($status_poll['status_event']) {
                        case 'alert':
                            // New state alerted
                            $msg .= "Alert: " . $device['hostname'] . " " . $status_db['status_descr'] . " entered ALERT state: " . $status_poll['status_name'] . " (previous: " . $status_db['status_name'] . ")";
                            log_event($msg, $device, 'status', $status_db['status_id'], 'warning');
                            break;
                        case 'warning':
                            // New state warned
                            $msg .= "Warning: " . $device['hostname'] . " " . $status_db['status_descr'] . " entered WARNING state: " . $status_poll['status_name'] . " (previous: " . $status_db['status_name'] . ")";
                            log_event($msg, $device, 'status', $status_db['status_id']);
                            break;
                        case 'ok':
                            // New state ok
                            $msg .= "Ok: " . $device['hostname'] . " " . $status_db['status_descr'] . " entered OK state: " . $status_poll['status_name'] . " (previous: " . $status_db['status_name'] . ")";
                            log_event($msg, $device, 'status', $status_db['status_id'], 'warning');
                            break;
                    }
                }
            }
        } else {
            // If status not changed, leave old last_change
            $status_poll['status_last_change'] = $status_db['status_last_change'];
        }
        if (OBS_DEBUG > 1) {
            print_vars($status_poll);
        }
        // Send statistics array via AMQP/JSON if AMQP is enabled globally and for the ports module
        if ($config['amqp']['enable'] == TRUE && $config['amqp']['modules']['status']) {
            $json_data = array('value' => $status_value);
            messagebus_send(array('attribs' => array('t' => time(), 'device' => $device['hostname'], 'device_id' => $device['device_id'], 'e_type' => 'status', 'e_type' => $status_db['status_type'], 'e_index' => $status_db['status_index']), 'data' => $json_data));
        }
        // Update StatsD/Carbon
        if ($config['statsd']['enable'] == TRUE) {
            StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'status' . '.' . $status_db['status_class'] . '.' . $status_db['status_type'] . '.' . $status_db['status_index'], $status_value);
        }
        // Update RRD - FIXME - can't convert to NG because filename is dynamic! new function should return index instead of filename.
        $rrd_file = get_status_rrd($device, $status_db);
        rrdtool_create($device, $rrd_file, "DS:status:GAUGE:600:-20000:U");
        rrdtool_update($device, $rrd_file, "N:{$status_value}");
        // Enable graph
        $graphs[$sensor_db['status']] = TRUE;
        // Check alerts
        $metrics = array();
        $metrics['status_value'] = $status_value;
        $metrics['status_name'] = $status_poll['status_name'];
        $metrics['status_name_uptime'] = $status_polled_time - $status_poll['status_last_change'];
        $metrics['status_event'] = $status_poll['status_event'];
        //print_cli_data("Event (State)", $status_poll['status_event'] ." (".$status_poll['status_name'].")", 3);
        $GLOBALS['table_rows'][] = array($status_db['status_descr'], $status_db['status_type'], $status_db['status_index'], $status_db['poller_type'], $status_poll['status_name'], $status_poll['status_event'], format_unixtime($status_poll['status_last_change']));
        check_entity('status', $status_db, $metrics);
        // Update SQL State
        if (is_numeric($status_db['status_polled'])) {
            dbUpdate(array('status_value' => $status_value, 'status_name' => $status_poll['status_name'], 'status_event' => $status_poll['status_event'], 'status_last_change' => $status_poll['status_last_change'], 'status_polled' => $status_polled_time), 'status-state', '`status_id` = ?', array($status_db['status_id']));
        } else {
            dbInsert(array('status_id' => $status_db['status_id'], 'status_value' => $status_value, 'status_name' => $status_poll['status_name'], 'status_event' => $status_poll['status_event'], 'status_last_change' => $status_poll['status_last_change'], 'status_polled' => $status_polled_time), 'status-state');
        }
    }
}
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:functions.inc.php


示例5: print_debug

            if ($config['housekeeping']['rrd']['invalid'] && file_exists($file)) {
                if (!file_exists($config['file'])) {
                    print_debug("Magic 'file' binary not found in configured path!");
                } else {
                    $filetype = $this_data = trim(external_exec($config['file'] . " -b " . $file));
                    if (substr($filetype, 0, 10) != "RRDTool DB") {
                        print_debug("Invalid file type for {$file} ({$filetype}) - deleting");
                        logfile("housekeeping.log", "File {$file} has invalid type: {$filetype} - deleting");
                        unlink($file);
                        $count_notvalid++;
                    }
                }
            }
        }
    }
    if ($prompt && $cutoff) {
        if ($count_notmodified) {
            print_message("Deleted {$count_notmodified} not modified RRD files older than " . format_unixtime($cutoff));
        } else {
            print_message("No RRD files found last modified before " . format_unixtime($cutoff));
        }
    }
    if ($prompt && $config['housekeeping']['rrd']['invalid']) {
        if ($count_notvalid) {
            print_message("Deleted {$count_notvalid} invalid RRD files");
        } else {
            print_message("No invalid RRD files found");
        }
    }
}
// EOF
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:rrd.inc.php


示例6: generate_status_row

function generate_status_row($status, $vars)
{
    global $config;
    $table_cols = 7;
    humanize_status($status);
    $alert = $status['state_event'] == 'alert' ? 'oicon-exclamation-red' : '';
    // FIXME - make this "four graphs in popup" a function/include and "small graph" a function.
    // FIXME - DUPLICATED IN device/overview/status
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $status['status_id'];
    $graph_array['type'] = "status_graph";
    $graph_array['legend'] = "no";
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    $status_misc = '<span class="label">' . $status['entPhysicalClass'] . '</span>';
    $row .= '<tr class="' . $status['row_class'] . '">
        <td class="state-marker"></td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $row .= '<td class="entity">' . generate_device_link($status) . '</td>';
        $table_cols++;
    }
    if ($status['status_event'] && $status['status_name']) {
        $mini_graph = generate_graph_tag($graph_array);
    } else {
        // Do not show "Draw Error" minigraph
        $mini_graph = '';
    }
    $row .= '<td class="entity">' . generate_entity_link('status', $status) . '</td>';
    if ($vars['tab'] != "overview") {
        $row .= '<td><span class="label">' . $status['entPhysicalClass'] . '</span></td>';
        $table_cols++;
    }
    $row .= '<td style="width: 90px; text-align: right;">' . generate_entity_link('status', $status, $mini_graph, NULL, FALSE) . '</td>';
    if ($vars['tab'] != "overview") {
        $row .= '<td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $status['status_last_change'], 'short-2') . ' ago', format_unixtime($status['status_last_change'])) . '</td>
        <td style="text-align: right;"><strong><span class="' . $status['state_class'] . '">' . $status['status_event'] . '</span></strong></td>';
        $table_cols++;
        $table_cols++;
    }
    $row .= '<td style="width: 80px; text-align: right;"><strong><span class="' . $status['state_class'] . '">' . $status['status_name'] . '</span></strong></td>
        </tr>' . PHP_EOL;
    if ($vars['view'] == "graphs") {
        $vars['graph'] = "status";
    }
    if ($vars['graph'] || $vars['id'] == $status['status_id']) {
        // If id set in vars, display only specific graphs
        $row .= '<tr class="' . $status['row_class'] . '">
      <td class="state-marker"></td>
      <td colspan="' . $table_cols . '">';
        unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $status['status_id'];
        $graph_array['type'] = "status_graph";
        $row .= generate_graph_row($graph_array, TRUE);
        $row .= '</td></tr>';
    }
    # endif graphs
    return $row;
}
开发者ID:Natolumin,项目名称:observium,代码行数:62,代码来源:status.inc.php


示例7: snmp_get_multi

$data = snmp_get_multi($device, $oids, "-OQUst", "SNMPv2-MIB:CISCO-CONFIG-MAN-MIB", mib_dirs(array("cisco")));
$config_age = $data[0];
foreach ($config_age as $key => $val) {
    $config_age[$key] = $val / 100;
}
$RunningLastChanged = $config_age['sysUpTime'] - $config_age['ccmHistoryRunningLastChanged'];
$RunningLastChangedTS = time() - $RunningLastChanged;
$RunningLastSaved = $config_age['sysUpTime'] - $config_age['ccmHistoryRunningLastSaved'];
$RunningLastSavedTS = time() - $RunningLastSaved;
$StartupLastChanged = $config_age['sysUpTime'] - $config_age['ccmHistoryStartupLastChanged'];
$StartupLastChangedTS = time() - $StartupLastChanged;
$sysUptimeTS = time() - $config_age['sysUpTime'];
echo 'sysUptime : ' . format_unixtime($sysUptimeTS) . ' | ' . formatUptime($config_age['sysUpTime']) . PHP_EOL;
echo 'Running   : ' . format_unixtime($RunningLastChangedTS) . ' | ' . formatUptime($RunningLastChanged) . PHP_EOL;
echo 'Saved     : ' . format_unixtime($RunningLastSavedTS) . ' | ' . formatUptime($RunningLastSaved) . PHP_EOL;
echo 'Startup   : ' . format_unixtime($StartupLastChangedTS) . ' | ' . formatUptime($StartupLastChanged) . PHP_EOL;
# 7200 and IOS-XE (ASR1k)
if (preg_match('/^Cisco IOS Software, .+? Software \\([^\\-]+-([^\\-]+)-\\w\\),.+?Version ([^, ]+)/', $poll_device['sysDescr'], $regexp_result)) {
    $features = $regexp_result[1];
    $version = $regexp_result[2];
} elseif (preg_match('/Cisco Internetwork Operating System Software\\s+IOS \\(tm\\) [^ ]+ Software \\([^\\-]+-([^\\-]+)-\\w\\),.+?Version ([^, ]+)/', $poll_device['sysDescr'], $regexp_result)) {
    $features = $regexp_result[1];
    $version = $regexp_result[2];
} elseif (is_array($entPhysical)) {
    if ($entPhysical['entPhysicalContainedIn'] === '0') {
        if (!empty($entPhysical['entPhysicalSoftwareRev'])) {
            $version = $entPhysical['entPhysicalSoftwareRev'];
        }
        if (!empty($entPhysical['entPhysicalModelName'])) {
            $hardware = $entPhysical['entPhysicalModelName'];
        } else {
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:ios.inc.php


示例8: generate_sensor_row

function generate_sensor_row($sensor, $vars)
{
    global $config;
    humanize_sensor($sensor);
    $table_cols = 4;
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $sensor['sensor_id'];
    $graph_array['type'] = "sensor_graph";
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    if ($sensor['sensor_event'] && is_numeric($sensor['sensor_value'])) {
        $mini_graph = generate_graph_tag($graph_array);
    } else {
        // Do not show "Draw Error" minigraph
        $mini_graph = '';
    }
    $row = '
      <tr class="' . $sensor['row_class'] . '">
        <td class="state-marker"></td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $row .= '        <td class="entity">' . generate_device_link($sensor) . '</td>' . PHP_EOL;
        $table_cols++;
    }
    if ($vars['entity_icon'] == TRUE) {
        $row .= '        <td width="20px"><i class="' . $config['sensor_types'][$sensor['sensor_class']]['icon'] . '"></i></td>';
    }
    $row .= '        <td class="entity">' . generate_entity_link("sensor", $sensor) . '</td>';
    if ($vars['show_class']) {
        $row .= '        <td>' . nicecase($sensor['sensor_class']) . '</td>' . PHP_EOL;
        $table_cols++;
    }
    if ($vars['tab'] != 'overview') {
        $row .= '        <td><span class="label ' . ($sensor['sensor_custom_limit'] ? 'label-warning' : '') . '">' . $sensor['sensor_thresholds'] . '</span></td>' . PHP_EOL;
        $table_cols++;
    }
    $row .= '        <td style="width: 90px; text-align: right;">' . generate_entity_link('sensor', $sensor, $mini_graph, NULL, FALSE) . '</td>';
    if ($vars['tab'] != 'overview') {
        $row .= '        <td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $sensor['sensor_last_change'], 'short-2') . ' ago', format_unixtime($sensor['sensor_last_change'])) . '</td>';
        $table_cols++;
        $row .= '        <td style="text-align: right;"><strong><span class="' . $sensor['state_class'] . '">' . $sensor['sensor_event'] . '</span></strong></td>';
        $table_cols++;
    }
    $row .= '        <td style="width: 80px; text-align: right;"><strong><span class="' . $sensor['state_class'] . '">' . $sensor['human_value'] . $sensor['sensor_symbol'] . '</span></strong>
        </tr>' . PHP_EOL;
    if ($vars['view'] == "graphs" || $vars['id'] == $sensor['sensor_id']) {
        $vars['graph'] = "graph";
    }
    if ($vars['graph']) {
        $row .= '
      <tr class="' . $sensor['row_class'] . '">
        <td class="state-marker"></td>
        <td colspan="' . $table_cols . '">';
        $graph_array = array();
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $sensor['sensor_id'];
        $graph_array['type'] = 'sensor_' . $vars['graph'];
        $row .= generate_graph_row($graph_array, TRUE);
        $row .= '</td></tr>';
    }
    # endif graphs
    return $row;
}
开发者ID:Natolumin,项目名称:observium,代码行数:65,代码来源:sensor.inc.php


示例9: foreach

   foreach (json_decode($tunnel['tunnel_endpoint'], TRUE) as $entry) {
       $tunnel_endpoint[] = 'Local: ' . generate_popup_link('ip', $entry['local']) . ', Remote: ' . generate_popup_link('ip', $entry['remote']);
   }
   $tunnel_endpoint = implode('<br />', $tunnel_endpoint);
   $timediff = $GLOBALS['config']['time']['now'] - $tunnel['tunnel_added'];
   echo '<tr class="' . $tunnel['row_class'] . '">
 <td class="state-marker"></td>
 <td>' . generate_popup_link('ip', $tunnel['local_addr']) . '</td>
 <td><b>&#187;</b></td>
 <td>' . generate_popup_link('ip', $tunnel['peer_addr']) . '</td>
 <td>' . $tunnel['tunnel_name'] . '</td>
 <td><span>' . $tunnel_endpoint . '</span></td>
 <td><span>' . generate_tooltip_link(NULL, formatUptime($tunnel['tunnel_lifetime'], 'short-3'), $tunnel['tunnel_lifetime'] . ' sec') . '</span></td>
 <td><span class="label ' . $tunnel['ike_label_class'] . '">' . $tunnel['tunnel_ike_alive'] . '</span></td>
 <td><span>' . generate_tooltip_link(NULL, formatUptime($tunnel['tunnel_ike_lifetime'], 'short-3'), $tunnel['tunnel_ike_lifetime'] . ' sec') . '</span></td>
 <td><span>' . generate_tooltip_link(NULL, formatUptime($timediff, "short-3") . ' ago', format_unixtime($tunnel['tunnel_added'])) . '</span></td>
 </tr>';
   switch ($vars['graph']) {
       case 'bits':
       case 'pkts':
           $graph_array['type'] = 'ipsectunnel_' . $vars['graph'];
           $graph_array['id'] = $tunnel['tunnel_id'];
   }
   if ($vars['graph'] == 'bits' || $vars['graph'] == 'pkts') {
       $tunnel['graph'] = 1;
   }
   if ($tunnel['graph']) {
       $graph_array['to'] = $config['time']['now'];
       echo '<tr class="' . $tunnel['row_class'] . '">';
       echo '<td colspan="10">';
       print_graph_row($graph_array);
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:ipsec_tunnels.inc.php


示例10: get_http_request

function get_http_request($request, $context = array(), $rate_limit = FALSE)
{
    global $config;
    $ok = TRUE;
    if (defined('OBS_HTTP_REQUEST') && OBS_HTTP_REQUEST === FALSE) {
        print_debug("HTTP requests skipped since previous request exit with timeout");
        $ok = FALSE;
        $GLOBALS['response_headers'] = array('code' => '408', 'status' => 'Request Timeout');
    } else {
        if (!ini_get('allow_url_fopen')) {
            print_debug('HTTP requests disabled, since PHP config option "allow_url_fopen" set to off. Please enable this option in your PHP config.');
            $ok = FALSE;
            $GLOBALS['response_headers'] = array('code' => '501', 'status' => 'Not Implemented');
        } else {
            if (preg_match('/^https/i', $request) && !check_extension_exists('openssl')) {
                // Check if Secure requests allowed, but ssl extensin not exist
                print_debug(__FUNCTION__ . '() wants to connect with https but https is not enabled on this server. Please check your PHP settings, the openssl extension must exist and be enabled.');
                logfile(__FUNCTION__ . '() wants to connect with https but https is not enabled on this server. Please check your PHP settings, the openssl extension must exist and be enabled.');
                $ok = FALSE;
                $GLOBALS['response_headers'] = array('code' => '501', 'status' => 'HTTPS Method Not Implemented');
            }
        }
    }
    if ($ok && $rate_limit && is_numeric($rate_limit) && $rate_limit >= 0) {
        // Check limit rates to this domain (per/day)
        if (preg_match('/^https?:\\/\\/([\\w\\.]+[\\w\\-\\.]*(:\\d+)?)/i', $request, $matches)) {
            $date = format_unixtime($config['time']['now'], 'Y-m-d');
            $domain = $matches[0];
            // base domain (with http(s)): https://test-me.com/ -> https://test-me.com
            $rate_db = json_decode(get_obs_attrib('http_rate_' . $domain), TRUE);
            //print_vars($date); print_vars($rate_db);
            if (is_array($rate_db) && isset($rate_db[$date])) {
                $rate_count = $rate_db[$date];
            } else {
                $rate_count = 0;
            }
            $rate_count++;
            set_obs_attrib('http_rate_' . $domain, json_encode(array($date => $rate_count)));
            if ($rate_count > $rate_limit) {
                print_debug("HTTP requests skipped because the rate limit {$rate_limit}/day for domain '{$domain}' is exceeded (count: {$rate_count})");
                $GLOBALS['response_headers'] = array('code' => '429', 'status' => 'Too Many Requests');
                $ok = FALSE;
            } else {
                if (OBS_DEBUG > 1) {
                    print_debug("HTTP rate count for domain '{$domain}': {$rate_count} ({$rate_limit}/day)");
                }
            }
        } else {
            $rate_limit = FALSE;
        }
    }
    if (OBS_DEBUG > 0) {
        $debug_request = $request;
        if (OBS_DEBUG < 2 && strpos($request, 'update.observium.org')) {
            $debug_request = preg_replace('/&stats=.+/', '&stats=***', $debug_request);
        }
        $debug_msg = PHP_EOL . 'REQUEST[%y' . $debug_request . '%n]';
    }
    if (!$ok) {
        if (OBS_DEBUG > 0) {
            print_message($debug_msg . PHP_EOL . 'REQUEST STATUS[' . $GLOBALS['response_headers']['code'] . ' ' . $GLOBALS['response_headers']['status'] . ']', 'console');
        }
        return FALSE;
    }
    $response = '';
    if (!is_array($context)) {
        $context = array();
    }
    // Fix context if not array passed
    $opts = array('http' => $context);
    $opts['http']['timeout'] = '15';
    // User agent (required for some type of queries, ie geocoding)
    if (!isset($opts['http']['header'])) {
        $opts['http']['header'] = '';
    }
    // Avoid 'undefined index' when concatting below
    $opts['http']['header'] .= 'User-Agent: ' . OBSERVIUM_PRODUCT . '/' . OBSERVIUM_VERSION . '\\r\\n';
    if (isset($config['http_proxy']) && $config['http_proxy']) {
        $opts['http']['proxy'] = 'tcp://' . $config['http_proxy'];
        $opts['http']['request_fulluri'] = TRUE;
    }
    // Basic proxy auth
    if (isset($config['proxy_user']) && $config['proxy_user'] && isset($config['proxy_password'])) {
        $auth = base64_encode($config['proxy_user'] . ':' . $config['proxy_password']);
        $opts['http']['header'] .= 'Proxy-Authorization: Basic ' . $auth . '\\r\\n';
    }
    $start = utime();
    $context = stream_context_create($opts);
    $response = file_get_contents($request, FALSE, $context);
    $runtime = utime() - $start;
    // Parse response headers
    $head = array();
    foreach ($http_response_header as $k => $v) {
        $t = explode(':', $v, 2);
        if (isset($t[1])) {
            $head[trim($t[0])] = trim($t[1]);
        } else {
            if (preg_match("!HTTP/([\\d\\.]+)\\s+(\\d+)(.*)!", $v, $matches)) {
                $head['http'] = $matches[1];
                $head['code'] = intval($matches[2]);
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:common.inc.php


示例11: generate_pseudowire_row

function generate_pseudowire_row($pw, $vars)
{
    global $config;
    humanize_pseudowire($pw);
    $table_cols = 11;
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $pw['pseudowire_id'];
    $graph_array['type'] = $pw['graph'];
    $graph_array['legend'] = "no";
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    if ($pw['event'] && $pw['pwOperStatus']) {
        $mini_graph = generate_graph_tag($graph_array);
    } else {
        // Do not show "Draw Error" minigraph
        $mini_graph = '';
    }
    $out = '<tr class="' . $pw['row_class'] . '"><td class="state-marker"></td>';
    $out .= '<td class="entity" style="text-align: right;">' . generate_entity_link('pseudowire', $pw, NULL, NULL, TRUE, TRUE) . '</td>';
    $out .= '<td>' . nicecase($pw['pwType']) . '/' . nicecase($pw['pwPsnType']) . '</td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $out .= '<td class="entity">' . generate_device_link($pw, NULL, array('tab' => 'pseudowires')) . '</td>';
        $table_cols++;
    }
    $out .= '<td class="entity">' . generate_entity_link('port', $pw['port_id']) . '</td>';
    $out .= '<td><span class="text-success"><i class="glyphicon glyphicon-arrow-right"></i></span></td>';
    if ($pw['peer_port_id']) {
        $out .= '<td class="entity">' . generate_entity_link('device', $pw['peer_device_id']) . '</td>';
        $out .= '<td class="entity">' . generate_entity_link('port', $pw['peer_port_id']) . '</td>';
    } else {
        $out .= '<td class="entity">' . generate_popup_link('ip', $pw['peer_addr']) . '</td>';
        $out .= '<td>' . $pw['pwRemoteIfString'] . '</td>';
    }
    $out .= '<td>' . generate_entity_link('pseudowire', $pw, $mini_graph, NULL, FALSE) . '</td>';
    $out .= '<td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $pw['last_change'], 'short-2') . ' ago', format_unixtime($pw['last_change'])) . '</td>';
    $out .= '<td style="text-align: right;"><strong><span class="' . $pw['pw_class'] . '">' . $pw['event'] . '</span></strong></td>';
    $out .= '<td style="text-align: right;"><strong><span class="' . $pw['pw_class'] . '">' . $pw['pwOperStatus'] . '</span></strong></td>';
    $out .= '<td>' . formatUptime($pw['pwUptime'], 'short-2') . '</td>';
    $out .= '</tr>';
    if ($vars['graph'] || $vars['view'] == "graphs" || $vars['id'] == $pw['pseudowire_id']) {
        // If id set in vars, display only specific graphs
        $graph_array = array();
        $graph_array['type'] = $vars['graph'] ? $vars['graph'] : $pw['graph'];
        $graph_array['id'] = $pw['pseudowire_id'];
        $out .= '<tr class="' . $pw['row_class'] . '">';
        $out .= '  <td class="state-marker"></td>';
        $out .= '  <td colspan="' . $table_cols . '">';
        $out .= generate_graph_row($graph_array, TRUE);
        $out .= '  </td>';
        $out .= '</tr>';
    }
    return $out;
}
开发者ID:Natolumin,项目名称:observium,代码行数:56,代码来源:pseudowire.inc.php


示例12: sprintf

            case "finishtime":
                $perlArgs[] = sprintf($finishArg, $value);
                break;
            case "ipaddress":
                $perlArgs[] = sprintf($IPArg, $value);
                break;
        }
    }
    return sprintf($perlCommand, implode(' && ', $perlArgs));
}
/* Start Page Logic */
if (trim($_GET['acctid']) != '') {
    $session = DatabaseFunctions::getInstance()->getRadiusSessionDetails($_GET['acctid']);
    // Build up components for perl matching command
    $conditions['starttime'] = escapeshellcmd(format_unixtime($session['AcctStartTime']));
    $finishTime = escapeshellcmd(format_unixtime($session['AcctStopTime']));
    if ($finishTime != "0.0.0 0:00:00" && $finishTime != '') {
        $conditions['finishtime'] = $finishTime;
    }
    $conditions['ipaddress'] = escapeshellcmd($session['FramedIPAddress']);
    /* We use a perl command as it's faster and easier to code the
     * matching logic than trying to process the entire log file in PHP */
    $perlCommand = buildPerlCommand($conditions);
    $username = $session['Username'];
    $command = "gunzip -fc /var/log/squid3/access.log*  | {$perlCommand} ";
} else {
    $error = "Invalid Acctid";
    $templateEngine->assign("error", $error);
}
if ($command) {
    $logLines = array();
开发者ID:KuberKode,项目名称:grase-www-portal,代码行数:31,代码来源:logview.php


示例13: snmp_get_multi

if (is_device_mib($device, 'CISCO-CONFIG-MAN-MIB')) {
    // Check Cisco configuration age
    $oids = 'sysUpTime.0 ccmHistoryRunningLastChanged.0 ccmHistoryRunningLastSaved.0 ccmHistoryStartupLastChanged.0';
    $data = snmp_get_multi($device, $oids, '-OQUst', 'SNMPv2-MIB:CISCO-CONFIG-MAN-MIB');
    $config_age = $data[0];
    foreach ($config_age as $key => $val) {
        $config_age[$key] = $val / 100;
    }
    $RunningLastChanged = $config_age['sysUpTime'] - $config_age['ccmHistoryRunningLastChanged'];
    $RunningLastChangedTS = time() - $RunningLastChanged;
    $RunningLastSaved = $config_age['sysUpTime'] - $config_age['ccmHistoryRunningLastSaved'];
    $RunningLastSavedTS = time() - $RunningLastSaved;
    $StartupLastChanged = $config_age['sysUpTime'] - $config_age['ccmHistoryStartupLastChanged'];
    $StartupLastChangedTS = time() - $StartupLastChanged;
    $sysUptimeTS = time() - $config_age['sysUpTime'];
    $os_additional_info['Cisco configuration ages'] = array('sysUptime' => format_unixtime($sysUptimeTS) . ' | ' . formatUptime($config_age['sysUpTime']), 'Running' => format_unixtime($RunningLastChangedTS) . ' | ' . formatUptime($RunningLastChanged), 'Saved' => format_unixtime($RunningLastSavedTS) . ' | ' . formatUptime($RunningLastSaved), 'Startup' => format_unixtime($StartupLastChangedTS) . ' | ' . formatUptime($StartupLastChanged));
}
$sysDescr = preg_replace('/\\s+/', ' ', $poll_device['sysDescr']);
// Replace all spaces and newline to single space
// Generic IOS/IOS-XE/IES/IOS-XR sysDescr
if (preg_match('/^Cisco IOS Software, .+? Software \\([^\\-]+-([\\w\\d]+)-\\w\\),.+?Version ([^, ]+)/', $sysDescr, $matches)) {
    //Cisco IOS Software, Catalyst 4500 L3 Switch Software (cat4500e-ENTSERVICESK9-M), Version 15.2(1)E3, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2014 by Cisco Systems, Inc. Compiled Mon 05-May-14 07:56 b
    //Cisco IOS Software, IOS-XE Software (PPC_LINUX_IOSD-IPBASEK9-M), Version 15.2(2)S, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2012 by Cisco Systems, Inc. Compiled Mon 26-Mar-12 15:23 by mcpre
    //Cisco IOS Software, IES Software (IES-LANBASEK9-M), Version 12.2(52)SE1, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by Cisco Systems, Inc. Compiled Tue 09-Feb-10 03:17 by prod_rel_team
    $features = $matches[1];
    $version = $matches[2];
} else {
    if (preg_match('/^Cisco Internetwork Operating System Software IOS \\(tm\\) [^ ]+ Software \\([^\\-]+-([\\w\\d]+)-\\w\\),.+?Version ([^, ]+)/', $sysDescr, $matches)) {
        //Cisco Internetwork Operating System Software IOS (tm) 7200 Software (UBR7200-IK8SU2-M), Version 12.3(17b)BC8, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2007 by cisco Systems, Inc. Compiled Fri 29-Ju
        //Cisco Internetwork Operating System Software IOS (tm) C1700 Software (C1700-Y-M), Version 12.2(4)YA2, EARLY DEPLOYMENT RELEASE SOFTWARE (fc1) Synched to technology version 12.2(5.4)T TAC Support: http://www.cisco.com/tac Copyright (c) 1986-2002 by ci
        $features = $matches[1];
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:cisco.inc.php


示例14: unset

                        if ($geo_db[$k] == $value) {
                            unset($update_geo[$k]);
                        }
                    }
                    if ($update_geo) {
                        dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', array($geo_db['location_id']));
                        if ($geo_msg) {
                            log_event($geo_msg, $device, 'device', $device['device_id']);
                        }
                    }
                    // else not changed
                } else {
                    $update_geo['device_id'] = $device['device_id'];
                    dbInsert($update_geo, 'devices_locations');
                    if ($geo_msg) {
                        log_event($geo_msg, $device, 'device', $device['device_id']);
                    }
                }
            }
        } else {
            if (is_numeric($geo_db['location_id'])) {
                $update_geo = array('location_updated' => format_unixtime($config['time']['now'], 'Y-m-d G:i:s'));
                // Increase updated time
                dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', array($geo_db['location_id']));
            }
        }
        # end if $update_geo
    }
}
unset($geo_detect, $geo_db, $update_geo);
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:system.inc.php


示例15: age_to_unixtime

 * @package    observium
 * @subpackage housekeeping
 * @author     Adam Armstrong <[email protected]>
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$cutoff = age_to_unixtime($config['housekeeping']['deleted_ports']['age']);
if ($cutoff) {
    $where = "`deleted` = 1 AND UNIX_TIMESTAMP(`ifLastChange`) < {$cutoff}";
    $ports = dbFetchRows("SELECT `port_id` FROM `ports` WHERE {$where}");
    $count = count($ports);
    if ($count) {
        if ($prompt) {
            $answer = print_prompt("{$count} ports marked as deleted before " . format_unixtime($cutoff) . " will be deleted");
        }
        if ($answer) {
            foreach ($ports as $entry) {
                delete_port($entry['port_id']);
            }
            print_debug("Deleted ports housekeeping: deleted {$count} entries");
            logfile("housekeeping.log", "Deleted ports: deleted {$count} entries older than " . format_unixtime($cutoff));
        }
    } else {
        if ($prompt) {
            print_message("No ports found marked as deleted before " . format_unixtime($cutoff));
        }
    }
} else {
    print_message("Deleted ports housekeeping disabled in configuration.");
}
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:ports.inc.php


示例16: print_error_permission

    print_error_permission();
    return;
}
?>

<div class="row">
  <div class="col-md-12">

<?php 
$box_args = array('title' => 'Duration', 'header-border' => TRUE, 'padding' => TRUE);
$box_args['header-controls'] = array('controls' => array('perf' => array('text' => 'Performance Data', 'anchor' => TRUE, 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'perf')))));
echo generate_box_open($box_args);
$ptime = dbFetchRow('SELECT * FROM `devices_perftimes` WHERE `operation` = "poll" AND `device_id` = ? ORDER BY `start` DESC LIMIT 1', array($device['device_id']));
echo "Last Polled: <b>" . format_unixtime($ptime['start']) . '</b> (took ' . $ptime['duration'] . 's) - <a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'perf')) . '">Details</a>';
$dtime = dbFetchRow('SELECT * FROM `devices_perftimes` WHERE `operation` = "discover" AND `device_id` = ? ORDER BY `start` DESC LIMIT 1', array($device['device_id']));
echo "<p>Last discovered: <b>" . format_unixtime($dtime['start']) . '</b> (took ' . $dtime['duration'] . 's) - <a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'perf')) . '">Details</a></p>';
echo generate_box_close();
$box_args = array('title' => 'RANCID', 'header-border' => TRUE, 'padding' => TRUE);
$box_args['header-controls'] = array('controls' => array('perf' => array('text' => 'Show Config', 'anchor' => TRUE, 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')))));
echo generate_box_open($box_args);
if (count($config['rancid_configs'])) {
    $device_config_file = get_rancid_filename($device['hostname'], 1);
    echo '<p />';
    if ($device_config_file) {
        print_success("Configuration file for device was found; will be displayed to users with level 7 or higher.");
    } else {
        print_warning("Configuration file for device was not found.");
    }
} else {
    print_warning("No RANCID directories configured.");
}
开发者ID:Natolumin,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP format_url函数代码示例发布时间:2022-05-15
下一篇:
PHP format_uid函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap