Пример #1
0
 /**
  * 修改监控适配器 
  * 
  * @access public
  * @return void
  */
 public function action_mod()
 {
     $madapter_name = $this->__request->get_post('name', '');
     $madapter_id = $this->__request->get_post('madapter_id', '');
     $madapter_display_name = $this->__request->get_post('display_name', '');
     $steps = $this->__request->get_post('steps', '');
     $store_type = $this->__request->get_post('store_type', '');
     $madapter_type = $this->__request->get_post('madapter_type', '');
     if (!$madapter_id) {
         return $this->render_json(null, 10001, '`madapter_id` not allow is empty.');
     }
     if ($madapter_display_name) {
         $data['madapter_display_name'] = $madapter_display_name;
     }
     if ($steps) {
         $data['steps'] = $steps;
     }
     if ($store_type) {
         $data['store_type'] = $store_type;
     }
     if ($madapter_type) {
         $data['madapter_type'] = $madapter_type;
     }
     if ($madapter_name) {
         $data['madapter_name'] = $madapter_name;
     }
     // 修改 madapter basic
     try {
         $property_basic = sw_member::property_factory('madapter_basic', $data);
         $condition = sw_member::condition_factory('mod_madapter_basic', array('madapter_id' => $madapter_id));
         $condition->set_in('madapter_id');
         $condition->set_property($property_basic);
         $madapter = sw_member::operator_factory('madapter');
         $madapter->get_operator('basic')->mod_basic($condition);
     } catch (\swan\exception\sw_exception $e) {
         return $this->render_json(null, 10002, $e->getMessage());
     }
     return $this->render_json(null, 10000, 'mod madapter success.');
 }
Пример #2
0
 /**
  * test_del_archive 
  * 
  * @access public
  * @return void
  */
 public function test_del_archive()
 {
     $condition = sw_member::condition_factory('del_madapter_archive', array('madapter_id' => 1, 'archive_id' => 2));
     $condition->set_in('madapter_id');
     $condition->set_in('archive_id');
     $madapter = sw_member::operator_factory('madapter');
     $madapter->get_operator('archive')->del_archive($condition);
     $query_table = $this->getConnection()->CreateQueryTable('madapter_archive', 'select * from madapter_archive');
     $expect = $this->createXMLDataSet(dirname(__FILE__) . '/_files/del_result.xml')->getTable('madapter_archive');
     $this->assertTablesEqual($expect, $query_table);
 }
Пример #3
0
 /**
  * 修改监控适配器数据项 
  * 
  * @access public
  * @return void
  */
 public function action_mod()
 {
     $mid = $this->__request->get_post('madapter_id', '');
     $mmid = $this->__request->get_post('metric_id', '');
     $name = $this->__request->get_post('name', '');
     $unit = $this->__request->get_post('unit', '');
     $title = $this->__request->get_post('title', '');
     $tmax = $this->__request->get_post('tmax', '');
     $vmax = $this->__request->get_post('vmax', 'U');
     $vmin = $this->__request->get_post('vmin', 'U');
     $dst_type = $this->__request->get_post('dst_type', '');
     $collect_every = $this->__request->get_post('collect_every', '');
     $time_threshold = $this->__request->get_post('time_threshold', '');
     if (!$mid || !$mmid) {
         return $this->render_json(null, 10001, '`madapter_id` and `metric_id` not allow is empty.');
     }
     // 修改 madapter metric
     $data = array();
     if ($name) {
         $data['metric_name'] = $name;
     }
     if ($title) {
         $data['title'] = $title;
     }
     if ($unit) {
         $data['unit'] = $unit;
     }
     if ($collect_every) {
         $data['collect_every'] = $collect_every;
     }
     if ($time_threshold) {
         $data['time_threshold'] = $time_threshold;
     }
     if ($dst_type) {
         $data['dst_type'] = $dst_type;
     }
     if ($vmax) {
         $data['vmax'] = $vmax;
     }
     if ($vmin) {
         $data['vmin'] = $vmin;
     }
     if ($tmax) {
         $data['tmax'] = $tmax;
     }
     try {
         $property_metric = sw_member::property_factory('madapter_metric', $data);
         $condition = sw_member::condition_factory('mod_madapter_metric', array('madapter_id' => $mid, 'metric_id' => $mmid));
         $condition->set_in('madapter_id');
         $condition->set_in('metric_id');
         $condition->set_property($property_metric);
         $madapter = sw_member::operator_factory('madapter');
         $madapter->get_operator('metric')->mod_metric($condition);
     } catch (\swan\exception\sw_exception $e) {
         return $this->render_json(null, 10002, $e->getMessage());
     }
     return $this->render_json(null, 10000, 'mod madapter metric success.');
 }
Пример #4
0
 /**
  * 获取属性的详细信息 
  * 
  * @param int $monitor_id 
  * @param int $attr_id 
  * @access protected
  * @return array
  */
 protected function _get_attr_info($monitor_id, $device_id)
 {
     try {
         $device = sw_member::operator_factory('device');
         $condition = sw_member::condition_factory('get_device_monitor_params');
         $condition->set_in('device_id');
         $condition->set_device_id($device_id);
         $condition->set_in('monitor_id');
         $condition->set_monitor_id($monitor_id);
         $condition->set_is_count(false);
         $monitor_params = $device->get_operator('monitor')->get_monitor_params($condition);
     } catch (\swan\exception\sw_exception $e) {
         throw new sw_exception($e);
     }
     return $monitor_params;
 }
Пример #5
0
 /**
  * 修改监控适配器属性 
  * 
  * @access public
  * @return void
  */
 public function action_mod()
 {
     $mid = $this->__request->get_post('madapter_id', '');
     $aid = $this->__request->get_post('attr_id', '');
     $name = $this->__request->get_post('name', '');
     $display_name = $this->__request->get_post('display_name', '');
     $form_type = $this->__request->get_post('form_type', '');
     $form_data = $this->__request->get_post('form_data', '');
     $attr_default = $this->__request->get_post('attr_default', '');
     if (!$mid || !$aid) {
         return $this->render_json(null, 10001, '`madapter_id` and `attr_id` not allow is empty.');
     }
     // 修改 madapter attribute
     $data = array();
     if ($name) {
         $data['attr_name'] = $name;
     }
     if ($display_name) {
         $data['attr_display_name'] = $display_name;
     }
     if ($form_type) {
         $data['form_type'] = $form_type;
     }
     if ($form_data) {
         $data['form_data'] = $form_data;
     }
     if ($attr_default) {
         $data['attr_default'] = $attr_default;
     }
     try {
         $property_attribute = sw_member::property_factory('madapter_attribute', $data);
         $condition = sw_member::condition_factory('mod_madapter_attribute', array('madapter_id' => $mid, 'attr_id' => $aid));
         $condition->set_in('madapter_id');
         $condition->set_in('attr_id');
         $condition->set_property($property_attribute);
         $madapter = sw_member::operator_factory('madapter');
         $madapter->get_operator('attribute')->mod_attribute($condition);
     } catch (\swan\exception\sw_exception $e) {
         return $this->render_json(null, 10002, $e->getMessage());
     }
     return $this->render_json(null, 10000, 'mod madapter success.');
 }
Пример #6
0
 /**
  * 修改监控适配器数据项 
  * 
  * @access public
  * @return void
  */
 public function action_mod()
 {
     $mid = $this->__request->get_post('madapter_id', '');
     $arid = $this->__request->get_post('archive_id', '');
     $cf_type = $this->__request->get_post('cf_type', '');
     $xff = $this->__request->get_post('xff', '');
     $title = $this->__request->get_post('title', '');
     $steps = $this->__request->get_post('steps', '');
     $rows = $this->__request->get_post('rows', '');
     if (!$mid || !$arid) {
         return $this->render_json(null, 10001, '`mid` and `arid` not allow is empty.');
     }
     // 修改 madapter archive
     $data = array();
     if ($cf_type) {
         $data['cf_type'] = $cf_type;
     }
     if ($xff) {
         $data['xff'] = $xff;
     }
     if ($title) {
         $data['title'] = $title;
     }
     if ($steps) {
         $data['steps'] = $steps;
     }
     if ($rows) {
         $data['rows'] = $rows;
     }
     try {
         $property_archive = sw_member::property_factory('madapter_archive', $data);
         $condition = sw_member::condition_factory('mod_madapter_archive', array('madapter_id' => $mid, 'archive_id' => $arid));
         $condition->set_in('madapter_id');
         $condition->set_in('archive_id');
         $condition->set_property($property_archive);
         $madapter = sw_member::operator_factory('madapter');
         $madapter->get_operator('archive')->mod_archive($condition);
     } catch (\swan\exception\sw_exception $e) {
         return $this->render_json(null, 10002, $e->getMessage());
     }
     return $this->render_json(null, 10000, 'mod madapter archive success.');
 }
Пример #7
0
 /**
  * 获取设备监控器 params 值 
  * 
  * @access public
  * @return string
  */
 public function action_info()
 {
     // 获取设备监控器 params 值
     $device_id = $this->__request->get_post('device_id', '');
     $monitor_id = $this->__request->get_post('monitor_id', '');
     $page = $this->__request->get_post('page', 1);
     $page_count = $this->__request->get_post('page_count', 10);
     $count = 0;
     if (!$device_id || !$monitor_id) {
         return $this->render_json(null, 10001, '`device_id`/`monitor_id` not allow is empty.');
     }
     try {
         $condition = sw_member::condition_factory('get_device_monitor_params');
         $condition->set_in('device_id');
         $condition->set_device_id($device_id);
         $condition->set_in('monitor_id');
         $condition->set_monitor_id($monitor_id);
         $condition->set_is_count(true);
         $device = sw_member::operator_factory('device');
         $count = $device->get_operator('monitor')->get_monitor_params($condition);
     } catch (\swan\exception\sw_exception $e) {
         return $this->render_json(null, 10001, $e->getMessage());
     }
     if (!$count) {
         return $this->render_json(array('count' => $count), 10001, 'no data.');
     }
     try {
         $condition = sw_member::condition_factory('get_device_monitor_params');
         $condition->set_in('device_id');
         $condition->set_device_id($device_id);
         $condition->set_in('monitor_id');
         $condition->set_monitor_id($monitor_id);
         $device = sw_member::operator_factory('device');
         $data = $device->get_operator('monitor')->get_monitor_params($condition);
     } catch (\swan\exception\sw_exception $e) {
         return $this->render_json(null, 10001, $e->getMessage());
     }
     $result = array('result' => $data, 'count' => $count);
     return $this->render_json($result, 10000, 'get device monitor success.');
 }
Пример #8
0
 /**
  * test_del_basic 
  * 
  * @access public
  * @return void
  */
 public function test_del_basic()
 {
     $condition = sw_member::condition_factory('del_device_basic', array('device_id' => 2));
     $condition->set_in('device_id');
     $device = sw_member::operator_factory('device');
     $device->get_operator('basic')->del_basic($condition);
     $query_table = $this->getConnection()->CreateQueryTable('device_basic', 'select * from device_basic');
     $expect = $this->createXMLDataSet(dirname(__FILE__) . '/_files/del_result.xml')->getTable('device_basic');
     $this->assertTablesEqual($expect, $query_table);
 }
Пример #9
0
 /**
  * 获取设备列表 
  * 
  * @access public
  * @return string
  */
 public function action_json()
 {
     // 获取设备
     $page = $this->__request->get_post('page', 1);
     $page_count = $this->__request->get_post('page_count', 10);
     $count = 0;
     try {
         $condition = sw_member::condition_factory('get_device');
         $condition->set_is_count(true);
         $device = sw_member::operator_factory('device');
         $count = $device->get_device($condition);
     } catch (\swan\exception\sw_exception $e) {
         return $this->render_json(null, 10001, $e->getMessage());
     }
     if (!$count) {
         return $this->render_json(array('count' => $count), 10001, 'no data.');
     }
     try {
         $condition = sw_member::condition_factory('get_device');
         $condition->set_is_count(false);
         $condition->set_limit_page(array('page' => $page, 'rows_count' => $page_count));
         $data = $device->get_device($condition);
     } catch (\swan\exception\sw_exception $e) {
         return $this->render_json(null, 10001, $e->getMessage());
     }
     $result = array('result' => $data, 'count' => $count);
     return $this->render_json($result, 10000, 'get device success.');
 }
Пример #10
0
 /**
  * test_get_monitor_params 
  * 
  * @access public
  * @return void
  */
 public function test_get_monitor_params()
 {
     $condition = sw_member::condition_factory('get_device_monitor_params');
     $condition->set_in('device_id');
     $condition->set_device_id(1);
     $condition->set_in('monitor_id');
     $condition->set_monitor_id(1);
     $device = sw_member::operator_factory('device');
     $device_monitor = $device->get_operator('monitor')->get_monitor_params($condition);
     $query_table = $this->array_to_dbset(array('monitor_params' => $device_monitor))->getTable('monitor_params');
     $expect = $this->createXMLDataSet(dirname(__FILE__) . '/_files/get_params_result.xml')->getTable('monitor_params');
     $this->assertTablesEqual($expect, $query_table);
 }