1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| package marouene;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DecimalFormat;
import java.util.Timer;
import java.util.Vector;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.TimerTask;
import java.text.*;
import java.util.Locale;
public class TestPerformance {
static int i = 0;
static Timer timer;
static Connection con;
static double perte;
public static void main(String[] args) {
class RemindTask extends TimerTask {
public void run() {
//TestFtp ftp = new TestFtp();
//HttpClient http = new HttpClient();
Ping avg = new Ping();
Dns dns = new Dns();
Vector t=dns.tableau();
try {
double perte=dns.taux(t.size());
} catch (IllegalStateException e1) {
} catch (IOException e1) {
}
tableau tab = new tableau();
try {
Class.forName("com.mysql.jdbc.Driver");
try {
con DriverManager.getConnection("jdbc:mysql://localhost:3306newdata","root","root");
} catch (SQLException e) {
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
//capture cc = new capture();
try {
Statement stm=con.createStatement();
// int res1=stm.executeUpdate("insert into httptable(date,heure,http) values (now(),now(),"+http.debithttp("http://41.228.192.9/30M")+")");
//int res2=stm.executeUpdate("insert into ftptable(date,heure,ftp) values (now(),now(),"+ftp.calculdebitftp("otn","otnotn","41.228.192.9","/30M")+")");
int res4=stm.executeUpdate("insert into dnstable(date,heure,min,moy,max,perte) values (now(),now(),"+tab.minimum(t)+","+tab.moyenne(t)+","+tab.maximum(t)+","+perte+")");
try {
int res3=stm.executeUpdate("insert into pingtable(date,heure,avg) values (now(),now(),"+avg.time()+")");
} catch (IllegalStateException e) {
} catch (IOException e) {
}
//cc.start();
} catch (SQLException e) {
}
}
}
timer = new Timer();
timer.scheduleAtFixedRate(new RemindTask(), 0, 900 * 1000);
}
} |
Partager