Analytic

Thursday, October 24, 2013

QMail Changing send IP

The default IP for outgoing connections can be set using the "ip" utility. Check how routing is configured on the server:

assume we have two network interfaces vnet0:0 (192.168.175.100)  and vnet0:1 (192.168.175.200) and 192.168.175.1 is gateway:

[root@server]#/sbin/ip route

192.168.175.0/24 dev venet0  scope host
169.254.0.0/16 dev venet0  scope link
default via 199.168.175.1 dev venet0



If no "src" is listed in the "ip" output for the default route, the main IP on the interface is used for outgoing connections.

To change Plesk default Mail IP address, check ifconfig on the server first as :


lo        Link encap:Lokale Schleife 
          inet Adresse:127.0.0.1  Maske:255.0.0.0
          inet6 Adresse: ::1/128 Gültigkeitsbereich:Maschine
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:898825 errors:0 dropped:0 overruns:0 frame:0
          TX packets:898825 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:0
          RX bytes:2333074597 (2224.9 Mb)  TX bytes:2333074597 (2224.9 Mb)

venet0    Link encap:UNSPEC  Hardware Adresse 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
          inet Adresse:127.0.0.1  P-z-P:127.0.0.1  Bcast:0.0.0.0  Maske:255.255.255.255
          UP BROADCAST PUNKTZUPUNKT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:69429506 errors:0 dropped:0 overruns:0 frame:0
          TX packets:109230137 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:0
          RX bytes:19231956377 (18341.0 Mb)  TX bytes:136258969119 (129946.6 Mb)

venet0:0  Link encap:UNSPEC  Hardware Adresse 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
          inet Adresse:192.168.175.100  P-z-P:
92.168.175.100  Bcast:0.0.0.0  Maske:255.255.255.255
          UP BROADCAST PUNKTZUPUNKT RUNNING NOARP  MTU:1500  Metric:1

venet0:1  Link encap:UNSPEC  Hardware Adresse 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
          inet Adresse:
192.168.175.200  P-z-P:
92.168.175.200  Bcast:0.0.0.0  Maske:255.255.255.255
          UP BROADCAST PUNKTZUPUNKT RUNNING NOARP  MTU:1500  Metric:1



Change the mail IP address through following command as :

[root@server]#/sbin/ip route change default via 192.168.175.1 dev venet0:1 src 192.168.175.200


now verify the mail IP address :

[root@server]#/sbin/ip route

192.168.175.0/24 dev venet0  scope host
169.254.0.0/16 dev venet0  scope link
default via 192.168.175.1 dev venet0  src192.168.175.200



If "ip route" command says nothing about gateway or gateway is 0.0.0.0, for example like this one:

[root@server]#/sbin/ip route

127.0.0.0/8 dev lo  scope link
default dev venet0  scope link 



you can use this command:

[root@server]#/sbin/ip route change default via 192.168.175.100 dev venet0 src 192.168.175.200

Thursday, September 5, 2013

Useful commands with ffmpeg

Converting mp4 to flv:

ffmpeg -i INPUT.mp4  -vcodec copy -acodec aac -strict experimental -ac 2 -ar 44100 -ab 192k OUTPUT.flv



Deleting logo from video:

ffmpeg -sameq -i INPUT.flv -vf "delogo=x=10:y=10:w=80:h=60:band=80:show=0" -vcodec flv -acodec copy OUTPUT.flv

this command deletes the logo which exists at x=10 and y=10 (x=0 and y=0 is top left). h is height and w is width. You can use show=1 to see the location of deleted logo.

Crop video:
ffmpeg -sameq -i INPUT.flv -vf "crop=WIDTH:HEIGHT"
OUTPUT.flv


Thursday, July 11, 2013

Amazon AWS - Changing dynamically Apache Log File name based on Hostname

Change your vhost apache config as follow (the LogFormat writes correct client IPs to log):


LogFormat "\"%{X-Forwarded-For}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_new
CustomLog "|cat >> /shared/log/apache2/`hostname`-access.log" combined_new

Tuesday, July 2, 2013

Mysqldump only tables with certain prefix / Mysqldump wildcards

This commans will dump the tables with prefix PREFIX:

mysql DATABASE -u USERNAME -p -e 'show tables like "PREFIX%"' | grep -v Tables_in | xargs mysqldump DATABASE -u USERNAME -p > DUMP.sql

Monday, June 17, 2013

Install ia32-libs in Debian Wheezy

Since Wheezy introduces multiarch, the ia32-libs package in now deprecated. It is now possible to install 32bit packages directly:
 
dpkg --add-architecture i386 # enable multi-arch
apt-get update
apt-get install libc6:i386 # install base 32bit libraries

Monday, May 13, 2013

Delete files older X days or minutes

This command deletes all files /PATH/TO/FOLDER/YOUR_FILENAME_PATTERN
those older than 45 days:

find /PATH/TO/FOLDER/ -name YOUR_FILENAME_PATTERN -type f -mtime +45  -delete

and this for deleting files older than 30 minutes:

find /PATH/TO/FOLDER/ -name YOUR_FILENAME_PATTERN -type f -mmin +30  -delete

Tuesday, April 30, 2013

How to free Port 80 that already used in Windows 8

Solution 1:
  • Launch RegEdit
  • Find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
  • Change the value of "start" to 4 (disabled)
  • Reboot your computer

Solution 2:

  • Go to Device Manager, select “show hidden devices” from menu/view, go to “Non-Plug and Play Driver”/HTTP, double click it to disable it (and disable or manual some services depended on it).
  • Reboot and use

Tuesday, April 16, 2013

Nagios PNP Warning after upgrade php to 5.3

I got these error and warnings from Nagios after I upgrade my PHP:


Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/nagios/share/pnp/include/function.inc.php on line 1032

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europa/Berlin' for 'Debian/Squeeze' instead in /usr/local/nagios/share/pnp/include/function.inc.php on line 557


Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.php 

 To solve this problem you must edit this file: usr/local/nagios/share/pnp/include/function.inc.php

line 556: date_default_timezone_set('UTC');

line 1033: $pdf = new PDF('P', 'mm', 'A4');

line 1543: if($level == 2 && $type == "complete" && preg_match("/^NAGIOS_/",$tag)){






Friday, February 1, 2013

MySQL comparing timestamp with date


To find records older than 30 days using timestamp field:

Select from TableName where from_unixtime(tstamp) < (NOW() - INTERVAL 30 day);



Thursday, January 31, 2013

Extracting the string between two patterns in a file

Supose the file contains this phrase: That is just a test for you

I need to extract the patterns between the words is and test:


 sed -e 's/.*is//' -e 's/test.*$//' /Path-To-Your-File/yourfile.txt

and the result is:

  just a

Tuesday, January 22, 2013

Find out MySQL Time & Zone

for global and session time zone run this query:


mysql> SELECT @@global.time_zone, @@session.time_zone;


for get current time from MySQL Server run this query:

mysql> select now() ;