로그인

검색


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
번호 분류 제목 글쓴이 날짜 조회 수
4 Server 우분투(리눅스) 상위폴더로 전체 데이터 옮기기 1 보석 2016.05.18 212
3 Server 우분투 16.04 런처 하단으로 옮기는 방법 보석 2016.06.06 90
2 Server 우분투 업데이트 서버 변경 보석 2016.06.21 78
» Server 시놀로지(synology) 비디오 스테이션(video station) 사용목록(use list) 시청목록(watch list) 저장용 1 file 보석 2023.06.21 174
Board Pagination Prev 1 ... 2 3 4 5 6 7 8 9 10 11 Next
/ 11