서버에 webknight로그가 쌓이면 자동으로 메일일 뿌려주는 에이전트 개발
-> 모니터링 중이 아니더라도 메일을 통해 이벤트확인이 가능

주요함수 
FindFirstChangeNotification
FindNextChangeNotification
WaitForMultipleObjects



 // agent.cpp : Defines the entry point for the console application.
//

#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <tchar.h>
#include <Wininet.h>

int _tmain(int argc, _TCHAR* argv[])
{
HANDLE dwChangeHandles[1];
DWORD dwWaitStatus; 
HINTERNET hInternet;
HINTERNET hURL;
HINTERNET hRequest;
BOOL bRet;

dwChangeHandles[0] = FindFirstChangeNotification(L"C:\\Program Files\\AQTRONIX Webknight\\LogFiles",TRUE,FILE_NOTIFY_CHANGE_SIZE);

if(dwChangeHandles[0] == INVALID_HANDLE_VALUE)
{
printf("\nerror: unexpected null from findfirstchangenotification.\n");
ExitProcess(GetLastError());
}
if(dwChangeHandles[0] == NULL)
{
 printf("\n ERROR: Unexpected NULL from FindFirstChangeNotification.\n");
 ExitProcess(GetLastError());
}
while(TRUE)
{
printf("\nWaiting for notification...\n");
dwWaitStatus = WaitForMultipleObjects(1,dwChangeHandles,FALSE,INFINITE); 
    switch (dwWaitStatus)
    {
      case WAIT_OBJECT_0:
            printf("\nchange log size\n");

hInternet = InternetOpen(L"WebKnightConsoleAgent",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
hURL = InternetConnect(hInternet,L"192.168.230.130",80,L"",L"",INTERNET_SERVICE_HTTP,0,0);
hRequest = HttpOpenRequest(hURL,L"GET",L"/LogAnalysis.php?no=1&mail=1",NULL,NULL,NULL,0,0);

bRet = HttpSendRequest(hRequest,NULL,0,NULL,0);
            if ( FindNextChangeNotification(dwChangeHandles[0]) == FALSE )
            {
               printf("\n ERROR: FindNextChangeNotification function failed.\n");
               ExitProcess(GetLastError()); 
            }
            break; 
      case WAIT_TIMEOUT:
            printf("\nNo changes in the timeout period.\n");
            break;
      default: 
            printf("\n ERROR: Unhandled dwWaitStatus.\n");
            ExitProcess(GetLastError());
            break;
    }
  }





return 0;
}

'webhxxx > 연구과제' 카테고리의 다른 글

111121_진행상황  (0) 2011.11.21
input 자동완성 방지  (0) 2011.11.21
111106_진행상황 (webknight console)  (0) 2011.11.06
111102bugfix  (0) 2011.11.02
dynamic gauge(google chart) for snmp  (0) 2011.11.01
Posted by applicationlayer
:



구글차트는 인터넷 익스플로러에서 돌아가기는하나 그래픽이 부드럽지 않게 보이고 상대적으로 버벅인다. 역시 크롬에서 가장 매끄러운 화면을 보여준다.

구글 게이지차트와 윈도우snmp를 연동하는 작업을 했는데 상당히 애를 먹었다. 결국에 정석대로 코딩을 하면 문제없는 것인데 인터넷에는 꼼수가 너무 많이 나온다. 그리고 서적도 이런부분에 대해서 정확하게 언급하지 않는다. 웹프로그래밍 자체가 문법에 많이 관대하다보니 이런 문제가 생기는듯

남은것
[완료]서버 cpu,mem,traffic체크기능
[완료]구글맵 마커 디자인 - 그냥 구글꺼쓰기로.. 귀찮다
윈도우서버 에이전트
webknight conf 리스트박스 콤보박스 관련 기능
각 서버로그 통계
[완료]서버 추가 ui
[완료]서버 삭제 기능
Additional info클릭시 전문 출력



'webhxxx > 연구과제' 카테고리의 다른 글

input 자동완성 방지  (0) 2011.11.21
111117_진행상황 (webknight console)  (0) 2011.11.18
111102bugfix  (0) 2011.11.02
dynamic gauge(google chart) for snmp  (0) 2011.11.01
111031_진행상황 (webknight console)  (0) 2011.10.31
Posted by applicationlayer
:

111102bugfix

webhxxx/연구과제 2011. 11. 2. 12:38 |
Loganalysis.php
날짜 증가시 한자리일 경우 0을 붙여 두자리수로 수정
Posted by applicationlayer
: