본문 바로가기
Application/NAS

[NAS] synology download station 정보 읽어오기

by NAMP 2017. 3. 19.

[NAS] synology download station 정보 읽어오기

삭제하는 커맨드 실행전에, 해당 내용을 전송하기 위해 download station의 정보를 읽습니다.

삭제하는 커맨드는 아래와 같습니다.


psql -t -A -U postgres -d download -c "delete from download_queue where status=5"

테이블 구조를 모르니, psql 로 접속합니다.

ssh 로 접속하여 아래 명령어를 실행합니다.


psql -t -A -U postgres -d download

접속이후에 \d명령을 실행하면 테이블 목록을 얻을 수 있습니다.


download=# \d
public|download_queue|table|DownloadStation
public|download_queue_task_id_seq|sequence|DownloadStation
public|notification|table|DownloadStation
public|notification_id_seq|sequence|DownloadStation
public|notification_view|view|DownloadStation
public|rss_feed|table|DownloadStation
public|rss_feed_id_seq|sequence|DownloadStation
public|rss_filter|table|DownloadStation
public|rss_filter_id_seq|sequence|DownloadStation
public|rss_item|table|DownloadStation
public|rss_item_id_seq|sequence|DownloadStation
public|sysconf|table|DownloadStation
public|task_plugin|table|DownloadStation
public|test_filter_view|view|DownloadStation
public|thumbnail|table|DownloadStation
public|thumbnail_thumbnail_id_seq|sequence|DownloadStation
public|user_setting|table|DownloadStation

완료된 목록이 필요하므로 download_queue 테이블 정보를 확인합니다. \d download_queue 명령을 실행합니다.


download=#\d download_queue
task_id|integer|not null default nextval('download_queue_task_id_seq'::regclass)
username|character varying(128)|
pid|integer|
url|text|
filename|character varying(1024)|
status|integer|
created_time|integer|
started_time|integer|
total_size|bigint|
current_size|bigint|
current_rate|integer|
extra_info|text|
total_peers|integer|
connected_peers|integer|
total_pieces|integer|
downloaded_pieces|integer|
available_pieces|integer|
upload_rate|integer|default 0
total_upload|bigint|default 0
seeding_ratio|integer|default 0
seeding_interval|integer|default 0
seeding_elapsed|integer|default 0
task_flags|integer|default 0
seeders|integer|default 0
leechers|integer|default 0
destination|text|
unzip_password|text|
unzip_progress|integer|default 0
given_filename|text|
referer|text|
cookie_path|text|
thumbnail_status|integer|default 0
extra_data|json|
completed_time|integer|default 0
waiting_until_time|integer|default 0
file_oid|oid|default 0

어느 파일이 다운로드 완료되었는지 알기 위해서 필요한 정보는 filename 입니다.

정리가 실행되기 전에, 해당 정보를 읽어서, 전송하는 스크립트를 작성합니다.


filename=`psql -t -A -U postgres -d download -c "select filename from download_queue where status=5"`
if [ -n "$filename" ]
  then
    curl -d "token=YOUR_TOKEN" --data-urlencode "message=$filename Download Complete" https://notify.gyubot.com/send
fi

출처

댓글