close

本人現在的工作環境,約有 1600 台主機需要納入監控。

如果使用 Web GUI 一台一台慢慢加,大約會需要 1600 * 1(分鐘) = 1600(分鐘)  = 26.6(小時)

所以.....不可能一台一台慢慢加,一定要找一個快速大量監控節點設定的方法。

 

因為 OpsView 是使用 MySQL Database,而安裝時也有設定了 MySQL 的 root 帳號密碼,於是我就登入 MySQL 中看看 Table 有那些,和資料是如何存放的。

各個 Table 名稱都很清楚的描述它的用途,像是

host_attributes  (設定 host 的 attributes)

hosthosttemplates (設定 host 所使用的 hosttemplates)

hosts (設定受監控 host 的資料)

 

接著我使用 MySQL workbench 來新增一台受監控主機,並記下其 SQL 語法,其語法如下

INSERT INTO `opsview`.`hosts` (`id`, `name`, `ip`, `alias`, `notification_interval`, `hostgroup`, `check_period`, `check_interval`, `retry_check_interval`, `check_attempts`, `icon`, `enable_snmp`, `snmp_version`, `snmp_port`, `snmp_community`, `snmpv3_username`, `snmpv3_authpassword`, `snmpv3_privpassword`, `use_nmis`, `nmis_node_type`, `notification_options`, `notification_period`, `check_command`, `monitored_by`, `uncommitted`, `other_addresses`, `snmptrap_tracing`, `flap_detection_enabled`, `use_rancid`, `rancid_connection_type`, `rancid_autoenable`, `use_mrtg`, `tidy_ifdescr_level`, `snmp_max_msg_size`, `snmp_extended_throughput_data`, `event_handler`) VALUES ('1536', 'F015', '10.50.7.15', '', '60', '14', '1', '30', '1', '2', 'LOGO - Windows', '1', '2c', '161', 'rayvision', '', '', '', '1', 'server', 'u,d,r,f', '1', '15', '1', '0', '', '0', '0', '0', 'ssh', '0', '1', '0', '0', '0', '');

設定它使用的 templates 語法如下

INSERT INTO `opsview`.`hosthosttemplates` (`hostid`, `hosttemplateid`, `priority`) select id , "66" , "1" from opsview.hosts where id = 1536;

 

設定它要具有的 attributes 語法如下

INSERT INTO `opsview`.`host_attributes` (`host`, `attribute`, `value`) select id , "18" , "C" from opsview.hosts where id = 1536;

 

如此一來,只要在 EXECL 和 NotePad++ 上一次把 1600 台受監控主機的 SQL 句子編輯好後,就可以快速的設定大量節點,而不用一台一台慢慢加。

 

 

 

arrow
arrow
    全站熱搜

    johnchen6927 發表在 痞客邦 留言(0) 人氣()