История изменений
Исправление futurama, (текущая версия) :
Нет. Это видимо другая версия, но похоже на это. Ого 2017г. Не последние в 2024 делал
-rwxr-xr-x 1 1377 Jan 7 19:01 check_cameras_jobs.sh
-rwxr-xr-x 1 503 Feb 4 15:18 cam1-store.sh
-rwxr-xr-x 1 503 Feb 4 15:18 cam2-store.sh
$ cat bin/check_cameras_jobs.sh
#!/bin/bash
PATH='/bin:/usr/bin:/sbin:/usr/sbin'
exec > /home/user/camera.log
exec 2> /home/user/camera.err
[ `date '+%H'` -eq 0 ] && exit 0
CAMDIR='/camera'
CAM1='cam1'
CAM2='cam2'
#IF no space on disk
while ! /usr/lib/nagios/plugins/check_disk -w 15% -c 10% -p $CAMDIR >/dev/null 2>&1; do
# clean up
RMDIR1=`ls -1rt $CAMDIR/$CAM1 |head -1`
RMDIR2=`ls -1rt $CAMDIR/$CAM2 |head -1`
[ -n "$RMDIR1" ] && rm -rf $CAMDIR/$CAM1/$RMDIR1
[ -n "$RMDIR2" ] && rm -rf $CAMDIR/$CAM2/$RMDIR2
sleep 5
done
# если ffmpeg умер, то и screen тоже
# проверяем screen
screen -ls | grep -q "$CAM1" || screen -d -m -S $CAM1 ~/bin/${CAM1}-store.sh
screen -ls | grep -q "$CAM2" || screen -d -m -S $CAM2 ~/bin/${CAM2}-store.sh
sleep 5
# check if ffmpeg is working
# check that dir is grow
TODAYDIR=`date '+%Y-%m-%d'`
SIZE11=`du -sk $CAMDIR/$CAM1/$TODAYDIR | cut -f1`
SIZE21=`du -sk $CAMDIR/$CAM2/$TODAYDIR | cut -f1`
sleep 30
SIZE12=`du -sk $CAMDIR/$CAM1/$TODAYDIR | cut -f1`
SIZE22=`du -sk $CAMDIR/$CAM2/$TODAYDIR | cut -f1`
if [ "$SIZE11" -eq "$SIZE12" ]; then
# kill ffmpeg 1
pkill -9 -f '1&stream=0'
pkill -9 -f 'cam1-store'
sleep 1
screen -d -m -S $CAM1 ~/bin/${CAM1}-store.sh
screen -wipe
fi
if [ "$SIZE21" -eq "$SIZE22" ]; then
# kill ffmpeg 2
pkill -9 -f '3&stream=0'
pkill -9 -f 'cam2-store'
sleep 1
screen -d -m -S $CAM2 ~/bin/${CAM2}-store.sh
screen -wipe
fi
$ cat bin/cam1-store.sh
#!/bin/bash
REG_IP='192.168.1.5'
CAM_NUM=cam1
VDIR=/camera/${CAM_NUM}
RTSP1='rtsp://'$REG_IP'/user=admin&password=XXXXXXX&channel=1&stream=0'
SUFF='.mp4'
while :; do
SEC=$((`date +%s -d 'today 23:59:59'` - `date +%s`))
mkdir -p $VDIR/`date '+%Y-%m-%d'`
cd $VDIR/`date '+%Y-%m-%d'`
PREF1=`date +%s`
ffmpeg -rtsp_transport tcp -nostdin -i "$RTSP1" -t $SEC -r 30 -vcodec copy -an -f segment -segment_time 60 -segment_format mp4 "${PREF1}-%d${SUFF}" 2>/dev/null
sleep 3
done
$ du -sh /camera/cam*/*
36G /camera/cam1/2024-04-06
34G /camera/cam1/2024-04-07
26G /camera/cam1/2024-04-08
23G /camera/cam2/2024-04-06
23G /camera/cam2/2024-04-07
18G /camera/cam2/2024-04-08
$ df -h /camera/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg1-cam 250G 158G 93G 63% /camera
Исправление futurama, :
Нет. Это видимо другая версия, но похоже на это. Ого 2017г. Не последние в 2024 делал
-rwxr-xr-x 1 1377 Jan 7 19:01 check_cameras_jobs.sh
-rwxr-xr-x 1 503 Feb 4 15:18 cam1-store.sh
-rwxr-xr-x 1 503 Feb 4 15:18 cam2-store.sh
$ cat bin/check_cameras_jobs.sh
#!/bin/bash
PATH='/bin:/usr/bin:/sbin:/usr/sbin'
exec > /home/user/camera.log
exec 2> /home/user/camera.err
[ `date '+%H'` -eq 0 ] && exit 0
CAMDIR='/camera'
CAM1='cam1'
CAM2='cam2'
#IF no space on disk
while ! /usr/lib/nagios/plugins/check_disk -w 15% -c 10% -p $CAMDIR >/dev/null 2>&1; do
# clean up
RMDIR1=`ls -1rt $CAMDIR/$CAM1 |head -1`
RMDIR2=`ls -1rt $CAMDIR/$CAM2 |head -1`
[ -n "$RMDIR1" ] && rm -rf $CAMDIR/$CAM1/$RMDIR1
[ -n "$RMDIR2" ] && rm -rf $CAMDIR/$CAM2/$RMDIR2
sleep 5
done
# если ffmpeg умер, то и screen тоже
# проверяем screen
screen -ls | grep -q "$CAM1" || screen -d -m -S $CAM1 ~/bin/${CAM1}-store.sh
screen -ls | grep -q "$CAM2" || screen -d -m -S $CAM2 ~/bin/${CAM2}-store.sh
sleep 5
# check if ffmpeg is working
# check that dir is grow
TODAYDIR=`date '+%Y-%m-%d'`
SIZE11=`du -sk $CAMDIR/$CAM1/$TODAYDIR | cut -f1`
SIZE21=`du -sk $CAMDIR/$CAM2/$TODAYDIR | cut -f1`
sleep 30
SIZE12=`du -sk $CAMDIR/$CAM1/$TODAYDIR | cut -f1`
SIZE22=`du -sk $CAMDIR/$CAM2/$TODAYDIR | cut -f1`
if [ "$SIZE11" -eq "$SIZE12" ]; then
# kill ffmpeg 1
pkill -9 -f '1&stream=0'
pkill -9 -f 'cam1-store'
sleep 1
screen -d -m -S $CAM1 ~/bin/${CAM1}-store.sh
screen -wipe
fi
if [ "$SIZE21" -eq "$SIZE22" ]; then
# kill ffmpeg 2
pkill -9 -f '3&stream=0'
pkill -9 -f 'cam2-store'
sleep 1
screen -d -m -S $CAM2 ~/bin/${CAM2}-store.sh
screen -wipe
fi
$ cat bin/cam1-store.sh
#!/bin/bash
REG_IP='192.168.1.5'
CAM_NUM=cam1
VDIR=/camera/${CAM_NUM}
RTSP1='rtsp://'$REG_IP'/user=admin&password=XXXXXXX&channel=1&stream=0'
SUFF='.mp4'
while :; do
SEC=$((`date +%s -d 'today 23:59:59'` - `date +%s`))
mkdir -p $VDIR/`date '+%Y-%m-%d'`
cd $VDIR/`date '+%Y-%m-%d'`
PREF1=`date +%s`
ffmpeg -rtsp_transport tcp -nostdin -i "$RTSP1" -t $SEC -r 30 -vcodec copy -an -f segment -segment_time 60 -segment_format mp4 "${PREF1}-%d${SUFF}" 2>/dev/null
sleep 3
done
Исправление futurama, :
Нет. Это видимо другая версия, но похоже на это. Ого 2017г. Не последние в 2024 делал
-rwxr-xr-x 1 1377 Jan 7 19:01 check_cameras_jobs.sh
-rwxr-xr-x 1 503 Feb 4 15:18 cam1-store.sh
-rwxr-xr-x 1 503 Feb 4 15:18 cam2-store.sh
$ cat bin/check_cameras_jobs.sh
#!/bin/bash
PATH='/bin:/usr/bin:/sbin:/usr/sbin'
exec > /home/user/camera.log
exec 2> /home/user/camera.err
[ `date '+%H'` -eq 0 ] && exit 0
CAMDIR='/camera'
CAM1='cam1'
CAM2='cam2'
#IF no space on disk
while ! /usr/lib/nagios/plugins/check_disk -w 15% -c 10% -p $CAMDIR >/dev/null 2>&1; do
# clean up
RMDIR1=`ls -1rt $CAMDIR/$CAM1 |head -1`
RMDIR2=`ls -1rt $CAMDIR/$CAM2 |head -1`
[ -n "$RMDIR1" ] && rm -rf $CAMDIR/$CAM1/$RMDIR1
[ -n "$RMDIR2" ] && rm -rf $CAMDIR/$CAM2/$RMDIR2
sleep 5
done
# если ffmpeg умер, то и screen тоже
# проверяем screen
screen -ls | grep -q "$CAM1" || screen -d -m -S $CAM1 ~/bin/${CAM1}-store.sh
screen -ls | grep -q "$CAM2" || screen -d -m -S $CAM2 ~/bin/${CAM2}-store.sh
sleep 5
# check if ffmpeg is working
# check that dir is grow
TODAYDIR=`date '+%Y-%m-%d'`
SIZE11=`du -sk $CAMDIR/$CAM1/$TODAYDIR | cut -f1`
SIZE21=`du -sk $CAMDIR/$CAM2/$TODAYDIR | cut -f1`
sleep 30
SIZE12=`du -sk $CAMDIR/$CAM1/$TODAYDIR | cut -f1`
SIZE22=`du -sk $CAMDIR/$CAM2/$TODAYDIR | cut -f1`
if [ "$SIZE11" -eq "$SIZE12" ]; then
# kill ffmpeg 1
pkill -9 -f '1&stream=0'
pkill -9 -f 'cam1-store'
sleep 1
screen -d -m -S $CAM1 ~/bin/${CAM1}-store.sh
screen -wipe
fi
if [ "$SIZE21" -eq "$SIZE22" ]; then
# kill ffmpeg 2
pkill -9 -f '3&stream=0'
pkill -9 -f 'cam2-store'
sleep 1
screen -d -m -S $CAM2 ~/bin/${CAM2}-store.sh
screen -wipe
fi
Исправление futurama, :
Нет. Это видимо другая версия, но похоже на это. Ого 2017г. Не последние в 2024 делал
-rwxr-xr-x 1 1377 Jan 7 19:01 check_cameras_jobs.sh
-rwxr-xr-x 1 503 Feb 4 15:18 cam1-store.sh
-rwxr-xr-x 1 503 Feb 4 15:18 cam2-store.sh
Исправление futurama, :
Нет. Это видимо другая версия, но похоже на это. Ого 2017г. Не последние в 2023 делал
Исходная версия futurama, :
Нет. Это видимо другая версия, но похоже на это