Abills NMS: различия между версиями

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску
Строка 96: Строка 96:
 
);
 
);
 
}
 
}
<PRE>
+
</PRE>
   
 
<PRE>
 
<PRE>

Версия 09:59, 20 октября 2010

CREATE TABLE user_switch (
    uid int default NULL,
    switch_ip int default NULL,
    port int default NULL,
    vlan int default NULL
) TYPE=InnoDB;
CREATE TABLE dhcplog (
  host varchar(32) default NULL,
  facility varchar(10) default NULL,
  priority varchar(10) default NULL,
  level varchar(10) default NULL,
  tag varchar(10) default NULL,
  date date default NULL,
  time time default NULL,
  program varchar(15) default NULL,
  msg text,
  seq int(10) unsigned NOT NULL auto_increment,
  local_time timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (seq),
  KEY host (host),
  KEY seq (seq),
  KEY program (program),
  KEY time (time),
  KEY date (date),
  KEY priority (priority),
  KEY facility (facility)
) ENGINE=MyISAM AUTO_INCREMENT=72 DEFAULT CHARSET=latin1;


 CREATE TABLE dhcphosts_networks_vlans (
  id int(11) default NULL,
  vlan int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8


CREATE TABLE nmslog (
  seq int(10) unsigned NOT NULL auto_increment,
  local_time timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  client_ip varchar(32) default NULL,
  uid int(11) default NULL,
  VLAN int(11) default NULL,
  MODULE int(11) default NULL,
  PORT int(11) default NULL,
  MAC varchar(32) default NULL,
  SWITCH varchar(32) default NULL,
  username varchar(32) default NULL,
  client_net int(11) default NULL,
  msg text,
  log_reason varchar(255) default "info", 
  PRIMARY KEY  (seq)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;



Вместо ID NASa я использую его IP - так проще. И, соответвенно, расширяю поле.

ALTER TABLE dhcphosts_hosts  change nas nas int unsigned;    
SELECT 
   dhcphosts_networks.id,
   INET_NTOA(dhcphosts_networks.network),
   INET_NTOA(dhcphosts_networks.mask
FROM
   ( dhcphosts_networks JOIN dhcphosts_networks_vlans on dhcphosts_networks.id=dhcphosts_networks_vlans.id );


DHCP VIEW

Пример класса для мака 52:54:0:12:34:56 и порта 4

class "match_vlan__2001__port__4__MAC__52:54:0:12:34:56__switch__172.31.0.2"
{
    match if (
        binary-to-ascii(10, 16, "",  substring(option agent.circuit-id, 2, 2)) = "2001"
        and
        binary-to-ascii(10, 8, "",  substring(option agent.circuit-id, 5, 1)) = "4"
        and
        binary-to-ascii(16,  8, ":", substring(hardware,                1, 6)) = "52:54:0:12:34:56"
        and
        substring(option agent.remote-id, 2, 15) = "172.31.0.2"
    );
}
SELECT
dhcphosts_networks.id AS network,
INET_NTOA(dhcphosts_hosts.ip) as ip,
dhcphosts_networks_vlans.vlan AS vlan,
dhcphosts_hosts.mac AS mac,
INET_NTOA(dhcphosts_hosts.nas) AS switch
CONCAT
FROM
   (
     dhcphosts_networks 
     JOIN 
        dhcphosts_hosts 
     ON 
        dhcphosts_networks.id=dhcphosts_hosts.network
    )
     JOIN 
        dhcphosts_networks_vlans
     ON
       dhcphosts_networks_vlans.id=dhcphosts_networks.id;


+----+----------+-----------+------------+---------------+------------+--------------+----------------+-------------+-------+-----------+---------+----------------+---------------+----------+----------------------+---------------+------------+------+------+-----------+----------+---------+------------------+---------+--------+-----------+------------+------+----------+------+------------+-----------+-------+-----------+---------------------+------+------+
| id | name     | network   | mask       | block_network | block_mask | suffix       | dns            | coordinator | phone | routers   | disable | ip_range_first | ip_range_last | comments | deny_unknown_clients | authoritative | net_parent | id   | uid  | ip        | hostname | network | mac              | disable | forced | blocktime | expire     | seen | comments | vid  | nas        | option_82 | ports | boot_file | changed             | id   | vlan |
+----+----------+-----------+------------+---------------+------------+--------------+----------------+-------------+-------+-----------+---------+----------------+---------------+----------+----------------------+---------------+------------+------+------+-----------+----------+---------+------------------+---------+--------+-----------+------------+------+----------+------+------------+-----------+-------+-----------+---------------------+------+------+
|  9 | VLAN2001 | 167837952 | 4294967040 |             0 |          0 | net_vlan2001 | 172.16.255.254 | sirmax      |       | 167837953 |       0 |      167837954 |     167838206 |          |                    0 |             1 |          0 | 1788 | 1774 | 167837954 | sirmax1  |       9 | 52:54:0:12:34:56 |       0 |      0 |         0 | 0000-00-00 |    0 |          | 2001 | 2887713021 |         0 | 9     |           | 2010-10-19 23:31:57 |    9 | 2001 |
+----+----------+-----------+------------+---------------+------------+--------------+----------------+-------------+-------+-----------+---------+----------------+---------------+----------+----------------------+---------------+------------+------+------+-----------+----------+---------+------------------+---------+--------+-----------+------------+------+----------+------+------------+-----------+-------+-----------+---------------------+------+------+
1 row in set (0.00 sec)