HP DL585 G7 a correr o Webmin no CentOs 6 causa erros de ACPI

Ao instalar o webmin num HP DL585 G7 a correr o CentOs 6 o servidor dá mensagens de erro ACPI de 10 em 10minutos. Segundo o site da HP este é um erro normal neste modelo quando se utiliza RHEL 6 e que não causa problemas.

May  4 18:01:57 ccems-web5 kernel: ACPI Error: SMBus or IPMI write requires Buffer of length 42, found length 20 (20090903/exfield-286)
May  4 18:01:57 ccems-web5 kernel: ACPI Error (psparse-0537): Method parse/execution failed [\_SB_.PMI0._PMM] (Node ffff88043b101448), AE_AML_BUFFER_LIMIT
May  4 18:01:57 ccems-web5 kernel: ACPI Exception: AE_AML_BUFFER_LIMIT, Evaluating _PMM (20090903/power_meter-341)

Apesar de ser um erro normal é muito chato receber mails de 10 em 10mins com as mensagens de erro…

A solução passa por desativar o ACPI. Existem duas formas de o fazer, retirando o serviço do arranque e parando-o ou alterando o grub para desligar o ACPI na kernel.

Desligar o ACPI Soft-Off com o chkconfig no arranque:

chkconfig --level 2345 acpid off
service acpid stop

Ou então desativar completamente o ACPI editando o grub.conf:

vim /boot/grub/grub.conf

Acrescentar acpi=off aos parâmetros de boot da kernel. Exemplo:

kernel /vmlinuz-2.6.18-36.el5 ro root=/dev/VolGroup00/LogVol00 console=ttyS0,115200n8 acpi=off

 

Fonte:
http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c02642731&lang=en&cc=us&taskId=101&prodSeriesId=4194641&prodTypeId=15351
http://www.centos.org/docs/5/html/5.1/Cluster_Administration/s2-apci-disable-boot-CA.html
http://www.centos.org/docs/5/html/5.1/Cluster_Administration/s2-apci-disable-chkconfig-CA.html
http://sites.google.com/site/boxxit/linux-server/myserver (ACIP fails with “ACPI Error (psparse-0537)” so it has to be disabled.)

CentOs 6 erros no NetworkManager

Ao fazer boot o message log do servidor apresentava alguns erros no NetworkManager.

May  4 14:55:30 ccems-web5 NetworkManager[4445]: <error> [1336139730.352197] [nm-manager.c:1360] user_proxy_init(): could not init user settings proxy: (3) Could not get owner of name 'org.freedesktop.NetworkManagerUserSettings': no such name
May  4 14:55:30 ccems-web5 NetworkManager[4445]: <error> [1336139730.525895] [nm-manager.c:1360] user_proxy_init(): could not init user settings proxy: (3) Could not get owner of name 'org.freedesktop.NetworkManagerUserSettings': no such name

Depois de ler algumas páginas concluí que a causa do problema do NetworkManager foi, provavelmente, por ter mexido nas definições das placas de rede (/etc/sysconfig/network-scripts/ifcfg-eth[01]) sem ser através do gestor de rede.

Para gerir a rede da forma normal é necessário alterar os ficheiros de configuração ifcfg e adicionar:

NM_CONTROLLED="no"

e depois desligar o NetworkManager e ligar a network:

chkconfig NetworkManager off
chkconfig network on
service NetworkManager stop
service network start

 

Fonte:

https://www.centos.org/modules/newbb/viewtopic.php?topic_id=36992

Using the Webmin YUM repository

If you like to install and update Webmin via RPM, create the /etc/yum.repos.d/webmin.repo file containing :

[Webmin]
 name=Webmin Distribution Neutral
 #baseurl=http://download.webmin.com/download/yum
 mirrorlist=http://download.webmin.com/download/yum/mirrorlist
 enabled=1

You should also fetch and install my GPG key with which the packages are signed, with the commands :

wget http://www.webmin.com/jcameron-key.asc
rpm --import jcameron-key.asc

You will now be able to install with the command :

yum install webmin

All dependencies should be resolved automatically.

Implementar quotas de disco

First do:

yum install quota

Also you have to edit the edit the /etc/fstab and add:

usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0

If you do not need to set quotas for groups then omit the grpjquota=aquota.group, then in my fstab I have this:

UUID=b4a0be80-3a47-4609-af72-a30b7102593b /                       ext4    defaults        1 1
UUID=8f7f1ed5-4726-471f-a48e-76088180c099 /boot                   ext4    defaults        1 2
UUID=11315782-76c7-4380-b968-0bcef2f4b832 /home                   ext4    defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0        1 2
UUID=4dcacd31-c789-4406-8a71-fe1579ac5f4f swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults,nosuid,noexec,rw         0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/var/tempFS             /tmp                    ext4    loop,nosuid,noexec,rw   0 0

To create the quota files (aquota.user and aquota.group) on the file system, use the -c option of the quotacheck command. For example, if user and group quotas are enabled for the /home file system, create the files in the /home directory:

quotacheck -cug /home

The -c option specifies that the quota files should be created for each file system with quotas enabled, the -u option specifies to check for user quotas, and the -g option specifies to check for group quotas.

If neither the -u or -g options are specified, only the user quota file is created. If only -g is specified, only the group quota file is created.

 

After the files are created, run the following command to generate the table of current disk usage per file system with quotas enabled:

quotacheck -avugm

The options used are as follows:

  • a — Check all quota-enabled, locally-mounted file systems
  • v — Display verbose status information as the quota check proceeds
  • u — Check user disk quota information
  • g — Check group disk quota information

After quotacheck has finished running, the quota files corresponding to the enabled quotas (user and/or group) are populated with data for each quota-enabled locally-mounted file system such as /home

quotaon -avug

if you need to turn the quotas off then do:

quotaoff /home

or the equivalent

quotaon -f /home

The quota system is ready to go, now we have to set the quotas for every user:

edquota -u username

And we get:

Disk quotas for user username (uid 501):

  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/mapper/vg_aguila-lv_root         36        0          0         10        0        0

The system automatically uses the default editor.

If we want to set 5MB of quota for username then we edit the file to:

Disk quotas for user username (uid 501):

  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/mapper/vg_aguila-lv_root         36       5000          0         10        0        0

 

Gestão

Basics

Use this command to check for quotas on a specific partition:

# repquota /home

Use this command to check for all quotas that apply to a user:

# quota -u $USER

for groups;

# quota -g $GROUP

Copying quota settings

To copy quota from one user or group to the other, use this command:

# edquota -p user1 user2

User1 is the user you copy from, user2 is the user you copy quota to. Of course you can replace user with group, when necessary.

Multiple users

The idea is to make a temporary user acount, modify the quota settings for that user, and then copy the generated quota files for all users to use. After setting quota settings for quotauser, copy the settings:

# edquota -p quotauser `awk -F: '$3 > 999 {print $1}' /etc/passwd`

This applies the settings to users with a UID equal to or greater than 1000.

Other commands

There are several useful commands:

repquota -a      # Shows the status on disk usage
warnquota        # Can be used to warn the users about their quota
setquota         # Non-interactive quota setting--useful for scripting

Lasty, quotastats is used to give thorough information about the quota system:

$ quotastats
Number of dquot lookups: 101289
Number of dquot drops: 101271
Number of still active inodes with quota : 18
Number of dquot reads: 93
Number of dquot writes: 2077
Number of quotafile syncs: 134518740
Number of dquot cache hits: 7391
Number of allocated dquots: 90
Number of free dquots: 2036
Number of in use dquot entries (user/group): -1946

 

Fonte:

http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-disk-quotas.html

http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-disk-quotas-managing.html

https://wiki.archlinux.org/index.php/Disk_Quota#Journaled_quota

Utilizar o grep no linux

Copiar todas as linhas que contêm foo no ficheiro file para o ficheiro output.txt

 grep foo file > output.txt

Listar a escrita do ficheiro mas com filtragem por uma determinada expressao

tail -f file | grep --line-buffered my_pattern

Desactivar mod_security para um virtualhost

Não é possível desactivar o mod_security2 através de um ficheiro .htaccess. É necessário desactivá-lo no virtual host no ficheiro de configuração httpd.conf adicionando as seguintes directivas:

<IfModule mod_security2.c>
 SecRuleEngine Off
</IfModule>

Comandos Postfix

postqueue -p

Permite ver quais as mensagens que estão na queue do servidor

postcat -q XXXXXXXXXXXX

Permite ver o conteúdo de uma mensagem que esteja na queue

postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / remover@ccems\.pt$/ { print $1 }' | tr -d '*!' | postsuper -d -

Apagar todos os emails de/para um determinado email

mailq | tail -n +2 | awk 'BEGIN { RS = "" } # $7=sender, $8=recipient1, $9=recipient2 { if ($7 == "remover@ccems.pt" && $9 == "") print $1 }' | tr -d '*!' | postsuper -d -

Gerar o ficheiro de base de dados para o postfix ler

postmap /etc/postfix/virtual.cf
/etc/init.d/postfix restart

If your server has very high load and you want to temporarily move all message from the incoming queue to the hold queue, use the command:

postsuper -h ALL

to move the messages back to the incoming queue, use the command:

postsuper -r ALL

Procura todas as mensagens com mais de 3k e apaga-as. Deve ser feito na(s) pasta(s) /var/spool/postfix/(hold|incoming|queue|active)

find . -type f -size -3k -exec ls -lh {} \; | awk '{ print "postsuper -r " $9 }'

Procura todas as mensagens com remover@ccems.pt e move para outra pasta

grep -l -Z -r 'sasl_username=remover@ccems.pt' . | xargs -0 -I{} mv {} /var/spool/postfix/lixo_hold

Para apagar todas as mensagem com aquele login:

find /var/spool/postfix/active/ -type f \
        -exec grep -l 'sasl_username=utilizador@ccems.pt' '{}' \; | \
    xargs -n1 basename | xargs -n1 postsuper -d
find /var/spool/postfix/deferred/ -type f \
        -exec grep -l 'Authenticated sender: utilizador@ccems.pt' '{}' \; | \
    xargs -n1 basename | xargs -n1 postsuper -d