Exemple #1
0
 /** Load configuration properties to initialize attributes. */
 private static void loadConfigProperties() {
   try {
     SMTPServer = PropertiesUtils.getValue("mail.SMTPServer");
     SMTPUsername = PropertiesUtils.getValue("mail.SMTPUsername");
     SMTPPassword = PropertiesUtils.getValue("mail.SMTPPassword");
     POP3Server = PropertiesUtils.getValue("mail.POP3Server");
     POP3Username = PropertiesUtils.getValue("mail.POP3Username");
     POP3Password = PropertiesUtils.getValue("mail.POP3Password");
   } catch (Exception e) {
     LOGGER.error("File not found at ", e);
   }
 }
Exemple #2
0
  public static void main(String[] args) throws Exception {
    // 发送邮件
    StringBuilder sb = new StringBuilder();
    sb.append(
        "Caused by: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /supervisors");
    sb.append(
        "at org.apache.zookeeper.KeeperException.create(KeeperException.java:99) ~[zookeeper-3.4.5.jar:3.4.5-1392090]");
    sb.append(
        "at org.apache.zookeeper.KeeperException.create(KeeperException.java:51) ~[zookeeper-3.4.5.jar:3.4.5-1392090]");
    sb.append(
        "at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1041) ~[zookeeper-3.4.5.jar:3.4.5-1392090]");
    sb.append(
        "at org.apache.curator.framework.imps.ExistsBuilderImpl$2.call(ExistsBuilderImpl.java:172) ~[curator-framework-2.4.0.jar:na]");
    sb.append(
        "at org.apache.curator.framework.imps.ExistsBuilderImpl$2.call(ExistsBuilderImpl.java:161) ~[curator-framework-2.4.0.jar:na]");
    sb.append(
        "at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107) ~[curator-client-2.4.0.jar:na]");
    sb.append(
        "at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForeground(ExistsBuilderImpl.java:157) ~[curator-framework-2.4.0.jar:na]");
    sb.append(
        "at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:148) ~[curator-framework-2.4.0.jar:na]");
    sb.append(
        "at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:36) ~[curator-framework-2.4.0.jar:na]");
    sb.append(
        "at backtype.storm.zookeeper$exists_node_QMARK_$fn__1153.invoke(zookeeper.clj:101) ~[storm-core-0.9.2-incubating.jar:0.9.2-incubating]");
    sb.append("... 15 common frames omitted");
    StringBuilder sbContext = new StringBuilder();
    sbContext.append(
        "2014-10-28 21:53:13 o.a.z.ClientCnxn [INFO] Opening socket connection to server vm132/192.168.128.132:2181. Will not attempt to authenticate using SASL (unknown error)");
    sbContext.append(
        "2014-10-28 21:53:13 o.a.z.ClientCnxn [INFO] Socket connection established to vm132/192.168.128.132:2181, initiating session");
    sbContext.append(
        "2014-10-28 21:53:13 o.a.z.ClientCnxn [INFO] Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect");
    sbContext.append(
        "2014-10-28 21:53:13 b.s.util [INFO] Halting process: (\"Error when processing an event\")");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:host.name=vm132");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:java.version=1.7.0_60");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:java.vendor=Oracle Corporation");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:java.home=/usr/java/jdk1.7.0_60/jre");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:java.class.path=/usr/local/storm-0.9.2/lib/kryo-2.21.jar:/usr/local/storm-0.9.2/lib/core.incubator-0.1.0.jar:/usr/local/storm-0.9.2/lib/commons-io-2.4.jar:/usr/local/storm-0.9.2/lib/jgrapht-core-0.9.0.jar:/usr/local/storm-0.9.2/lib/netty-3.6.3.Final.jar:/usr/local/storm-0.9.2/lib/jetty-6.1.26.jar:/usr/local/storm-0.9.2/lib/netty-3.2.2.Final.jar:/usr/local/storm-0.9.2/lib/minlog-1.2.jar:/usr/local/storm-0.9.2/lib/kafka_2.9.2-0.8.0-beta1.jar:/usr/local/storm-0.9.2/lib/chill-java-0.3.5.jar:/usr/local/storm-0.9.2/lib/disruptor-2.10.1.jar:/usr/local/storm-0.9.2/lib/curator-client-2.4.0.jar:/usr/local/storm-0.9.2/lib/guava-13.0.jar:/usr/local/storm-0.9.2/lib/zookeeper-3.4.5.jar:/usr/local/storm-0.9.2/lib/commons-lang-2.5.jar:/usr/local/storm-0.9.2/lib/storm-core-0.9.2-incubating.jar:/usr/local/storm-0.9.2/lib/servlet-api-2.5.jar:/usr/local/storm-0.9.2/lib/commons-fileupload-1.2.1.jar:/usr/local/storm-0.9.2/lib/carbonite-1.4.0.jar:/usr/local/storm-0.9.2/lib/logback-core-1.0.6.jar:/usr/local/storm-0.9.2/lib/metrics-core-2.2.0.jar:/usr/local/storm-0.9.2/lib/reflectasm-1.07-shaded.jar:/usr/local/storm-0.9.2/lib/clj-time-0.4.1.jar:/usr/local/storm-0.9.2/lib/logback-classic-1.0.6.jar:/usr/local/storm-0.9.2/lib/objenesis-1.2.jar:/usr/local/storm-0.9.2/lib/hiccup-0.3.6.jar:/usr/local/storm-0.9.2/lib/ring-jetty-adapter-0.3.11.jar:/usr/local/storm-0.9.2/lib/tools.cli-0.2.4.jar:/usr/local/storm-0.9.2/lib/asm-4.0.jar:/usr/local/storm-0.9.2/lib/joda-time-2.0.jar:/usr/local/storm-0.9.2/lib/snakeyaml-1.11.jar:/usr/local/storm-0.9.2/lib/slf4j-api-1.6.5.jar:/usr/local/storm-0.9.2/lib/clj-stacktrace-0.2.4.jar:/usr/local/storm-0.9.2/lib/mysql-connector-java-5.1.26.jar:/usr/local/storm-0.9.2/lib/compojure-1.1.3.jar:/usr/local/storm-0.9.2/lib/clojure-1.5.1.jar:/usr/local/storm-0.9.2/lib/ring-devel-0.3.11.jar:/usr/local/storm-0.9.2/lib/commons-codec-1.6.jar:/usr/local/storm-0.9.2/lib/commons-logging-1.1.3.jar:/usr/local/storm-0.9.2/lib/httpclient-4.3.3.jar:/usr/local/storm-0.9.2/lib/log4j-over-slf4j-1.6.6.jar:/usr/local/storm-0.9.2/lib/math.numeric-tower-0.0.1.jar:/usr/local/storm-0.9.2/lib/tools.macro-0.1.0.jar:/usr/local/storm-0.9.2/lib/tools.logging-0.2.3.jar:/usr/local/storm-0.9.2/lib/jline-2.11.jar:/usr/local/storm-0.9.2/lib/json-simple-1.1.jar:/usr/local/storm-0.9.2/lib/jetty-util-6.1.26.jar:/usr/local/storm-0.9.2/lib/servlet-api-2.5-20081211.jar:/usr/local/storm-0.9.2/lib/httpcore-4.3.2.jar:/usr/local/storm-0.9.2/lib/curator-framework-2.4.0.jar:/usr/local/storm-0.9.2/lib/zkclient-0.3.jar:/usr/local/storm-0.9.2/lib/scala-library-2.9.2.jar:/usr/local/storm-0.9.2/lib/ring-servlet-0.3.11.jar:/usr/local/storm-0.9.2/lib/ring-core-1.1.5.jar:/usr/local/storm-0.9.2/lib/commons-exec-1.1.jar:/usr/local/storm-0.9.2/lib/clout-1.0.1.jar:/usr/local/storm-0.9.2/conf");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:java.library.path=/usr/local/lib:/opt/local/lib:/usr/lib");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:java.io.tmpdir=/tmp");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:java.compiler=<NA>");
    sbContext.append("2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:os.name=Linux");
    sbContext.append("2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:os.arch=amd64");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:os.version=2.6.32-431.el6.x86_64");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:user.name=root");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:user.home=/root");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.ZooKeeper [INFO] Client environment:user.dir=/usr/local/storm-0.9.2/bin");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:host.name=vm132");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:java.version=1.7.0_60");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:java.vendor=Oracle Corporation");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:java.home=/usr/java/jdk1.7.0_60/jre");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:java.class.path=/usr/local/storm-0.9.2/lib/kryo-2.21.jar:/usr/local/storm-0.9.2/lib/core.incubator-0.1.0.jar:/usr/local/storm-0.9.2/lib/commons-io-2.4.jar:/usr/local/storm-0.9.2/lib/jgrapht-core-0.9.0.jar:/usr/local/storm-0.9.2/lib/netty-3.6.3.Final.jar:/usr/local/storm-0.9.2/lib/jetty-6.1.26.jar:/usr/local/storm-0.9.2/lib/netty-3.2.2.Final.jar:/usr/local/storm-0.9.2/lib/minlog-1.2.jar:/usr/local/storm-0.9.2/lib/kafka_2.9.2-0.8.0-beta1.jar:/usr/local/storm-0.9.2/lib/chill-java-0.3.5.jar:/usr/local/storm-0.9.2/lib/disruptor-2.10.1.jar:/usr/local/storm-0.9.2/lib/curator-client-2.4.0.jar:/usr/local/storm-0.9.2/lib/guava-13.0.jar:/usr/local/storm-0.9.2/lib/zookeeper-3.4.5.jar:/usr/local/storm-0.9.2/lib/commons-lang-2.5.jar:/usr/local/storm-0.9.2/lib/storm-core-0.9.2-incubating.jar:/usr/local/storm-0.9.2/lib/servlet-api-2.5.jar:/usr/local/storm-0.9.2/lib/commons-fileupload-1.2.1.jar:/usr/local/storm-0.9.2/lib/carbonite-1.4.0.jar:/usr/local/storm-0.9.2/lib/logback-core-1.0.6.jar:/usr/local/storm-0.9.2/lib/metrics-core-2.2.0.jar:/usr/local/storm-0.9.2/lib/reflectasm-1.07-shaded.jar:/usr/local/storm-0.9.2/lib/clj-time-0.4.1.jar:/usr/local/storm-0.9.2/lib/logback-classic-1.0.6.jar:/usr/local/storm-0.9.2/lib/objenesis-1.2.jar:/usr/local/storm-0.9.2/lib/hiccup-0.3.6.jar:/usr/local/storm-0.9.2/lib/ring-jetty-adapter-0.3.11.jar:/usr/local/storm-0.9.2/lib/tools.cli-0.2.4.jar:/usr/local/storm-0.9.2/lib/asm-4.0.jar:/usr/local/storm-0.9.2/lib/joda-time-2.0.jar:/usr/local/storm-0.9.2/lib/snakeyaml-1.11.jar:/usr/local/storm-0.9.2/lib/slf4j-api-1.6.5.jar:/usr/local/storm-0.9.2/lib/clj-stacktrace-0.2.4.jar:/usr/local/storm-0.9.2/lib/mysql-connector-java-5.1.26.jar:/usr/local/storm-0.9.2/lib/compojure-1.1.3.jar:/usr/local/storm-0.9.2/lib/clojure-1.5.1.jar:/usr/local/storm-0.9.2/lib/ring-devel-0.3.11.jar:/usr/local/storm-0.9.2/lib/commons-codec-1.6.jar:/usr/local/storm-0.9.2/lib/commons-logging-1.1.3.jar:/usr/local/storm-0.9.2/lib/httpclient-4.3.3.jar:/usr/local/storm-0.9.2/lib/log4j-over-slf4j-1.6.6.jar:/usr/local/storm-0.9.2/lib/math.numeric-tower-0.0.1.jar:/usr/local/storm-0.9.2/lib/tools.macro-0.1.0.jar:/usr/local/storm-0.9.2/lib/tools.logging-0.2.3.jar:/usr/local/storm-0.9.2/lib/jline-2.11.jar:/usr/local/storm-0.9.2/lib/json-simple-1.1.jar:/usr/local/storm-0.9.2/lib/jetty-util-6.1.26.jar:/usr/local/storm-0.9.2/lib/servlet-api-2.5-20081211.jar:/usr/local/storm-0.9.2/lib/httpcore-4.3.2.jar:/usr/local/storm-0.9.2/lib/curator-framework-2.4.0.jar:/usr/local/storm-0.9.2/lib/zkclient-0.3.jar:/usr/local/storm-0.9.2/lib/scala-library-2.9.2.jar:/usr/local/storm-0.9.2/lib/ring-servlet-0.3.11.jar:/usr/local/storm-0.9.2/lib/ring-core-1.1.5.jar:/usr/local/storm-0.9.2/lib/commons-exec-1.1.jar:/usr/local/storm-0.9.2/lib/clout-1.0.1.jar:/usr/local/storm-0.9.2/conf");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:java.library.path=/usr/local/lib:/opt/local/lib:/usr/lib");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:java.io.tmpdir=/tmp");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:java.compiler=<NA>");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:os.name=Linux");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:os.arch=amd64");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:os.version=2.6.32-431.el6.x86_64");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:user.name=root");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:user.home=/root");
    sbContext.append(
        "2014-10-28 22:42:59 o.a.z.s.ZooKeeperServer [INFO] Server environment:user.dir=/usr/local/storm-0.9.2/bin");
    sbContext.append("2014-10-28 22:43:00 o.a.c.f.i.CuratorFrameworkImpl [INFO] Starting");
    sbContext.append(
        "2014-10-28 22:43:00 o.a.z.ZooKeeper [INFO] Initiating client connection, connectString=192.168.128.131:2181,192.168.128.132:2181 sessionTimeout=20000 watcher=org.apache.curator.ConnectionState@53abd462");
    sbContext.append(
        "2014-10-28 22:43:00 o.a.z.ClientCnxn [INFO] Opening socket connection to server vm132/192.168.128.132:2181. Will not attempt to authenticate using SASL (unknown error)");
    sbContext.append(
        "2014-10-28 22:43:00 o.a.z.ClientCnxn [INFO] Socket connection established to vm132/192.168.128.132:2181, initiating session");
    sbContext.append(
        "2014-10-28 22:43:00 o.a.z.ClientCnxn [INFO] Session establishment complete on server vm132/192.168.128.132:2181, sessionid = 0x2495a6a51e20023, negotiated timeout = 20000");
    sbContext.append(
        "2014-10-28 22:43:00 o.a.c.f.s.ConnectionStateManager [INFO] State change: CONNECTED");
    sbContext.append(
        "2014-10-28 22:43:00 o.a.c.f.s.ConnectionStateManager [WARN] There are no ConnectionStateListeners registered.");
    sbContext.append(
        "2014-10-28 22:43:00 b.s.zookeeper [INFO] Zookeeper state update: :connected:none");
    sbContext.append("2014-10-28 22:43:01 o.a.z.ClientCnxn [INFO] EventThread shut down");
    sbContext.append(
        "2014-10-28 22:43:01 o.a.z.ZooKeeper [INFO] Session: 0x2495a6a51e20023 closed");
    sbContext.append("2014-10-28 22:43:01 o.a.c.f.i.CuratorFrameworkImpl [INFO] Starting");
    sbContext.append(
        "2014-10-28 22:43:01 o.a.z.ZooKeeper [INFO] Initiating client connection, connectString=192.168.128.131:2181,192.168.128.132:2181/storm sessionTimeout=20000 watcher=org.apache.curator.ConnectionState@64074bf8");
    sbContext.append(
        "2014-10-28 22:43:01 o.a.z.ClientCnxn [INFO] Opening socket connection to server vm132/192.168.128.132:2181. Will not attempt to authenticate using SASL (unknown error)");
    sbContext.append(
        "2014-10-28 22:43:01 o.a.z.ClientCnxn [INFO] Socket connection established to vm132/192.168.128.132:2181, initiating session");
    sbContext.append(
        "2014-10-28 22:43:01 o.a.z.ClientCnxn [INFO] Session establishment complete on server vm132/192.168.128.132:2181, sessionid = 0x2495a6a51e20024, negotiated timeout = 20000");
    sbContext.append(
        "2014-10-28 22:43:01 o.a.c.f.s.ConnectionStateManager [INFO] State change: CONNECTED");
    // MysqlUtils.insert("insert into
    // fks_alarminfo(description,context)values('"+sb.toString()+"','"+sbContext.toString()+"')");
    String mailContent =
        StrUtils.format(
            PropertiesUtils.getValue("log.alarm.content1"),
            "PROJECT NAME",
            "APP NAME",
            "ERROR",
            new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss Z", Locale.ENGLISH).format(new Date()),
            "MainLand-1",
            "192.168.128.131",
            sb.toString(),
            sbContext.toString());
    MailMessage mail =
        new MailMessage(
            StrUtils.format(PropertiesUtils.getValue("log.alarm.title1"), "ERROR", "EN"),
            "*****@*****.**",
            new String[] {"*****@*****.**", "*****@*****.**"},
            new String[] {"*****@*****.**"},
            new String[] {"*****@*****.**"},
            mailContent,
            new String[] {});
    // set attachments
    /*   String[] attachments = new String[]{
    "C:\\AndroidManifest.xml",
    "C:\\ic_launcher-web.png"};*/
    // mail.setFileNames(attachments);
    sendEmail(mail);

    // 接收邮件
    // receiveEmail(POP3Server, POP3Username, POP3Password);

    // 发送匿名邮件
    // MailMessage anonymousMail = new MailMessage("subject",
    //  "[email protected]", "*****@*****.**", "content");
    // anonymousMail.setFileNames(attachments);
    // sendAnonymousEmail(anonymousMail);
  }