로그인

검색


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
번호 분류 제목 글쓴이 날짜 조회 수
55 Server 우분투 로그 위치 및 각 로그의 설명 보석 2013.08.25 21417
54 Server 우분투 레이드0 설치 install Ubuntu RAID0 보석 2012.10.23 11882
53 Server 우분투 네트워크 트래픽 감시 / 속도 측정 보석 2011.05.16 20827
52 Server 우분투 가상호스트 설정 보석 2011.05.15 28853
51 Server 우분투 webalizer 설치 트래픽 확인 셋팅 방법 보석 2011.05.16 14689
50 Server 우분투 rpm 파일을 deb로변경후 설치하기 보석 2013.02.15 23855
49 Server 우분투 PHP5.3 버젼에 ioncube설치하기 보석 2011.10.17 25749
48 Server 우분투 PHP 설치 1 보석 2012.05.20 11477
47 Server 우분투 nginx rewrite 보석 2011.11.03 235869
46 Server 우분투 mysql DB 파일 위치 변경 방법 패키지로 설치 했을 경우 보석 2013.08.26 57388
45 Server 우분투 Memcached 설치는 이렇게 보석 2011.10.19 28786
44 Server 우분투 innoDB 활성화하기 보석 2012.11.16 8568
43 Server 우분투 DB백업 복원 보석 2012.01.01 10681
42 Server 우분투 AMP(아파치,mysql,php)설치 및 셋팅 - 웹서버운영 보석 2011.05.15 13340
41 Server 우분투 16.04 런처 하단으로 옮기는 방법 보석 2016.06.06 96
40 Server 우분투 13.04 DNS 설정방법 보석 2013.08.23 20542
39 Server 우분투 11.04에 Nginx에, PHP5, PHP-FPM와 MySQL 설치 보석 2015.02.24 1125
38 Server 우분투 "지울 수 없음: 읽기전용 파일 시스템" 이라고 나올때 보석 2016.05.17 151
» Server 시놀로지(synology) 비디오 스테이션(video station) 사용목록(use list) 시청목록(watch list) 저장용 1 file 보석 2023.06.21 181
36 Server 설치된 패키지 깨끗이 삭제하지 보석 2011.11.03 24470
Board Pagination Prev 1 2 3 4 Next
/ 4