Log sort

Ocak 28, 2019 § Yorum yok § Kalıcı bağlantı

cut -d field seperator, -f filedleri almak için 
sort:
-r reverse
-t field seperator
-k 2. fielde göre sırala
-n numerik
[root@vt02 pg_log]# head 1.txt| cut -d" " -f1,6 | sort -n -r -t ' ' -k 2
<172.16.42.34-2016-11-11 2.655
<172.16.42.37-2016-11-11 2.463
<172.16.42.41-2016-11-11 2.428
<172.16.42.34-2016-11-11 0.621
<172.16.42.37-2016-11-11 0.596
<172.16.42.41-2016-11-11 0.593
<172.16.42.45-2016-11-11 0.140
<172.16.42.34-2016-11-11 0.113
<172.16.42.37-2016-11-11 0.110
<172.16.42.41-2016-11-11 0.091

Linux route eklemek

Ocak 28, 2019 § Yorum yok § Kalıcı bağlantı

route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.5.1 dev bond0
route add -net 192.168.5.0 netmask 255.255.255.0 dev bond0

seq kullanımı

Ocak 28, 2019 § Yorum yok § Kalıcı bağlantı

seq -w 2 19 | while read sayi; do echo $sayi; done;

VLC uzaktan yönetim interfaceleri

Ocak 28, 2019 § Yorum yok § Kalıcı bağlantı

RC interface
Bir makinede

vlc -vvv udp://@224.1.2.249:1234 --quiet --intf oldrc --rc-host localhost:8082
veya 
cvlc -vvv udp://@224.1.2.249:1234 --quiet --extraintf=oldrc --rc-host localhost:8082

diğerinde ilgili porta komut gönderiyoruz:

echo quit | nc localhost 8082 &>/dev/null

Telnet interfacei ile restream yapmak:

Birinci makinede:
cvlc -vvv udp://@224.1.2.249:1234 --quiet --extraintf=telnet --telnet-password=test --telnet-port=9999 --rtsp-host=127.0.0.1 --rtsp-port=9000
-------------------------------------------------

İkinci makinede
frk-sk ~ #  telnet localhost 9999
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
VLC media player 2.1.6 Rincewind
Password: 
Welcome, Master
> new Test vod enabled        
new
> setup Test input udp://@224.1.2.249:1234
setup

İkinci makinede birden fazla restream oluturmak için:

frk-sk ~ # telnet localhost 9999
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
VLC media player 2.1.6 Rincewind
Password: 
Welcome, Master
> new Test vod enabled
new
> setup Test input udp://@224.1.2.249:1234
setup
> new Test2 vod enabled
new
> setup Test2 input udp://@224.1.2.250:1234
setup


restream ederken trancode etmek de mümkün:

frk-sk ~ # telnet localhost 9999
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
VLC media player 2.1.6 Rincewind
Password: 
> setup Test output #transcode{vcodec=h264,acodec=mp4a}
setup
> setup Test mux mp2t
setup
> setup Test input udp://@224.1.2.249:1234
setup
> setup Test enabled
setup


frk-sk ~ # telnet localhost 9999
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
VLC media player 2.1.6 Rincewind
Password: 
Welcome, Master
> new live broadcast
new
> setup live  input udp://@224.1.2.249:1234
setup
> setup live output #rtp{mux=ts,sdp=rtsp://:9998/live.sdp}                            
setup
> setup live enabled
setup


--------------------------------------------------------------------------------------------------
Ucuncu makinede:
vlc rtsp://127.0.0.1:9000/Test
vlc rtsp://127.0.0.1:9000/Test2
vlc rtp://127.0.0.1:9998/live.sdp


Unix socket kullanmak

Birinci makinede

frk-sk ~ # cvlc -vvv --quiet --extraintf=oldrc --rc-unix /tmp/test2.sock  udp://@224.1.2.249:1234


ikinci makinede  komut göndermek için:

frk-sk ~ # echo -n "pause" | nc -U /tmp/test2.sock
frk-sk ~ # echo -n "play" | nc -U /tmp/test2.sock
frk-sk ~ # echo -ne "play" | nc -U /tmp/test2.sock
frk-sk ~ # echo -n "pause" | nc -U /tmp/test2.sock
frk-sk ~ # echo -n "help" | nc -U /tmp/test2.sock
frk-sk ~ # echo -n "title deneme" | nc -U /tmp/test2.sock
frk-sk ~ # echo -n "playlist" | nc -U /tmp/test2.sock
frk-sk ~ # echo -n "quit" | nc -U /tmp/test2.soc



Windows Dizinini Linux’de mount etmek

Ocak 28, 2019 § Yorum yok § Kalıcı bağlantı

How to make the mounting permanent?
Open /etc/fstab d

sudo vim /etc/fstab
and add line

//REMOTE-WIN-NAME-OR-IP/REMOTE-SHARED-FOLdER /LOCAL-LINUX-SHARE user=WIN-USERNAME,domain=WIN-DOAMIN,password=WIN-PASS,iocharset=utf8 0 0
in my case

//192.168.10.108/D /home/palo/share/PC-D/ cifs user=palo,domain=kis,password=********,iocharset=utf8 0 0
then remount it all

sudo mount -a
and check with

mount

More secure way of the same
Previous example has a problem that the /etc/fstab may read someone and see your passwords, therefore a secure way of the same is to make a local text file

vim ~.credentials
and put there

username=valuevalue
password=valuevalue
domain=valuevalue
whare “value” are yours usernanme/password/domain_name

then modify /etc/fstab line from

//REMOTE-WIN-NAME-OR-IP/REMOTE-SHARED-FOLdER /LOCAL-LINUX-SHARE user=WIN-USERNAME,domain=WIN-DOAMIN,password=WIN-PASS,iocharset=utf8 0 0
to

//REMOTE-WIN-NAME-OR-IP/REMOTE-SHARED-FOLdER /LOCAL-LINUX-SHARE credentials=/root/.win_creditals,iocharset=utf8 0 0
then close the file and run

sudo mount -a
Done!

Benim kullandıgım dosyalar:

/etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=9cea0017-3082-4b1d-bd9a-7090aef15515 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=49581f69-2a85-42fc-bf4a-d14a4a6ce314 none            swap    sw              0       0
#//192.168.10.108/D /home/palo/share/PC-D/ cifs  user=palo,domain=kis,password=********,iocharset=utf8 0 0

//172.16.2./Users/Administrator/Desktop/test /home/fatih/shred cifs credentials=/root/.win_creditals,iocharset=utf8 0 0

/root/.win_credital içeriği

username=Administrator
password=xxxxxx
domain=SKxxS.NET

mount ve umount’u elle yapmak için

mount.cifs //172.16.x.x/Users/Administrator/Desktop/test /home/fth/shred -o user=Administrator,domain=SKxxS.NET
umount -t cifs /home/fth/shred

ffmpeg ile resize (küçültme, büyütme) yapmak

Ocak 28, 2019 § Yorum yok § Kalıcı bağlantı

Aspect ratio korunurken rescale etmek için en veya boydan biri -1 veya -2 verilir.

ffmpeg -i input.jpg -vf scale=320:-1 output_320.png

Görüntüyü 1/6 oranına getirmek

ffmpeg -i ../scriptler/sonuc.ts -c:v libx264 -c:a mp3 -vf scale=iw/6:-1 -b 130k -minrate 130k -maxrate 130k sonuc2.mp4

diğer örnekler
1/2 oranında küçültmek

ffmpeg -i input.jpg -vf "scale=iw*.5:ih*.5" input_half_size.png
ffmpeg -i input.jpg -vf "scale=iw/2:ih/2" input_half_size.png

Boyut tam olarak da verilebilir:

ffmpeg -i input.jpg -vf scale=320:240 output_320x240.png

Referans: https://trac.ffmpeg.org/wiki/Scaling#no1

Rsyslog İle İstenilen Logları Taşımak

Temmuz 24, 2018 § Yorum yok § Kalıcı bağlantı

Herhangi bir log dosyasını rsyslog ile servis etmek için
/etc/rsyslog.conf dosyasının içine

$ModLoad imfile

#variables required for non-syslog log file forwarding – SystemErr
$InputFileName /var/log/IBM/Websphere/AppServer/SystemErr.log
$InputFileTag websphere-errors
$InputFileStateFile websphere-errors
$InputFileSeverity error
$InputFileFacility local7
$InputRunFileMonitor

eklenebilir.

rsyslog ile merkezi sunucuya aktarmak için loglar aşağıdaki gibi yönlendirilmeli:

*.* @@172.x.x.x:514;RSYSLOG_SyslogProtokol23Format

Resim arşivinden backup DVD oluşturmak

Ekim 24, 2017 § Yorum yok § Kalıcı bağlantı

Öncelikle DVD olacak büyüklükte tar dosyalarını ve pariteleri oluşturalım

cd hatiralar
for i in `find ./   -maxdepth 1  -mindepth 1 -type d`; do tar -cv $i| split -b 3584MB - "${i}_tar_cv.part_"; done;
for i in `find ./   -maxdepth 1  -mindepth 1 -name '*tar_cv.part*'`; do par2 create -r20 $i; done;

Daha sonra yapilan işlemler sıra ile

md5sum dvd2/* >> hatiralar_dvd17.txt
cp hatiralar_dvd17.txt dvd1/
mkisofs -o ../iso/dvd13.iso -J /home/fatiho/dvd_hatiralar/dvd2/*
dvdisaster -c -i /home/fatiho/dvd_hatiralar/iso/dvd13.iso  -e /home/fatiho/dvd_hatiralar/iso/dvd13.ecc
growisofs -dvd-compat -speed=12 -Z /dev/sr0=/home/fatiho/dvd_hatiralar/iso/dvd12.iso

Bu işleri tek satırda yapmak için :

for i in `find ./   -maxdepth 1  -mindepth 1 -type d -name 'dvd*'`; do adi=`basename $i`; echo $adi;echo $i; md5sum $i/* >> "hatiralar_${adi}.txt";cp "hatiralar_${adi}.txt" $i/; mkisofs -o  "/home/fatiho/dvd_hatiralar/iso/${adi}.iso" -J $i/*; dvdisaster -c -i "/home/fatiho/dvd_hatiralar/iso/${adi}.iso"  -e "/home/fatiho/dvd_hatiralar/iso/${adi}.ecc"; done;

Multicast trafiği dinleme

Ekim 24, 2017 § Yorum yok § Kalıcı bağlantı

Iperf server
route add -host 239.255.1.3 ethx (where x is the interface used to transmit/receive multicast traffic)
iperf -s -B 239.255.1.3 -u -f m -i 5 – This command will run iperf in server mode. It will to join multicast group 239.255.1.3 and receive 1470 byte UDP datagrams from the client once the client is started. Rates will be formatted in Mbps and will be reported every 5 seconds.

root@perf138:iperf-2.0.4# iperf -s -B 239.255.1.3 -u -f m -i 5
------------------------------------------------------------
Server listening on UDP port 5001
Binding to local address 239.255.1.3
Joining multicast group  239.255.1.3
Receiving 1470 byte datagrams
UDP buffer size: 8.00 MByte (default)
------------------------------------------------------------
[  3] local 239.255.1.3 port 5001 connected with 10.4.2.139 port 32952
[ ID] Interval       Transfer     Bandwidth       Jitter   Lost/Total Datagrams
[  3]  0.0- 5.0 sec    570 MBytes    957 Mbits/sec  0.017 ms    0/406906 (0%)
[ ID] Interval       Transfer     Bandwidth       Jitter   Lost/Total Datagrams
[  3]  5.0-10.0 sec    570 MBytes    957 Mbits/sec  0.015 ms    0/406894 (0%)
[ ID] Interval       Transfer     Bandwidth       Jitter   Lost/Total Datagrams
[  3] 10.0-15.0 sec    570 MBytes    957 Mbits/sec  0.016 ms    0/406905 (0%)
[ ID] Interval       Transfer     Bandwidth       Jitter   Lost/Total Datagrams
[  3] 15.0-20.0 sec    570 MBytes    957 Mbits/sec  0.018 ms    0/406891 (0%)
[ ID] Interval       Transfer     Bandwidth       Jitter   Lost/Total Datagrams
[  3] 20.0-25.0 sec    570 MBytes    957 Mbits/sec  0.013 ms    0/406897 (0%)
[ ID] Interval       Transfer     Bandwidth       Jitter   Lost/Total Datagrams
[  3] 25.0-30.0 sec    570 MBytes    957 Mbits/sec  0.010 ms    0/406907 (0%)
[ ID] Interval       Transfer     Bandwidth       Jitter   Lost/Total Datagrams
[  3]  0.0-30.0 sec  3423 MBytes    957 Mbits/sec  0.026 ms    0/2441426 (0%)

root@perf138:iperf-2.0.4#

Iperf client
route add -host 239.255.1.3 ethx (where x is the interface used to transmit/receive multicast traffic)
iperf -c 239.255.1.3 -u -b 957m -f m -i 5 -t 30 – o This command will run iperf in client mode. It will transmit 1470 byte UDP datagrams to destination address 239.255.1.3 at a rate of 957 Mbps. The test will terminate after 30 seconds. Rates will be formatted in Mbps and will be reported every 5 seconds.

root@perf139:iperf-2.0.4# iperf -c 239.255.1.3 -u -b 990m -f m -i 5 -t 30
------------------------------------------------------------
Client connecting to 239.255.1.3, UDP port 5001
Sending 1470 byte datagrams
Setting multicast TTL to 1
UDP buffer size: 0.06 MByte (default)
------------------------------------------------------------
[  3] local 10.4.2.139 port 32952 connected with 239.255.1.3 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 5.0 sec    570 MBytes    957 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0-10.0 sec    570 MBytes    957 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3] 10.0-15.0 sec    570 MBytes    957 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3] 15.0-20.0 sec    570 MBytes    957 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3] 20.0-25.0 sec    570 MBytes    957 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3] 25.0-30.0 sec    570 MBytes    957 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-30.0 sec  3423 MBytes    957 Mbits/sec
[  3] Sent 2441428 datagrams
root@perf139:iperf-2.0.4#

Saniye bazında cronjob vermek

Şubat 25, 2015 § Yorum yok § Kalıcı bağlantı

Bildiğimiz gibi cronjoblar dakika olarak verilebilir.
Saniye bazında vermek için basit bir çözüm.
30 saniyede bir çalışan cronjob:

* * * * * /home/xxxx/1.sh
* * * * * (sleep 30; /home/xxxx/1.sh)

Neredeyim ben!?

Linux Notları kategorisinde geziniyorsun.