Имеется следующий скрипт по управлению шлюзом DLINK
который ничего не делает а только логинится на свитч и вылогинивается.
Код:
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import bitel.billing.common.IPUtils;
import bitel.billing.common.module.ipn.IPNContractStatus;
import bitel.billing.server.ipn.UserStatus;
import bitel.billing.server.ipn.bean.ManadUtils;
import bitel.billing.server.ipn.bean.VlanManager;
import bitel.billing.server.ipn.dlink.UserPortStatus;
import bitel.billing.server.util.DefaultServerSetup;
import bitel.billing.server.util.Utils;
import bitel.billing.server.util.telnet.OperationTimedoutException;
import bitel.billing.server.util.telnet.TelnetSession;
protected void doSync(){
log.info( "script started" );
try
{
log.info( "script started 1" );
host = gate.getHost();
port = gate.getPort();
DefaultServerSetup gateSetup = new DefaultServerSetup( gate.getConfig(), "\r\n" );
pswd = gate.getKeyword();
login = gateSetup.getStringValue( "login");
result = new StringBuffer();
log.info( gate.getId() + " gate: " + host + ":" + port + " login: " + login + " pswd: " + pswd );
TelnetSession session = new TelnetSession( host, port);
session.setLoginPromptSequence( "name:" );
log.info( "before connect" );
session.connect();
log.info( "after connect" );
session.setLoginPromptSequence( "word:" );
result.append( session.doCommand( login ) );
log.info( "after command" );
session.setLoginPromptSequence( "#" );
result.append( session.doCommand( pswd ) );
//TODO commands here
session.setLoginPromptSequence( "****" );
result.append( session.doCommand( "logout" ) );
log.info( result.toString() );
Thread.sleep( 100 );
log.info( "ok" );
} catch (Exception e)
{
log.info("error detected", e );
//throw new RuntimeException ( e );
} finally
{
log.info( "end of Dlink_SWITCH........................................................");
if(( session != null ) && ( session != void ))
{
session.disconnect();
}
}
};
примерно в 30% случаев изменения состояния шлюза из договор->модули->выделенные каналы -> шлюзы он зависает на логине к свитчу причем при этом виснет и клиентский интерфейс
содержимое логов сервера файл server.log
Код:
INFO 02.05.2009 15:49:49 Running script
INFO 02.05.2009 15:49:49 script started
INFO 02.05.2009 15:49:49 script started 1
INFO 02.05.2009 15:49:50 6 gate: 10.7.253.12:23 login: admin pswd: preved
INFO 02.05.2009 15:49:50 before connect
траффик между свитчем и биллингом
Код:
15:52:23.815097 IP 62.140.242.100.50840 > 10.7.253.12.23: S 112173738:112173738(0) win 5840 <mss 1460,sackOK,timestamp 14119778 0,nop,wscale 6>
0x0000: 4500 003c d1c8 4000 4006 30ef 3e8c f264 E..<..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2aa 0000 0000 ................
0x0020: a002 16d0 14ea 0000 0204 05b4 0402 080a ................
0x0030: 00d7 7362 0000 0000 0103 0306 ..sb........
15:52:23.816961 IP 10.7.253.12.23 > 62.140.242.100.50840: S 1019828298:1019828298(0) ack 112173739 win 8192 <mss 1444,nop,wscale 0,nop,nop,timestamp 196689 14119778>
0x0000: 4500 003c 4c54 0000 1d06 1964 0a07 fd0c E..<LT.....d....
0x0010: 3e8c f264 0017 c698 3cc9 584a 06af a2ab >..d....<.XJ....
0x0020: a012 2000 7958 0000 0204 05a4 0103 0300 ....yX..........
0x0030: 0101 080a 0003 0051 00d7 7362 .......Q..sb
15:52:23.816983 IP 62.140.242.100.50840 > 10.7.253.12.23: . ack 1 win 92 <nop,nop,timestamp 14119778 196689>
0x0000: 4500 0034 d1c9 4000 4006 30f6 3e8c f264 E..4..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2ab 3cc9 584b ............<.XK
0x0020: 8010 005c c4b0 0000 0101 080a 00d7 7362 ...\..........sb
0x0030: 0003 0051 ...Q
15:52:23.851993 IP 10.7.253.12.23 > 62.140.242.100.50840: P 1:4(3) ack 1 win 8192 <nop,nop,timestamp 196689 14119778>
0x0000: 4500 0037 4c56 0000 1d06 1967 0a07 fd0c E..7LV.....g....
0x0010: 3e8c f264 0017 c698 3cc9 584b 06af a2ab >..d....<.XK....
0x0020: 8018 2000 a203 0000 0101 080a 0003 0051 ...............Q
0x0030: 00d7 7362 fffd 03 ..sb...
15:52:23.852011 IP 62.140.242.100.50840 > 10.7.253.12.23: . ack 4 win 92 <nop,nop,timestamp 14119787 196689>
0x0000: 4500 0034 d1ca 4000 4006 30f5 3e8c f264 E..4..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2ab 3cc9 584e ............<.XN
0x0020: 8010 005c c4a4 0000 0101 080a 00d7 736b ...\..........sk
0x0030: 0003 0051 ...Q
15:52:23.852931 IP 10.7.253.12.23 > 62.140.242.100.50840: . 4:93(89) ack 1 win 8192 <nop,nop,timestamp 196689 14119778>
0x0000: 4500 008d 4c58 0000 1d06 190f 0a07 fd0c E...LX..........
0x0010: 3e8c f264 0017 c698 3cc9 584e 06af a2ab >..d....<.XN....
0x0020: 8010 2000 b814 0000 0101 080a 0003 0051 ...............Q
0x0030: 00d7 7362 fffb 03ff fb01 1b5b 306d 1b5b ..sb.......[0m.[
0x0040: 313b 3148 1b5b 324a 0d44 0d20 2020 2020 1;1H.[2J.D......
0x0050: 2020 2020 2020 0d0a 0d20 2020 2020 2020 ................
0x0060: 2020 2020 2020 2044 4553 2d33 3532 3620 .......DES-3526.
0x0070: 4661 7374 2045 7468 6572 6e65 7420 5377 Fast.Ethernet.Sw
0x0080: 6974 6368 2043 6f6d 6d61 6e64 20 itch.Command.
15:52:23.852938 IP 62.140.242.100.50840 > 10.7.253.12.23: . ack 93 win 92 <nop,nop,timestamp 14119787 196689>
0x0000: 4500 0034 d1cb 4000 4006 30f4 3e8c f264 E..4..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2ab 3cc9 58a7 ............<.X.
0x0020: 8010 005c c44b 0000 0101 080a 00d7 736b ...\.K........sk
0x0030: 0003 0051 ...Q
15:52:23.856145 IP 10.7.253.12.23 > 62.140.242.100.50840: P 93:250(157) ack 1 win 8192 <nop,nop,timestamp 196689 14119787>
0x0000: 4500 00d1 4c5a 0000 1d06 18c9 0a07 fd0c E...LZ..........
0x0010: 3e8c f264 0017 c698 3cc9 58a7 06af a2ab >..d....<.X.....
0x0020: 8018 2000 ed1e 0000 0101 080a 0003 0051 ...............Q
0x0030: 00d7 736b 4c69 6e65 2049 6e74 6572 6661 ..skLine.Interfa
0x0040: 6365 0d0a 0d0d 0a0d 2020 2020 2020 2020 ce..............
0x0050: 2020 2020 2020 2020 2020 2020 2020 2020 ................
0x0060: 2020 2020 4669 726d 7761 7265 3a20 4275 ....Firmware:.Bu
0x0070: 696c 6420 352e 3031 2e42 3532 0d0a 0d20 ild.5.01.B52....
0x0080: 2020 2020 2020 2020 2020 2043 6f70 7972 ...........Copyr
0x0090: 6967 6874 2843 2920 3230 3038 2044 2d4c ight(C).2008.D-L
0x00a0: 696e 6b20 436f 7270 6f72 6174 696f 6e2e ink.Corporation.
0x00b0: 2041 6c6c 2072 6967 6874 7320 7265 7365 .All.rights.rese
0x00c0: 7276 6564 2e0d 0a0d 7573 6572 6e61 6d65 rved....username
0x00d0: 3a :
15:52:23.856152 IP 62.140.242.100.50840 > 10.7.253.12.23: . ack 250 win 108 <nop,nop,timestamp 14119788 196689>
0x0000: 4500 0034 d1cc 4000 4006 30f3 3e8c f264 E..4..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2ab 3cc9 5944 ............<.YD
0x0020: 8010 006c c39d 0000 0101 080a 00d7 736c ...l..........sl
0x0030: 0003 0051 ...Q
15:52:23.917301 IP 62.140.242.100.50840 > 10.7.253.12.23: P 1:2(1) ack 250 win 108 <nop,nop,timestamp 14119803 196689>
0x0000: 4500 0035 d1cd 4000 4006 30f1 3e8c f264 E..5..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2ab 3cc9 5944 ............<.YD
0x0020: 8018 006c 382c 0000 0101 080a 00d7 737b ...l8,........s{
0x0030: 0003 0051 ff ...Q.
15:52:24.030867 IP 10.7.253.12.23 > 62.140.242.100.50840: . ack 2 win 8192 <nop,nop,timestamp 196689 14119803>
0x0000: 4500 0034 4c5c 0000 1d06 1964 0a07 fd0c E..4L\.....d....
0x0010: 3e8c f264 0017 c698 3cc9 5944 06af a2ac >..d....<.YD....
0x0020: 8010 2000 a3f9 0000 0101 080a 0003 0051 ...............Q
0x0030: 00d7 737b ..s{
15:52:24.030890 IP 62.140.242.100.50840 > 10.7.253.12.23: P 2:10(8) ack 250 win 108 <nop,nop,timestamp 14119832 196689>
0x0000: 4500 003c d1ce 4000 4006 30e9 3e8c f264 E..<..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2ac 3cc9 5944 ............<.YD
0x0020: 8018 006c 3833 0000 0101 080a 00d7 7398 ...l83........s.
0x0030: 0003 0051 fc03 fffe 03ff fe01 ...Q........
15:52:24.034617 IP 10.7.253.12.23 > 62.140.242.100.50840: P 250:253(3) ack 10 win 8192 <nop,nop,timestamp 196689 14119832>
0x0000: 4500 0037 4c5e 0000 1d06 195f 0a07 fd0c E..7L^....._....
0x0010: 3e8c f264 0017 c698 3cc9 5944 06af a2b4 >..d....<.YD....
0x0020: 8018 2000 a0ca 0000 0101 080a 0003 0051 ...............Q
0x0030: 00d7 7398 fffe 03 ..s....
15:52:24.074227 IP 62.140.242.100.50840 > 10.7.253.12.23: . ack 253 win 108 <nop,nop,timestamp 14119843 196689>
0x0000: 4500 0034 d1cf 4000 4006 30f0 3e8c f264 E..4..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2b4 3cc9 5947 ............<.YG
0x0020: 8010 006c c35a 0000 0101 080a 00d7 73a3 ...l.Z........s.
0x0030: 0003 0051 ...Q
15:52:24.075881 IP 10.7.253.12.23 > 62.140.242.100.50840: P 253:259(6) ack 10 win 8192 <nop,nop,timestamp 196689 14119843>
0x0000: 4500 003a 4c60 0000 1d06 195a 0a07 fd0c E..:L`.....Z....
0x0010: 3e8c f264 0017 c698 3cc9 5947 06af a2b4 >..d....<.YG....
0x0020: 8018 2000 a3ba 0000 0101 080a 0003 0051 ...............Q
0x0030: 00d7 73a3 fffc 03ff fc01 ..s.......
15:52:24.114225 IP 62.140.242.100.50840 > 10.7.253.12.23: . ack 259 win 108 <nop,nop,timestamp 14119853 196689>
0x0000: 4500 0034 d1d0 4000 4006 30ef 3e8c f264 E..4..@.@.0.>..d
0x0010: 0a07 fd0c c698 0017 06af a2b4 3cc9 594d ............<.YM
0x0020: 8010 006c c34a 0000 0101 080a 00d7 73ad ...l.J........s.
0x0030: 0003 0051 ...Q
предполагаю что почему-то иногда биллинг не распознает приглашение свитча к вводу логина "username:".
Приглашение ввода логина при подключении к свитчу телнетом.
Код:
DES-3526 Fast Ethernet Switch Command Line Interface
Firmware: Build 5.01.B52
Copyright(C) 2008 D-Link Corporation. All rights reserved.
username:
версия биллинга 4.5 сборка 415