Mysql NAgios Log: различия между версиями
Материал из noname.com.ua
Перейти к навигацииПерейти к поискуSirmax (обсуждение | вклад) |
Sirmax (обсуждение | вклад) |
||
Строка 2: | Строка 2: | ||
==Загрузить логи в Mysql== |
==Загрузить логи в Mysql== |
||
<PRE> |
<PRE> |
||
+ | </PRE> |
||
+ | |||
+ | ==Это Просто пример== |
||
+ | <PRE> |
||
+ | DROP FUNCTION GetAllPoolsForNet; |
||
+ | delimiter // |
||
+ | CREATE FUNCTION GetAllPoolsForNet(n1 int UNSIGNED) RETURNS MEDIUMTEXT |
||
+ | BEGIN |
||
+ | DECLARE done INT DEFAULT 0; |
||
+ | DECLARE mask1 int UNSIGNED; |
||
+ | DECLARE mac_dhcp1 VARCHAR(255); |
||
+ | DECLARE current_ip int UNSIGNED DEFAULT 0; |
||
+ | DECLARE pools MEDIUMTEXT DEFAULT " "; |
||
+ | DECLARE cursor_ip CURSOR FOR SELECT INET_ATOn(ip_dhcp),mac_dhcp from mtraf_status WHERE INET_ATON(mtraf_status.ip_dhcp)&mask1=n1; |
||
+ | DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1; |
||
+ | SELECT mask from network_mask WHERE network=n1 INTO mask1; |
||
+ | OPEN cursor_ip; |
||
+ | FETCH cursor_ip INTO current_ip,mac_dhcp1; |
||
+ | WHILE done = 0 DO |
||
+ | SELECT CONCAT( |
||
+ | "pool { range ", |
||
+ | INET_NTOA(current_ip), |
||
+ | "; allow members of \"", |
||
+ | INET_NTOA(current_ip), |
||
+ | "__", |
||
+ | mac_dhcp1, |
||
+ | "\"; default-lease-time 36000; max-lease-time 72000; } " |
||
+ | ," \n",pools) INTO pools; |
||
+ | FETCH cursor_ip INTO current_ip,mac_dhcp1; |
||
+ | END WHILE; |
||
+ | CLOSE cursor_ip; |
||
+ | RETURN pools; |
||
+ | END |
||
+ | // |
||
+ | delimiter ; |
||
</PRE> |
</PRE> |
Версия 10:03, 20 апреля 2011
Анализ логов нагиоса
Загрузить логи в Mysql
Это Просто пример
DROP FUNCTION GetAllPoolsForNet; delimiter // CREATE FUNCTION GetAllPoolsForNet(n1 int UNSIGNED) RETURNS MEDIUMTEXT BEGIN DECLARE done INT DEFAULT 0; DECLARE mask1 int UNSIGNED; DECLARE mac_dhcp1 VARCHAR(255); DECLARE current_ip int UNSIGNED DEFAULT 0; DECLARE pools MEDIUMTEXT DEFAULT " "; DECLARE cursor_ip CURSOR FOR SELECT INET_ATOn(ip_dhcp),mac_dhcp from mtraf_status WHERE INET_ATON(mtraf_status.ip_dhcp)&mask1=n1; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1; SELECT mask from network_mask WHERE network=n1 INTO mask1; OPEN cursor_ip; FETCH cursor_ip INTO current_ip,mac_dhcp1; WHILE done = 0 DO SELECT CONCAT( "pool { range ", INET_NTOA(current_ip), "; allow members of \"", INET_NTOA(current_ip), "__", mac_dhcp1, "\"; default-lease-time 36000; max-lease-time 72000; } " ," \n",pools) INTO pools; FETCH cursor_ip INTO current_ip,mac_dhcp1; END WHILE; CLOSE cursor_ip; RETURN pools; END // delimiter ;