<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    afunms

    My Software,My Dream—Forge a more perfect NMS product.

    tomcat監視

    ??????? 今天要做一個tomcat監視,參考了ens和華中電力的相關代碼,發現他們的做法都是先取到html代碼,然后從這html代碼中提取自己想要的數據,這太麻煩了,我在想有沒有更好的辦法。
    ??????? 研究了tomcat的源碼后,終于有了發現。我要的數據可以通過以下代碼得到:
    ???????--------server information------------------?
    ?????? 服務器信息:ServerInfo.getServerInfo()
    ??????? jvm版本:System.getProperty("java.runtime.version")
    ??????? jvm vendor:System.getProperty("java.vm.vendor")
    ??????? 操作系統:System.getProperty("os.name")
    ??????? 操作系統版本:System.getProperty("os.version")

    ???????--------jvm information------------------
    ?????? free_memory:Runtime.getRuntime().freeMemory()
    ?????? total_memory:Runtime.getRuntime().totalMemory()
    ?????? max_memory:Runtime.getRuntime().maxMemory()

    ?????? ---------應用列表-------------------
    ????? private Element createApplications()
    ?{
    ??Element applications = null;
    ??try
    ??{
    ???applications = new Element("applications");
    ???
    ???MBeanServer mBeanServer = Registry.getServer();
    ???????? ObjectName queryHosts = new ObjectName("*:j2eeType=WebModule,*");
    ???????? Set hostsON = mBeanServer.queryNames(queryHosts, null);

    ???Iterator iterator = hostsON.iterator();
    ???while(iterator.hasNext())
    ???{
    ????ObjectName contextON = (ObjectName)iterator.next();
    ????????? String webModuleName = contextON.getKeyProperty("name");???????? ????????????
    ????String hostName = null;
    ????????? String contextName = null;
    ????????? if(webModuleName.startsWith("http://"))
    ?????????????? webModuleName = webModuleName.substring(2);
    ?????????
    ????????? int slash = webModuleName.indexOf("/");
    ????????? if(slash != -1)
    ????????? {
    ????????????? hostName = webModuleName.substring(0, slash);
    ????????????? contextName = webModuleName.substring(slash);
    ????????? }
    ????else continue;
    ?
    ????????? if("/".equals(contextName)) continue;
    ?????????
    ????????? Element oneApp = new Element("application_information");
    ????????? try
    ????????? {???????
    ????????????? ObjectName queryManager = new ObjectName(contextON.getDomain() + ":type=Manager,path=" + contextName + ",host=" + hostName + ",*");
    ????????????? Set managersON = mBeanServer.queryNames(queryManager, null);
    ????????????? ObjectName managerON = null;
    ????????????? for(Iterator iterator2 = managersON.iterator(); iterator2.hasNext();)
    ???????????????? managerON = (ObjectName)iterator2.next();
    ?
    ????????????? Element wmn = new Element("web_module_name");
    ????????????? wmn.setText(contextName.substring(1));
    ?????????
    ????????????? Element as = new Element("active_sessions");
    ?????????? as.setText(mBeanServer.getAttribute(managerON, "activeSessions").toString());
    ?????????
    ?????????? Element sc = new Element("session_count");
    ?????????? sc.setText(mBeanServer.getAttribute(managerON, "sessionCounter").toString());
    ?????????
    ?????????? Element mas = new Element("max_active_sessions");
    ?????????? mas.setText(mBeanServer.getAttribute(managerON, "maxActive").toString());?
    ?????????? oneApp.addContent(wmn);
    ?????????? oneApp.addContent(as);
    ?????????? oneApp.addContent(sc);
    ?????????? oneApp.addContent(mas);
    ?????????? applications.addContent(oneApp);
    ????????? }
    ????????? catch(Exception e)
    ????????? {
    ????????? ?System.out.println("Error in TomcatMonitor.createApplications()-2");
    ????????? }//end_try
    ???}//end_while
    ??}
    ??????? catch(Exception e)
    ??????? {
    ??????? ?System.out.println("Error in TomcatMonitor.createApplications()-1");
    ??????? }//end_try
    ??????? return applications;
    ?}

    posted on 2006-12-04 11:18 afunms 閱讀(394) 評論(3)  編輯  收藏

    Feedback

    # re: tomcat監視 2008-04-21 15:29 chenhao

    沒想到我要解決的問題,你兩年前都已經研究的這么透徹了,慚愧啊。還有,原來你一直這么有目標阿,終于知道afunms大概的意思了。剛才在google上搜相關資料,看到afunms就是一驚,難道真的那么巧,進來一看,果然是你,在那邊生活的還好嗎?  回復  更多評論   

    # re: tomcat監視 2008-04-21 15:37 afu

    @chenhao
    呵呵,能告訴我你是哪位嗎?
      回復  更多評論   

    # re: tomcat監視 2008-04-21 15:48 chenhao

    nch的classmate,cqep的參與者,@dhcc  回復  更多評論   



    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    My Links

    News

    留言簿(18)

    隨筆檔案

    相冊

    搜索

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 欧洲亚洲国产清在高| 伊人婷婷综合缴情亚洲五月| 亚洲黄色片免费看| 99久久人妻精品免费一区| 亚洲av无码一区二区乱子伦as | 亚洲色大成网站www永久男同| 成年人免费的视频| 亚洲AV无码乱码麻豆精品国产| **毛片免费观看久久精品| 久久久久久亚洲精品成人| 一级女人18毛片免费| 2020天堂在线亚洲精品专区| 日韩在线天堂免费观看| 国产成人高清亚洲一区91 | 亚洲国产精品高清久久久| 无码精品国产一区二区三区免费 | 亚洲成亚洲乱码一二三四区软件| 免费一级不卡毛片| 亚洲国产精品成人综合久久久| 男人的好看免费观看在线视频 | 亚洲午夜理论片在线观看| 国产a级特黄的片子视频免费| 乱淫片免费影院观看| 亚洲av无码av制服另类专区| 91福利免费视频| 亚洲高清毛片一区二区| 亚洲成A人片在线观看无码3D | 亚洲国产高清视频| 成年在线观看免费人视频草莓| 美女免费视频一区二区| 亚洲AV无码精品色午夜果冻不卡| 69成人免费视频| 人人爽人人爽人人片A免费| 亚洲伊人色欲综合网| 无码专区永久免费AV网站 | 8x8x华人永久免费视频| 亚洲GV天堂GV无码男同| 亚洲AV无码久久精品蜜桃| 日本高清免费不卡视频| 一级特黄aa毛片免费观看| 亚洲AV无码成人网站在线观看|