/home/mjc1/public_html/apache_connect_log.php


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
<?php
header
("Access-Control-Allow-Origin: *");
date_default_timezone_set("Asia/Seoul");

$df1 trim(shell_exec('netstat -nap | grep :80 | grep ESTABLISHED | wc -l'));
$df2 trim(shell_exec("netstat -n|grep -F :80|egrep '(ESTAB|SYN)'|awk '{print $5}'|sed 's/:[0-9]*//'|sort -u|wc -l"));

$date date("Y-m-d H:i:s");

// 웹 홈페이지 DB
$DB_HOSTWEB2  =  "114.108.136.196";
$DB_USERWEB2  =  "web_connect";
$DB_PWDWEB2   =  "mj007700";
$DB_NAMEWEB2  =  "web_connect";
$connect_shop2    mysql_connect($DB_HOSTWEB2,$DB_USERWEB2,$DB_PWDWEB2);
mysql_select_db$DB_NAMEWEB2,$connect_shop2);

$sql "set names utf8";
mysql_query($sql,$connect_shop2);

//1주일 이전건 삭제
$del_date $reg_date date("Y-m-d H:i:s",time()-(60*60*24*7));
$sql "delete from apach_con_log where do_time <= '{$del_date}' ";
mysql_query($sql,$connect_shop2);


$sql "insert into apach_con_log set
                            ip = '74', do_time = '
{$date}', connect1 = '{$df1}', connect2 = '{$df2}'
                "
;
mysql_query($sql,$connect_shop2);

?>