Wednesday, July 25, 2012

Вывод конфига без комментарий


cat ./squid.conf |grep -v "^#"
cat ./squid.conf |grep -v -E "^#|^$" - исключая пусты строки

Install qt-faststart Centos

svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure
make
make tools/qt-faststart
cp -a tools/qt-faststart /usr/bin/

php-ffmpeg Centos

Ставим ffmpeg
yum install ffmpeg ffmpeg-devel ffmpeg-libpostproc 
yum install php-gd php-devel 


Cтавим ffmpeg-php
Now we are ready to install ffmpeg-php. This can be done in six easy steps:

Качаем latest ffmpeg-php release
Распаковываем архив:
tar -xjf ffmpeg-php-X.x.x.tbz2
cd ffmpeg-php-X.x.x/
phpize
./configure && make
sudo make install


PHP

Открывеаем файл php.ini и самом конце добавляем строчку — extension=ffmpeg.so
# vi /etc/php.ini
extension=ffmpeg.so





не хотел компилироваться ffmpeg_php, а нужен ffmpeg.so для PHP
ffmpeg-php-0.5.0/ffmpeg_frame.c:495: error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function) 


Тогда редактируем 
vi ffmpeg-php-0.x.0/ffmpeg_frame.c:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32 

или меняем “PIX_FMT_RGBA32″ на “PIX_FMT_RGB32″ в ffmpeg_frame.c


перекомпилируем
cd ffmpeg-php-0.x.0
make clean
./configure
make
make install
 

Friday, July 20, 2012

Ищем и убиваем zombie процессы


1)
top | grep zombie
225 processes: 1 running, 222 sleeping, 2 zombie
2)
ps aux | grep -w Z
root 3994 0,0 0,0 0 0 ?? Z 13июн11 16:23,02 <defunct>
root 3995 0,0 0,0 0 0 ?? Z 13июн11 13:43,28 <defunct>
Что касается «убийства», то их нельзя просто так убить. Самый правильный вариант – найти родительский процесс и перезапустить его. Некоторые могут посоветовать и перегрузиться, но это не выход.
Находим родительский процесс:
ps ajx | grep -w Z
root 3994 3992 3992 3992 0 Z ?? 16:23,02 <defunct>
root 3995 3992 3992 3992 0 Z ?? 13:43,28 <defunct>
3-я колонка как раз и показывает pid родительского процесса. Смотрим, что это за процесс:
ps auxww | grep 3992
root 3992 0,0 0,2 30664 9872 ?? Ss 13июн11 0:08,21 [exilog_agent] (perl5.12.3)
Собственно мы нашли виновника. Это exilog_agent. А дальше – либо просто прибиваем родительский процесс либо перезапускаем его:
#kill -9 3992
#top | grep zombie
#

Monday, July 16, 2012

Skype on CentOs

1. Install Skype

 CentOS/Red Hat (RHEL) 6.2/6.1/6

1.1 Change root user

su -
## OR ##
sudo -i

1.2 Install Needed Dependencies

yum install alsa-lib.i686 fontconfig.i686 freetype.i686 glib2.i686 libSM.i686 libXScrnSaver.i686 libXi.i686 libXrandr.i686 libXrender.i686 libXv.i686 libstdc++.i686 pulseaudio-libs.i686 qt.i686 qt-x11.i686 zlib.i686

Same command on multiple lines:
 
yum install alsa-lib.i686 fontconfig.i686 freetype.i686 \
glib2.i686 libSM.i686 libXScrnSaver.i686 libXi.i686 \
libXrandr.i686 libXrender.i686 libXv.i686 libstdc++.i686 \
pulseaudio-libs.i686 qt.i686 qt-x11.i686 zlib.i686

1.3 Download Latest Skype Static Package

cd /tmp
 
wget http://www.skype.com/go/getskype-linux-beta-static

1.4 Extract Skype

mkdir /opt/skype
 
tar xvf skype_static* -C /opt/skype --strip-components=1

1.5 Create libtiff.so.4 link

cd /usr/lib
 
ln -s libtiff.so.3 /usr/lib/libtiff.so.4

1.6 Create Launcher, Link icons, lang and sounds

ln -s /opt/skype/skype.desktop /usr/share/applications/skype.desktop
ln -s /opt/skype/icons/SkypeBlue_48x48.png /usr/share/icons/skype.png
ln -s /opt/skype/icons/SkypeBlue_48x48.png /usr/share/pixmaps/skype.png
 
touch /usr/bin/skype
chmod 755 /usr/bin/skype

Open /usr/bin/skype with text editor and add following content:
 
#!/bin/sh
export SKYPE_HOME="/opt/skype"
 
$SKYPE_HOME/skype --resources=$SKYPE_HOME $*

2. Use Skype

2.1 Start Skype

From command line use skype command
skype

 

Friday, June 1, 2012

View Manufacturer, Model and Serial number of the equipment using dmidecode


You can get information about the make, model and serial number of the equipment as shown below:
# dmidecode -t system
# dmidecode 2.9
SMBIOS 2.3 present.

Handle 0x0100, DMI type 1, 25 bytes
System Information
        Manufacturer: Dell Computer Corporation
        Product Name: PowerEdge 1750
        Version: Not Specified
        Serial Number: 1234567
        UUID: 4123454C-4123-1123-8123-12345603431
        Wake-up Type: Power Switch

Handle 0x0C00, DMI type 12, 5 bytes
System Configuration Options
        Option 1: NVRAM_CLR:  Clear user settable NVRAM areas and set defaults
        Option 2: PASSWD:  Close to enable password

Handle 0x2000, DMI type 32, 11 bytes
System Boot Information
        Status: No errors detected

Friday, May 11, 2012

How To Install RED5 Server on Centos


In this how to i will describe how to install RED5 server on Centos 5.3. This how to can be used to install RED5 server on Centos 4 and Fedora 8 – 11 as well. RED5 is open source flash server written in java supports streaming audio/video, recording client streams, shared objects, live stream publishing etc.

1) Download and Install Java

RED5 server depends on Java. CentOS 5.3 comes with OpenJDK 1.6 and install it using yum.
yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

2) Download and Install Ant & Ivy (Apache Project)

Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory.
cd /usr/src
wget http://mirrors.isu.net.sa/pub/apache//ant/binaries/apache-ant-1.8.2-bin.tar.bz2
tar jxvf apache-ant-1.8.2-bin.tar.bz2
mv apache-ant-1.8.2 /usr/local/ant
if not working download from here http://archive.apache.org/dist/ant/binaries/

cd /usr/src
svn co https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
cd ivy
ant jar
cp build/artifact/jars/ivy.jar /usr/local/ant/lib/
if ant is not working .. first do this
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin


after 



cd /usr/src
cd ivy
ant jar
cp build/artifact/jars/ivy.jar /usr/local/ant/lib/


3) Export Variables for Ant and Java

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
Also export these variables in /etc/bashrc to become available for every user login or for any terminal opens.
echo ‘export ANT_HOME=/usr/local/ant’ >> /etc/bashrc
echo ‘export JAVA_HOME=/usr/lib/jvm/java’ >> /etc/bashrc
echo ‘export PATH=$PATH:/usr/local/ant/bin’ >> /etc/bashrc

4) Download and Install RED5 Server

Here the latest version available for RED5 is 0.7 on site but download from google code using svn as the tarball of 0.7 on site is missing some of the files.
cd /usr/src
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
mv red5 /usr/local/
cd /usr/local/red5
ant prepare
ant dist
you will see a ton of lines, but you should get at last
BUILD SUCCESSFUL
that’s mean its install and now copy the conf directory from dist/ and test the red5 installation.
cp -r dist/conf .
./red5.sh
If it shows Installer service created in the last then everything is fine here, press ctrl+c and move to next step to create init script.

5) Init Script

Now we will create init script for red5 to start, stop and restart easily.
vi /etc/init.d/red5
download http://www.sohailriaz.com/downloads/red5.txt and copy / paste code in it. The init script code also be viewed below.
#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5
PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid
# Source function library
. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5
RETVAL=0
case “$1″ in
start)
echo -n $”Starting $PROG: ”
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG
fi
[ $RETVAL -eq 0 ] && success $”$PROG startup” || failure $”$PROG startup”
echo
;;
stop)
echo -n $”Shutting down $PROG: ”
killproc -p $PIDFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
;;
restart)
$0 stop
$0 start
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|status}”
RETVAL=1
esac
exit $RETVAL
Enable executable permission
chmod +x /etc/init.d/red5
Now start the service
/etc/init.d/red5 start
check status
/etc/init.d/red5 status
red5 (pid  XXXXX) is running…
again you can do stop, restart.

6) Test

Now test the RED5 installation by opening following URL in browser
http://yourip:5080/
you will see red5 page like this
red5_11
and demos can be find here.
http://yourip:5080/demos/
red5_21
You can use simple port tester tool that determines which ports the Flash Player is able to connect through to the Red5 server. Put your server address or IP in HOST when using port tester. You should get SUCCESS on RTMP or port 1935. If not please check your firewall.
http://yourip:5080/demos/port_tester.html
red5_3

7) ISSUE

When you run ./red5.sh, it will show you Installer service created. Thats mean everything runs fine and red5 server is up. But if you went to port_tester.swf using demos above or your application shows connections FAILS, this is an issue of RTMPT and RTMPTS. You can see it by running
/usr/local/red5/red5.sh
output trancated
[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPT server bean was not found
[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPS server bean was not found
output truncated
If you see this you have to uncomment the RTMPT and RTMPTS TomcatLoader in/usr/local/red5/conf/red5-core.xml
vi /usr/local/red5/conf/red5-core.xml
Search for a lines
<!– RTMPT –>
<!–
<bean id=”rtmpt.server” class=”org.red5.server.net.rtmpt.TomcatRTMPTLoader” init-method=”init” lazy-init=”true”>
Remove the <!– from start of <bean and –> from end of </bean>
Same goes for RTMPS
<!– RTMPS –>
<!–
<bean id=”rtmps.server” class=”org.red5.server.net.rtmps.TomcatRTMPSLoader” init-method=”init” lazy-init=”true”>
Remove the <!– from start of <bean and –> from end of </bean>
Restart the red5 services and connection fails problem will be fixed.
If you any question please use comments.