piwik

dijous, 4 de juliol del 2013

Untrusted connection doesn't contain I understand the risks.

@dtrager - in case the page you're trying to access is embedded in an iframe, right-click the error page, click on "this frame" > "show only this frame" and hopefully you can add an exception in the next step. this should only be necessary once if you choose to permanently store the exception.

dimecres, 12 de juny del 2013

myLVMbackup script with rotation 7 daily , 4 weekly, 4 monthly


With this is script, we set up a backup system for the mySQL database with rotation. The rotation schedule is the following, let's say we launched the script 5 months ago, today we will find in our daily directory 7 backups, in weekly directory we see the backups from last 4 mondays, and in monthly directory there are the backup of first monday of the past 4 months

In that case we make use of rsync with symbolic links, which allows us to perform incremental backups while keeping the availability of a full backup.

#!/bin/bash
#Copyright (C) 2013 Josep Manel Andrés Moscardó
#
#This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
#by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful, but
#WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT
#ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 
#Public License for more details.
#
#You should have received a copy of the GNU General Public License 
#along with this program. If not, see http://www.gnu.org/licenses/.
#

CAL=/usr/bin/cal
#Format= 2013-03-20
YESTERDAY=`date --date=yesterday +%Y-%m-%d`
#Int (where Monday is 1 and Sunday is 7)
TODAY=`date +%u`
#Format= 2013-03-20
SEVENDAYSAGO=`date --date '7 days ago' +%Y-%m-%d`
FOURWEEKSAGO=`date --date '28 days ago' +%Y-%m-%d`
FIVEWEEKSAGO=`date --date '35 days ago' +%Y-%m-%d`

#These variables will be used to find out which day is the backup from 5months ago that we have to remove
FIVEMONTHSAGOMONTH=`date --date='5 month ago' +%m`
FIVEMONTHSAGOYEAR=`date --date='5 month ago' +%Y`

#This function will give us the date of the first Monday of 5 months ago month.
function date5monthsago(){
  #Exact day for the backup from 5months ago
  local aux=`$CAL $FIVEMONTHSAGOMONTH $FIVEMONTHSAGOYEAR |
  awk '
  NR == 1 { next }
  NR == 2 { next }
  NF <= 5 { next }
  NF == 6 { print $1 ; exit }
  NF == 7 { print $2 ; exit }
  '`
  echo $aux
}

#AUX used for checking whether the backup from 28 days ago is the first Monday of the month backup, if so We'll keep it in monthly directory, if not, we'll remove it.
AUX=`date --date '35 days ago' +%d`

#Do daily backup and store it on /home/backup/daily
#To log Starting time
START=$(date +%s)
###########################################################
echo "#########################Starting myLVMbackup for dbMaster on dbBackup#####################" >> /home/backup/daily/mylvm-dbmaster-`date +%Y-%m-%d`.log 2>>1
###########################################################
mylvmbackup --socket=/var/run/mysqld/mysqld1.sock --innodb_recover --vgname=vgpool --lvname=lvdata --backuptype=rsync --relpath=replic_dbmaster --prefix=dbmaster  --backupdir=/home/backup/daily --datefmt=%Y-%m-%d --rsyncarg=" -a --link-dest=/home/backup/daily/dbmaster-${YESTERDAY}_mysql " >> /home/backup/daily/mylvm-dbmaster-`date +%Y-%m-%d`.log 2>&1
###########################################################
###########################################################

#To log Finishing time
END=$(date +%s)
TOTALTIME=$(( $END - $START ))
echo "############################################################################################" >> /home/backup/daily/mylvm-dbmaster-`date +%Y-%m-%d`.log
echo "Start time:$START, finish time:$END, seconds:$TOTALTIME" >> /home/backup/daily/mylvm-dbmaster-`date +%Y-%m-%d.log`


#We will check if today is Monday, if so we'll move last monday's backup 1 directory up
if [ "$TODAY" -eq "1" ]; then
  if [ -d "/home/backup/daily/dbmaster-${SEVENDAYSAGO}_mysql"  ]; then
    mv /home/backup/daily/dbmaster-${SEVENDAYSAGO}_mysql /home/backup/weekly/
    mv /home/backup/daily/mylvm-dbmaster-${SEVENDAYSAGO}.log /home/backup/weekly/
  fi
  #Checking for a backup older than 28 days and also from first Monday of the month.If the backup from 28 days ago is not the firstMondayOfTheMonth we'll expire, or else keep it in monthly directory.  
  if [ -d "/home/backup/weekly/dbmaster-${FIVEWEEKSAGO}_mysql" ]; then
    #Is it from first Monday of the month?
    if [ "$AUX" -le "7" ]; then
      mv /home/backup/weekly/dbmaster-${FIVEWEEKSAGO}_mysql /home/backup/monthly/
      mv /home/backup/weekly/mylvm-dbmaster-${SEVENDAYSAGO}.log /home/backup/monthly/
      #Execute function to find out exact date for 5 months ago
      FIVEMONTHSAGODAY=$(date5monthsago)
      #Expire backups older than 4 months ago. Note that FIVEMONTHSAGODAY has only 1 digit,that is why we add "0" before.
      if [ -d "/home/backup/monthly/dbmaster-${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-${FIVEMONTHSAGODAY}_mysql" ]; then
        rm -rf /home/backup/monthly/dbmaster-${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-0${FIVEMONTHSAGODAY}_mysql
        rm /home/backup/monthly/mylvm-dbmaster-${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-0${FIVEMONTHSAGODAY}.log
      fi
    else
      rm -rf /home/backup/weekly/dbmaster-${FIVEWEEKSAGO}_mysql
      rm /home/backup/weekly/mylvm-dbmaster-${FIVEWEEKSAGO}.log
    fi
  fi

#If today is NOT Monday we'll expire old daily backups
else
  #Is there a backup from 1weekago? If so we'll exxpire it
  if [ -d "/home/backup/daily/dbmaster-${SEVENDAYSAGO}_mysql" ]; then
    rm -rf /home/backup/daily/dbmaster-${SEVENDAYSAGO}_mysql
    #Remove log file also
    rm /home/backup/daily/mylvm-dbmaster-${SEVENDAYSAGO}.log
  fi    
fi
rm /root/debug-${SEVENDAYSAGO}.log

###################################################################
###Code for dbslave replication backup#############################
#To log Starting time
START2=$(date +%s)
###################################################################
echo "#########################Starting myLVMbackup for dbSlave on dbBackup#####################" >> /home/backup/daily/mylvm-dbslave-`date +%Y-%m-%d`.log 2>>1
###################################################################
mylvmbackup --socket=/var/run/mysqld/mysqld2.sock --innodb_recover --vgname=vgpool --lvname=lvdata --backuptype=rsync --relpath=replic_dbslave --prefix=dbslave  --backupdir=/home/backup/daily --datefmt=%Y-%m-%d --rsyncarg=" -a --link-dest=/home/backup/daily/dbslave-${YESTERDAY}_mysql " >> /home/backup/daily/mylvm-dbslave-`date +%Y-%m-%d`.log 2>>1

#To log Finishing time
END2=$(date +%s)
TOTALTIME2=$(( $END2 - $START2 ))
echo "############################################################################################" >> /home/backup/daily/mylvm-dbslave-`date +%Y-%m-%d`.log
echo "Start time:$START2, finish time:$END2, seconds:$TOTALTIME2" >> /home/backup/daily/mylvm-dbslave-`date +%Y-%m-%d.log`

#We will check if today is Monday, if so we ll move last mondays backup 1 directory up
if [ "$TODAY" -eq "1" ]; then
  if [ -d "/home/backup/daily/dbslave-${SEVENDAYSAGO}_mysql"  ]; then
    mv /home/backup/daily/dbslave-${SEVENDAYSAGO}_mysql /home/backup/weekly/
    mv /home/backup/daily/mylvm-dbslave-${SEVENDAYSAGO}.log /home/backup/weekly/
  fi
  #Checking for a backup older than 28 days and also from first Monday of the month.If the backup from 28 days ago is not the firstMondayOfTheMonth we ll expire, or else keep it in monthly directory.  
  if [ -d "/home/backup/weekly/dbslave-${FIVEWEEKSAGO}_mysql" ]; then
    #Is it from first Monday of the month?
    if [ "$AUX" -le "7" ]; then
      mv /home/backup/weekly/dbslave-${FIVEWEEKSAGO}_mysql /home/backup/monthly/
      mv /home/backup/weekly/mylvm-dbslave-${SEVENDAYSAGO}.log /home/backup/monthly/
      #Execute function to find out exact date for 5 months ago
      FIVEMONTHSAGODAY=$(date5monthsago)
      #Expire backups older than 4 months ago. Note that FIVEMONTHSAGODAY has only 1 digit,that is why we add "0" before.
      if [ -d "/home/backup/monthly/dbslave-${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-${FIVEMONTHSAGODAY}_mysql" ]; then
        rm -rf /home/backup/monthly/dbslave-${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-0${FIVEMONTHSAGODAY}_mysql
        rm /home/backup/monthly/mylvm-dbslave-${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-0${FIVEMONTHSAGODAY}.log
      fi
    else
      rm -rf /home/backup/weekly/dbslave-${FIVEWEEKSAGO}_mysql
      rm /home/backup/weekly/mylvm-dbslave-${FIVEWEEKSAGO}.log
    fi
  fi

#If today is NOT Monday we ll expire old daily backups
else
  #Is there a backup from 1weekago? If so we will expire it
  if [ -d "/home/backup/daily/dbslave-${SEVENDAYSAGO}_mysql" ]; then
    rm -rf /home/backup/daily/dbslave-${SEVENDAYSAGO}_mysql
    #Remove log file also
    rm /home/backup/daily/mylvm-dbslave-${SEVENDAYSAGO}.log
  fi    
fi
rm /root/debug-slave${SEVENDAYSAGO}.log

dimecres, 5 de juny del 2013

How to avoid apparmor errors when running multiple mysql instances

When Apparmor complains about deny access to some directory, like in this case with mysql data paths and mysql.sock, we'll have to add those paths to the apparmor config file for mysql.

root@server10124:~# vi /etc/apparmor.d/usr.sbin.mysqld
  /var/run/mysqld/mysqld.pid w,
  /var/run/mysqld/mysqld.sock w,
  /var/run/mysqld/mysqld1.pid w,
  /var/run/mysqld/mysqld1.sock w,
  /var/run/mysqld/mysqld2.pid w,
  /var/run/mysqld/mysqld2.sock w,
  /run/mysqld/mysqld.pid w,
  /run/mysqld/mysqld.sock w,
  /run/mysqld/mysqld1.pid w,
  /run/mysqld/mysqld1.sock w,
  /run/mysqld/mysqld2.pid w,
  /run/mysqld/mysqld2.sock w,
  /home/replic_dbmaster/** rwk,
  /home/replic_dbmaster/ r,
  /home/replic_dbslave/** rwk,
  /home/replic_dbslave/ r,

Then, all we have to do is reload Apparmor and start up mysql instances.

root@server10124:~# service apparmor restart

Piwik installation

Since we are hosting many websites, we are going to need to define an Apache VirtualHost with the following configuration.

vi /etc/apache2/sites-available/piwik.arruixaqueplou.org

     ServerAdmin webmaster@piwik.arruixaqueplou.org
     ServerName piwik.arruixaqueplou.org
     ServerAlias piwik.arruixaqueplou.org
     DocumentRoot /var/www/public_html/
     ErrorLog /var/www/public_html/logs/error.log
     CustomLog /var/www/public_html/logs/access.log combined

After that, we will need to enable the site and restart apache:

a2ensite piwik.arruixaqueplou.org
service apache2 reload

We are going to need the latest Piwik version, available through 
their web servers, so we will need to go to the Piwik root directory 
were the installation is going to take place and pull the latest 
version.

wget http://piwik.org/latest.zip
unzip latest.zip -d public_html

Assign the right permissions for the web server:

chown -R www-data:www-data public_html/

Before running Piwik's installation script, we need to change the permissions of several directories. Piwik requires these permissions to remain set to function properly. Issue the following commands:

chmod a+w /var/www/public_html/tmp
chmod a+w /var/www/public_html/config

Now we are ready to go through web browser web based installation process by typing piwik.arruixaqueplou.org into the browser.

mySQL users
We had added a piwikuser accound with full privileges.

mysql> create user 'piwikuser'@'localhost' identified by 'piwikpass!';
mysql> grant all privileges on piwik.* to 'piwikuser'@'localhost' with grant option;


The next screen will ask us to create a Piwik account with full privileges.

How to allow zabbix user to execute certain command as a privilege user


We just need to add the following line to /etc/sudoers

1
zabbix ALL=(root) NOPASSWD:/bin/bash /etc/zabbix/scripts/hparray.sh
After NOPASSWD: we'll place the commands we want to allow.

Monitor swap space in Zabbix

#Monitoring % Swap space
UserParameter=swap.percentage, free|tail -n -1|awk '{print ($3/$2)*100}'

Script that monitors the status of a HP physical RAID


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash

PHDRIVE[1]=`hpacucli ctrl all show config detail | grep "physicaldrive 1I:1:1" | awk '{print $10}' | sed 's/)//' | sed -e 's/[\t ]//g;/^$/d'`
PHDRIVE[2]=`hpacucli ctrl all show config detail | grep "physicaldrive 1I:1:2" | awk '{print $10}' | sed 's/)//' | sed -e 's/[\t ]//g;/^$/d'`
PHDRIVE[3]=`hpacucli ctrl all show config detail | grep "physicaldrive 1I:1:3" | awk '{print $10}' | sed 's/)//' | sed -e 's/[\t ]//g;/^$/d'`
PHDRIVE[4]=`hpacucli ctrl all show config detail | grep "physicaldrive 1I:1:4" | awk '{print $10}' | sed 's/)//' | sed -e 's/[\t ]//g;/^$/d'`
#PHDRIVE[1]="FAULT"
#PHDRIVE[2]="FAULT"
#PHDRIVE[3]="OK"
#PHDRIVE[4]="OK"
#echo ${PHDRIVE[1]}

#Meaning of the variable ALARM, 
# 0 ----------- No alarms, everything OK
# 1 ----------- Disk 1 doesn't have STATUS OK
# 2 ----------- Disk 2 doesn't have STATUS OK
# 3 ----------- Disk 3 doesn't have STATUS OK
# 4 ----------- Disk 4 doesn't have STATUS OK
ALARM=0

for i in `seq 1 4`;
do
  if [ "${PHDRIVE[$i]}" != "OK" ]; then
    ALARM=$i
  fi
done

echo $ALARM

How to list all the applications that had been installed through apt-get

( zcat $( ls -tr /var/log/apt/history.log*.gz ) ; cat /var/log/apt/history.log ) | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | egrep '^Commandline:' | sed 's/Commandline: //'

How to send emails through command line

echo -e "Subject: Here is gonna be the subject\nFrom: backup@arruixaqueplou.org\nTo: alarm@arruixaqueplou.org\n\$(`cat /home/backup/daily/mylvm-$(date +%Y-%m-%d.log) && cat /home/backup/web2/mysql/mysql_$(date +%Y-%m-%d)/backup_mysql_$(date +%Y-%m-%d) && cat /home/backup/web4/mysql/mysql_$(date +%Y-%m-%d)/backup_mysql_$(date +%Y-%m-%d) && cat /home/backup/web2/gluster/gluster_$(date +%Y-%m-%d)/backup_gluster_$(date +%Y-%m-%d)`) " | sendmail -t

Sed hacks.

How to remove empty lines from a file:
sed '/^$/d' file.txt
Remove commented lines from a specific file
sed 's/^#.*//' file.txt
Above command will replace # 'ed lines by empty lines, in case we want to merge both steps into a single command, we'll issue the following command.
sed -e 's/^#.*//;/^$/d' file.txt

MySQL commands

==========================
Backup database using dump
==========================
1.- Backup
mysqldump -u root xcms > new-xcms.sql

2.- Restore
(Make sure we have created the corresponding database)
mysql -u root -proot xcms < new-xcms.sql

3.-Rename DB
---------------
mysql -e "CREATE DATABASE \`new_database\`;"

for table in `mysql -B -N -e "SHOW TABLES;" old_database`
do
  mysql -e "RENAME TABLE \`old_database\`.\`$table\` to \`new_database\`.\`$table\`"
done
mysql -e "DROP DATABASE \`old_database\`;"
----------------



4.-Create DB
create database old_xcms;

5.- Backup triggers and stored procedures
mysqldump -u root --all-databases --triggers --routines -d -t > dbMasterProc.sql

6.- Create user and grant all privileges
mysql> create user 'root'@'172.16.%';
mysql> grant all privileges on *.* to 'root'@'172.16.%';
mysql> show grants;
+--------------------------------------------------+
| Grants for root@172.16.%                         |
+--------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' |
+--------------------------------------------------+
1 row in set (0.00 sec)

7.- Skip execution of one row in replication servers:
mysql> set global sql_slave_skip_counter = 1;

############
Show columns
############
mysql> show columns from tbl_gamechat;
+----------------+----------------------+------+-----+---------+----------------+
| Field          | Type                 | Null | Key | Default | Extra          |
+----------------+----------------------+------+-----+---------+----------------+
| GCHT_iID       | int(10) unsigned     | NO   | PRI | NULL    | auto_increment |
| GCHT_TLST_iID  | int(10) unsigned     | NO   | MUL | 0       |                |
| GCHT_GAM_iID   | int(10) unsigned     | NO   | MUL | 0       |                |
| GCHT_PLY_iID   | int(10) unsigned     | NO   | MUL | 0       |                |
| GCHT_cText     | varchar(255)         | NO   |     |         |                |
| GCHT_dDate     | timestamp            | YES  | MUL | NULL    |                |
| GCHT_iChatType | smallint(5) unsigned | NO   |     | 0       |                |
+----------------+----------------------+------+-----+---------+----------------+

##########
See rows
##########

mysql> select * from tbl_gamechat where GCHT_iID='24875';
+----------+---------------+--------------+--------------+------------+---------------------+----------------+
| GCHT_iID | GCHT_TLST_iID | GCHT_GAM_iID | GCHT_PLY_iID | GCHT_cText | GCHT_dDate          | GCHT_iChatType |
+----------+---------------+--------------+--------------+------------+---------------------+----------------+
|    24875 |          1148 |       756640 |      1029050 |            | 2013-02-19 12:31:03 |              0 |
+----------+---------------+--------------+--------------+------------+---------------------+----------------+
1 row in set (0.00 sec)

##########
Delete row
##########

mysql> delete  from tbl_gamechat where GCHT_iID='24875';

dimarts, 4 de juny del 2013

Usefull hacks for grep command.

How to count the number of lines that match with a specific pattern in a file:
grep -c Josep /etc/passwd
Using -v option, we'll be inverting the results. The number of lines that do not match the pattern will be shown.
grep -cv Josep /etc/passwd
Ignoring case sensitive:
grep -i josep /etc/passwd

Searching through all subdirectories the files that inside them have at least one occurrence of the pattern.
grep -r mysql /home/josep

divendres, 31 de maig del 2013

Setting up external monitor as a primary with Ubuntu, GNOME

Since I am currently working with an ultrabook, which has a very tiny monitor, I attached an external one. So, if we want to get it working as a primary monitore, where the menu bar and the buttons will be displayed, we just have to issue the following command:

xrandr --output VGA-0 --primary

In my case the external monitor is named VGA-0, but you might have different name for it, all you have to do is TAB after xrandr --output and it will prompt you for the different options you have.

Source: http://alt236.blogspot.com/2012/01/setting-up-second-monitor-as-primary.html

dimarts, 28 de maig del 2013

Monitoritzar Gluster 3.2 amb Zabbix

Per la informacio que he trobat, crec que amb la versio 3.2 sols tenim disponible dos comandaments per a monitoritzar l'estat dels volums i la connectivitat amb els "peers". Per tant, aci vos deixe els dos comandament que he afegit a Zabbix.

Amb aquest primer, el que fem es agafem l'estat del volum i imprimim un "1" si es "Started" o un "0" per a la resta de casos.

#Monitoring GlusterFS
UserParameter=glusterfs.status,sudo gluster volume info | grep Status | awk '{print $2}' | sed "s/\s//g" | sed "s/Started/1/" | awk '{ if ($1 == 1) print $1; else printf "0\n" }'



Aci el que fem es comprovar que tots els "peers" estan connectats al volum del server en el que executem Gluster. "1" en el cas que estiguen, "0" per a la resta
 
UserParameter=glusterfs.peer,sudo gluster peer status | grep State | awk '{print $5}' | sed 's/(//g' | sed 's/)//g' | sed "s/\s//g" | paste -sd " " | awk '{ if ($1 == "Connected" && $2 == "Connected" && $3 == "Connected") print "1"; else print "0"}'

dimarts, 21 de maig del 2013

How to install Oracle VM VirtualBox Extension Pack

USB 2.0 is currently enabled for this virtual machine. However, this requires the Oracle VM VirtualBox Extension Pack

This is the message we get when trying to enable USB 2.0 support from Virtual Box. Everything we need to do is go to the following link, and download the package shown bellow.

VirtualBox 4.2.12 Oracle VM VirtualBox Extension Pack  All supported platforms

https://www.virtualbox.org/wiki/Downloads

How to enable USB to the virtual machines on Virtual Box

This is the error we get when we want to go to "Settings".
VirtualBox is not currently allowed to access USB devices. You can change this by adding your user to the 'vboxusers' group

We just need to issue the following command in order to add the current user to vboxusers group.

sudo usermod -aG vboxusers josep

Where "josep" is our current user.
Right after that, we'll need to log out and log back in to see the changes applied.

dimecres, 15 de maig del 2013

Hidden menu bar in Firefox

Newer version of Firefox come with a single "Firefox" menu button, to switch between old-style and new format:
Right click on an empty section of the Tab strip, and either select or deselect "Menu bar" in the pop-up menu.

Source: https://support.mozilla.org/en-US/kb/what-happened-to-the-file-edit-and-view-menus

dimarts, 14 de maig del 2013

Llibreria h264enc necessaria per a codificar en el Kdenlive

El cas és que quan instal·les l'editor de vídeo Kdenlive et cal una llibreria per a poder codificar els vídeos als formats MPEG-4, h264

libffmpeg
libffmpegthumbnailer4
ffmpeg
libx264-85

libxvidcore4
libxvid
h264enc
mencoder
libmlt++1
libmlt++-dev

diumenge, 12 de maig del 2013

How to deploy an rsyslog central server in GNU/Linux


Rsyslog Central Server

Server side

The package we are gonna need to get installed is rsyslog-ng, available through main software distribution application for every distro.
The layout for our central syslog server is going to be the following:


on the server side we only need to modify /etc/rsyslog.conf by uncomment two modules and adding some rules:




#################
#### MODULES ####
#################

$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog   # provides kernel logging support (previously done by rklogd)
#$ModLoad immark  # provides --MARK-- message capability

# provides UDP syslog reception
#$ModLoad imudp.so
#$UDPServerRun 5514
#$UDPServerAddress 172.16.65.163

# provides TCP syslog reception
$ModLoad imtcp.so
$InputTCPServerRun 5514

We will define also a template to generate the logs from remote servers depending on the IP, and also if the process that generates the log matches with one of the processes we want, we will create a separate syslog file preceded by process name.

##############
##Templates###
##############
# This one is the template to generate the log filename dynamically, depending on the client's IP address.
$template externalsyslog,"/home/backup/rsyslog_server/%fromhost-ip%/syslog.log"
$template TraditionalFormat,"%timegenerated% %fromhost-ip% %syslogtag%%msg:::drop-last-lf%\n"

$template filterByProgramName,"/home/backup/rsyslog_server/%fromhost-ip%/%programname%_syslog.log"

if $programname == 'process1' then ?filterByProgramName;TraditionalFormat
if $programname == 'process2' then ?filterByProgramName;TraditionalFormat
if $programname == 'process3' then ?filterByProgramName;TraditionalFormat
if $programname == 'process4' then ?filterByProgramName;TraditionalFormat
if $programname == 'process5' then ?filterByProgramName;TraditionalFormat
if $programname == 'process6' then ?filterByProgramName;TraditionalFormat
if $programname == 'process7' then ?filterByProgramName;TraditionalFormat
if $programname == 'process8' then ?filterByProgramName;TraditionalFormat

# Log all messages to the dynamically formed file. Now each clients log (172.16.65.166, 172.16.65.167,etc...), will be under a separate directory which is formed by the template FILENAME.
*.* -?externalsyslog;TraditionalFormat

We must grant the right permissions to the directory where rsyslog will be writing its logs. syslog:syslog

Clients

We must forward the syslog messages to server's IP.

#Forward log to remote server
*.* @@172.16.70.3:5514
#Forward log to localhost
*.* @@localhost:514


Logrotate

Linked to syslog server we had set logrotate to rotate the logs weekly. That is why we added the following entries to /etc/logrotate.d/rsyslog

Here we are rotating all the logs generated by different processes from every client. For example, for 172.16.65.161 we are going to be rotating syslog.log,  process2_syslog.log, process3_syslog.log, process4syslog.log, process1_syslog.log

root@ZNNH003:~# cat /etc/logrotate.d/rsyslog
/var/log/syslog
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
postrotate
reload rsyslog >/dev/null 2>&1 || true
endscript
}


/home/backup/rsyslog_server/127.0.0.1/syslog.log
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
postrotate
reload rsyslog >/dev/null 2>&1 || true
endscript
}
/home/backup/rsyslog_server/127.0.0.1/process4_syslog.log
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
postrotate
reload rsyslog >/dev/null 2>&1 || true
endscript
}
/home/backup/rsyslog_server/127.0.0.1/process3_syslog.log
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
postrotate
reload rsyslog >/dev/null 2>&1 || true
endscript
}

dilluns, 29 d’abril del 2013

How do I get the full path to display in Nautilus?


How can I get the full path to display in Nautilus so I can copy it to the clipboard and/or type a path manually?


Ctrl+L


Source: http://ubuntuforums.org/showthread.php?t=1653259

diumenge, 24 de febrer del 2013

Removing Joomla plugin using phpMyAdmin

After moving my joomla website from the previous hosting provider to the new one, I had ran into many troubles, I got it fixed, after all, and the next issue that stopped me was some installed plugins weren't working, I wasn't even able to uninstall them, so the last chance was going to phpMyAdmin and removing one row from jos_plugins table, I just removed the one that belonged to the specific plugin I wanted to remove, then I installed the plugin back.

It worked great! 

dimarts, 12 de febrer del 2013

How to install KVM on Debian

Since I need it for training purposes, RHCSA, I am going to install the Red Hat based virtualization platform on Debian. Choosing that platform is good if your station support virtualization, KVM, for Intel version we should check out cpuinfo file using the following command:
grep --color vmx /proc/cpuinfo
For AMD based processor will follow with this:
grep --color svm /proc/cpuinfo
The needed packages for setting up the system are:
aptitude install qemu-kvm libvirt-bin virtinst kvm virt-viewer virt-manager

Now we only need to get the user we want to use VM added to libvirt and kvm groups:
adduser ouruser libvirt
adduser ouruser kvm

dijous, 17 de gener del 2013

How to compress an entire directory on GNU/Linux tar

tar -cvf filename.tar.gz directory_to_compress/

How to mount ISO image into GNU/Linux filesystem

You must be logged as a root and execute the following command, assuming that you have a mount point directory (/mnt/disk1) already created.

mount -o loop disk1.iso /mnt/disk

Source: http://www.cyberciti.biz/tips/how-to-mount-iso-image-under-linux.html

dimecres, 16 de gener del 2013

Enable PAE support for the CentOS virtual image, on VirtualBox

When trying to dun a CentOS image in my VirtualBox, I got the following error.

This kernel requires the following features not present on the CPU:
PAE
Unable to boot - please use a kernel appropiate for your CPU.

Due to the new kernel version of CenOS 6, we are required to have PAE support enabled in the actual virtual machine. To proceed with this we just need to run the following console command, which sets to On mode PAE support for the current machine.

VBoxManage modifyvm SlackVM2 --pae on
Info taken from: http://slackblogs.blogspot.cz/2011/06/pae-support-on-virtualbox.html