コード例 #1
0
ファイル: install.php プロジェクト: kansifang/share
 /**
  * 显示现在安装了多少个数据表
  */
 public static function show()
 {
     $mysql = new shareMysql(DB_HOST, DB_USER, DB_PASS, DB_PRE, DB_NAME, DB_PORT, CHARSET);
     return $mysql->query('show tables');
 }
コード例 #2
0
ファイル: crontab.php プロジェクト: kansifang/share
<?php

//crontab
$base = dirname(__FILE__) . '/';
require $base . '../config.php';
load_file(SHARE_ROOT . 'class/shareMysql.php');
$mysql = new shareMysql(DB_HOST, DB_USER, DB_PASS, DB_PRE, DB_NAME, DB_PORT, CHARSET);
$servers = $mysql->select('server')->query();
load_file($base . '../model/server.php');
$t = microtime(true);
$day_break = time::day_break();
foreach ($servers as $s) {
    echo "==========" . $s['name'] . "==============\r\n";
    $ip = ip::long_to_ip($s['ip']);
    $security_name = mserver::decode_security_name($s);
    $pass_phrase = mserver::decode_pass_phrase($s);
    $snmp = new snmpworker($s['type'], $ip . ':' . $s['port'], $security_name, SNMP_AUTH_PRIV, $s['auth_protocol'], $pass_phrase, $s['priv_protocol'], $pass_phrase);
    $rs = $snmp->get('.1.3.6.1.4.1.2021');
    $where = array();
    //内存
    $data = array();
    $where['time'] = $day_break;
    $where['server_id'] = $s['id'];
    $data['now'] = $_SERVER['REQUEST_TIME'];
    $mem_total = clean($rs['UCD-SNMP-MIB::memTotalReal.0']);
    $mem_free = clean($rs['UCD-SNMP-MIB::memAvailReal.0']);
    $mem_buffers = clean($rs['UCD-SNMP-MIB::memBuffer.0']);
    $mem_cache = clean($rs['UCD-SNMP-MIB::memCached.0']);
    $data['mem_used'] = $mem_total - $mem_free - $mem_buffers - $mem_cache;
    echo "mem_used : " . $data['mem_used'] . "\r\n";
    update_data('memory', $where, $data);