www.thorko.de Thorsten Kohlhepp - Systems administrator | Thorko.de

 

For it has been granted to you that for the sake of Christ you should not only believe in him but also suffer for his sake....

Last FaqDB entries

RSS

Incron Howto

Install incron

~$ apt-get install incron

Configure incron and allow root to create an incrontab

# /etc/incron.conf
system_table_dir = /var/spool/incron/systables
user_table_dir = /var/spool/incron/usertables
allowed_users = /etc/incron.d/allow
denied_users = /etc/incron.d/deny
editor = vim
~$ mkdir -p /var/spool/incron/{systables,usertables}
~$ echo "root" > /etc/incron.d/allow
~$ touch /etc/incron.d/deny
~$ /etc/init.d/incron restart

next create an incrontab

~$ incrontab -e
/home/karl IN_CREATE /opt/scripts/send_mail.sh $# $@

incron can't handle pipes so "/home/tdorn IN_CREATE echo "$# $@" | mail -s "test" test@thorko.de" won't work. Instead use command line parameters to pass it to your script

$@ - name of the watched directory
$# - the filename
$$ - dollar sign
$% - event as text
$& - event as number




Howto configure avg for antivirus mail scanning

If you have avg already installed you can use "avgcfgctl" and "avgctl" to control avg

In your postfix configuration (master.cf) you have to set this

avgtcpd   unix  -       -        n     -       2    smtp 
   -o smtp_data_done_timeout=1200
   -o smtp_send_xforward_command=yes
   -o disable_dns_lookups=yes
   -o max_use=20

and in your main.cf file

content_filter = avgtcpd:localhost:54321

make sure avgtcpd is started and listening on port 54321

to configure avg you can export the entire configuration by using

~$ avgcfgctl -f avg.cfg 

once you have edited that file you import it by

~$ avgcfgctl -f avg.cfg -w -n

-n will also notify avg about configuration changes

I suggest at least to set

Tcpd.scan.Options.ReportMacros=true
Tcpd.scan.Options.ReportPwdProtectedArchs=true
Tcpd.scan.Options.ReportPwdProtectedDocs=true
Tcpd.scan.Options.ScanMediaFiles=true



Some useful SELinux commands

disable selinux at all

~$ echo 0 > /selinux/enforce

enable it again

~$ echo 1 > /selinux/enforce

 

when getting permission denied or something
check if auditd is running

~$ ps xa |grep auditd

run audit2allow

~$ audit2allow -l -a -M local

add the rules

 

~$ semodule -i local.pp

 




Useful commands

Show when a process got started

~$ ps kstart_time -ef



Howto create custom PNP4Nagios Template

First of all you need to be sure your perfdata comes in format " | <name>=<data>; <name2>=<data>"
Now create a file in your check_commands directory

check_commands/check_nrpe.cfg

CUSTOM_TEMPLATE = 0,1

PNP4Nagios takes the check_command definition of nagios. So "check_command check_nrpe!load!-w 4,4,4 -c 5,5,5" will be split into:
0=check_nrpe
1=load
2=-w...

So if you use CUSTOM_TEMPLATE = 0,1 it searches for a template file called "check_nrpe_load.php". This template file needs to be created under the share/templates directory. You can use the following as an example

<?
$opt[1] = "--title \"Memory consumption $hostname / $servicedesc\" ";

$def[1] =  "DEF:Data=$RRDFILE[1]:$DS[1]:AVERAGE " ;
$def[1] .= "DEF:Lib=$RRDFILE[1]:$DS[2]:AVERAGE " ;
$def[1] .= "DEF:RSS=$RRDFILE[1]:$DS[3]:AVERAGE " ;
$def[1] .= "DEF:Exe=$RRDFILE[1]:$DS[4]:AVERAGE " ;
$def[1] .= "DEF:Stk=$RRDFILE[1]:$DS[5]:AVERAGE " ;

$def[1] .= "LINE:Data#80ff40:\"Data used     \" " ;
$def[1] .= "GPRINT:Data:LAST:\"%6.0lf MB last\" " ;
$def[1] .= "GPRINT:Data:AVERAGE:\"%6.0lf MB avg\" " ;
$def[1] .= "GPRINT:Data:MAX:\"%6.0lf MB max\\n\" ";

$def[1] .= "LINE:Lib#80aa40:\"Lib used     \" " ;
$def[1] .= "GPRINT:Lib:LAST:\"%6.0lf MB last\" " ;
$def[1] .= "GPRINT:Lib:AVERAGE:\"%6.0lf MB avg\" " ;
$def[1] .= "GPRINT:Lib:MAX:\"%6.0lf MB max\\n\" ";

$def[1] .= "LINE:RSS#7b0040:\"RSS used     \" " ;
$def[1] .= "GPRINT:RSS:LAST:\"%6.0lf MB last\" " ;
$def[1] .= "GPRINT:RSS:AVERAGE:\"%6.0lf MB avg\" " ;
$def[1] .= "GPRINT:RSS:MAX:\"%6.0lf MB max\\n\" ";

$def[1] .= "LINE:Exe#969640:\"Exe used     \" " ;
$def[1] .= "GPRINT:Exe:LAST:\"%6.0lf MB last\" " ;
$def[1] .= "GPRINT:Exe:AVERAGE:\"%6.0lf MB avg\" " ;
$def[1] .= "GPRINT:Exe:MAX:\"%6.0lf MB max\\n\" ";

$def[1] .= "LINE:Stk#80ffcc:\"Stk used     \" " ;
$def[1] .= "GPRINT:Stk:LAST:\"%6.0lf MB last\" " ;
$def[1] .= "GPRINT:Stk:AVERAGE:\"%6.0lf MB avg\" " ;
$def[1] .= "GPRINT:Stk:MAX:\"%6.0lf MB max\\n\" ";
?>