로그인

검색


DS918+에서 테스트 했습니다.

필요 패키지: 웹스테이션(아파치2.2, php5.6), 텍스트 편집기

위 패키지 설치 및 설정은 인터넷 검색하셔서 진행하시면 됩니다.

 

1.  작업 스캐줄러 등록.

`제어판 - 작업 스캐줄러`

생성 - 예약된 작업 - 사용자 정의 스크립트
스케줄 탭 - 시간 - 첫 실행 시간: 00:20 - 주기: 매시간 - 마지막 실행 시간: 23:20
(위 스케줄은 본인에 맞게 설정하세요.)
작업설정 탭 - 아래 내용 복/붙

cut -f1,3 -d: /etc/passwd > /var/services/tmp/ulist.txt
psql -U postgres -d video_metadata -t -A -c "SELECT id,path,filesize,duration FROM video_file;" > /var/services/tmp/vfile.txt
psql -U postgres -d video_metadata -t -A -c "SELECT id,uid,video_file_id,position,create_date,modify_date FROM watch_status ORDER BY modify_date DESC;" > /var/services/tmp/watch.txt

 

위 내용도 알아서 본인 환경에 맞게 작업 스케줄러에 등록하시면 됩니다.
제 경우엔 ulist.txt는 재부팅(시작) 할때만 한번 가져옵니다.

사용자를 자주 추가하는게 아니라서요. 본인이 자주 추가한다면 자주 업데이트 해주셔야 겟죠.

(생성 - 트리거된 작업 - 사용자 정의 스크립트 - 이벤트: 부트업)
vfile.txt도 8시간마다...
watch.txt는 1시간마다...

 

 

2. 폴더생성.

DSM - 파일 스테이션 - web - 폴더생성: status

 

3. php파일 생성.

파일편집기 - 파일 - 새로 만들기 - 아래 내용 복/붙 - 파일 - 저장 - 폴더: web/status - 파일이름: status.php - 인코딩: unicode(utf-8) - 저장.

 

<?php
$ipPass = array($_SERVER["SERVER_ADDR"],"접속허용 아이피(집)","접속허용 아이피(회사?)");
//접속허용 아이피를 필요한 만큼 추가하세요.
if(!in_array($_SERVER['REMOTE_ADDR'], $ipPass)) exit;

date_default_timezone_set('Asia/Seoul');

function filesize_formatted($size)
{
    $units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    $power = $size > 0 ? floor(log($size, 1024)) : 0;
    return number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
}

$a = array();
//사용자정보 가져오기
//안봐도 되는 계정들 등록. 관리자가 사용중인 본인 계정도 넣으시면 되구요.
$idBan  = array("guest","admin");
$user_list = file_get_contents('/var/services/tmp/ulist.txt');
$n = explode("\n",$user_list);
foreach($n as $l){
list($id,$uno) = explode(":",$l);
//사용자 계정이 1000명이 넘으면...뒤에 2000을 늘려주세요.
if($uno<1000 || $uno>2000) continue;
if(in_array($id,$idBan)) continue;
if($id) $a['u'][$uno]=$id;//mb_strimwidth($id,0,3,'***','utf-8');
}

$video_file = file_get_contents('/var/services/tmp/vfile.txt');
$n = explode("\n",$video_file);
foreach($n as $l){
list($id,$path,$filesize,$duration) = explode("|",$l);
if($id) $a['v'][$id]=array(array_pop(explode("/",$path)),$duration,filesize_formatted($filesize));
}

$watch_status = file_get_contents('/var/services/tmp/watch.txt');
$n = explode("\n",$watch_status);
foreach($n as $l){
list($id,$uid,$video_file_id,$position,$create_date,$modify_date) = explode("|",$l);
if($id && $a['u'][$uid]) $a['w'][$id]=array($a['u'][$uid],$a['v'][$video_file_id][0],array_shift(explode(".",$modify_date)),array_shift(explode(".",$create_date)),$position,$a['v'][$video_file_id][1],$a['v'][$video_file_id][2]);
}
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>비디오스테이션 사용목록</title>
</head>
<body style="font-size:9pt;">
<table>
<thead style="background:black;color:white;">
<tr>
<th>아이디</th>
<th>파일이름</th>
<th>파일크기</th>
<th>최근재생</th>
<th>처음재생</th>
<th>재생위치</th>
<th>재생시간</th>
</tr>
</thead>
<tbody style="background:gray;color:white;">
<?php
foreach($a['w'] as $id => $v){
if($v[3]<date("Y-m-d H:i:s",strtotime("-7 day"))) continue;
echo' <tr><td>'.(strlen($v[0])>6?(strlen($v[0])>9?substr($v[0],0,-6):substr($v[0],0,-3)):substr($v[0],0,-2)).'*****</td><td>'.$v[1].'</td><td>'.$v[6].'</td><td>'.$v[2].'</td><td>'.$v[3].'</td><td>'.gmdate('H:i:s',$v[4]).'</td><td>'.gmdate('H:i:s',$v[5]).'</td></tr>'.PHP_EOL;
}
?>
</tbody>
</table>
</body>
</html>

 

 

status.zip

 

4. 확인하기

주소줄에 `http://나스 사설IP or 공인IP/status/status.php` 실행.

아래 이미지 처럼 나오면 성공하신 겁니다.


  • ?
    건실한중년 2023.11.20 04:58
    dsm 7.2.1 입니다.
    아파치2.4 , php8.2
    웹스테이션 사용입니다.
    스케쥴러 실행시 아래와 같이 log 출력되는데, 무엇이 문제 일까용?

    psql: FATAL: Peer authentication failed for user "postgres"

리눅스

유용한 정보 및 자료

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
75 Server 테이블 형태 변경하기 MyISAM -> InnoDB(또는 InnoDB -> MyISAM) 보석 2011.10.21 25963
74 Server 우분투에서 압축하고 풀기( tar, gzip, tar.gz ) 보석 2011.08.31 15714
73 Server 우분투에 메일서버를 설치하자. file 보석 2011.12.10 10649
72 Server 우분투(리눅스) 상위폴더로 전체 데이터 옮기기 1 보석 2016.05.18 217
71 Server 우분투 프록시서버 만들기 file 보석 2014.02.03 9691
70 Server 우분투 폴더 소유권 설정 보석 2011.05.15 16403
69 Server 우분투 폴더 삭제 및 폴더 생성 보석 2011.05.15 21160
68 Server 우분투 트림활성화 및 수동 트림하기 보석 2012.11.04 19857
67 Server 우분투 크론 (예약작업) 설정 자동 백업 4 보석 2011.09.01 15846
66 Server 우분투 원격데스크톱 설정 보석 2012.03.30 12098
65 Server 우분투 오래된 커널 삭제 방법 보석 2016.01.14 317
64 Server 우분투 업데이트 서버 변경 보석 2012.11.11 12053
63 Server 우분투 업데이트 서버 변경 보석 2016.06.21 83
62 Server 우분투 센드메일 설치 및 설정 sendmail 2 보석 2011.05.16 22216
61 Server 우분투 서버(커맨드 모드)에서 외부 아이피 알아내기 보석 2012.04.05 14163
60 Server 우분투 사용자 패스워드 비번 변경 보석 2012.07.26 21177
59 Server 우분투 메일서버 보석 2012.03.30 10154
58 Server 우분투 리눅스에서 APM 설치하기 (웹서버 설정) 보석 2011.07.04 32846
57 Server 우분투 리눅스 자주쓰는 명령어 모음 보석 2011.05.15 13727
56 Server 우분투 루트권한 얻기 보석 2011.05.15 16031
Board Pagination Prev 1 2 3 4 Next
/ 4