13.2. System configuration

13.2.1. Apache configuration

Verify that mod_python has been configured: in your apache2.conf you should have a line like

LoadModule python_module modules/mod_python.so

Get the needed apache configuration with the command

python $SANET_HOME/manage.py deploy apache

check the configuration (in particular pathnames) and insert it into your Apache configuration file. It should be something like

DocumentRoot /var/www/

# Uncomment if you want to redirect the root of your webserver
# RedirectMatch ^/$ /sanet/

# Uncomment the following if you have mod_deflate
# SetOutputFilter DEFLATE
# BrowserMatch ^Mozilla/4 gzip-only-text/html
# BrowserMatch ^Mozilla/4\.0[678] no-gzip
# BrowserMatchMSIE !no-gzip !gzip-only-text/html

SetEnv SANET_HOME /usr/local/sanet

<LocationMatch "(/static/\|/media/)">
        SetHandler None
</LocationMatch>

<LocationMatch "/sanet/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE settings
        SetEnv PYTHON_EGG_CACHE /var/python-eggs/
        PythonDebug Off
        PythonPath "['/usr/local/sanet'] + sys.path"
</LocationMatch>

You must then link your /media in DocumentRoot to Django media files, and /static to $SANET_HOME/static

# ln -s /usr/local/sanet/django/contrib/admin/media/ /var/www/
# ln -s /usr/local/sanet/static /var/www/

Create /var/python-eggs directory and let it be writable by uid that executes apache daemon process.

13.2.2. Postgres tuning

SANET has been developed on PostgreSQL, so MySQL compatibility is not tested. Here we discuss some tuning actions in order to make PostgreSQL behave smarter.

13.2.2.1. General considerations

There are some parameters in postgresql.conf that we suggest to adapt in order to suite the application needs.

USE THE FOLLOWING INFORMATION AT YOUR OWN RISK ! They are just some considerations and you have to evaluate them by each installation, depending on how much you take care of ACID properties and your ability to recover from off-line backups and tolerate lost of some history info.

After changing this file you have to stop the poller via etc/rc.sanet stop, restart postgres and then launch again the poller with etc/rc.sanet start.

  • Max connections: if you have a lot of threads you would like to raise the default value to at least thread num + httpd thread daemon (usually apache) + some other. If you have no strict resources limit, We suggest to set it to (thread num + httpd thread) *2. Not dangerous.:

    max_connections: 200 or what you need
    shared_buffers: max_connections*16kB (p.e. 30MB)
    max_fsm_pages: min max_fsm_relations*16, 6 bytes each (p.e. 350000)
  • Autovacuum: you need it to perform some garbage collections. Not dangerous.:

    vacuum_cost_delay = 100
    track_counts = on
    autovacuum = on
    log_autovacuum_min_duration = 10 # (check postgresql logfile that autovacuum is actually doing some work)
    
  • Transaction parameters: tune sync writing to disk. If you disable synchronous commmit, the risk is to lose some transactions if postgres crashes, but you save a bunch of I/O operations since operations are aggregated and delayed. DANGEROUS.:

    synchronous_commit = off #immediate fsync at commit
    wal_writer_delay = 10000ms # 1-10000 milliseconds
    commit_delay = 100000# range 0-100000, in microseconds
    commit_siblings = 5# range 1-1000
  • Disable fsync: if you have REALLY NO HOPE ANYMORE you can disable fsync, and raise your risk to have a corrupted database. DANGEROUS. If you use this options pay attention to save CLI configuration each time you update it. If you disable fsync, previous settings of transaction parameters have no effect anymore::

    fsync = off
    

13.2.2.2. If you have a lot of RAM

If you have at least 2GB RAM (better more) and over 6000 targets and measures, you can try the following settings. After you have restarted it all check that swap is not used: it not useful to give plenty of RAM to postgres if you use swap. Remember to add echo 250000000 > /proc/sys/kernel/shmmax to your rc.postgres:

# SANET SETTINGS:
# Put in rc.postgres something like: echo 250000000 > /proc/sys/kernel/shmmax
# Remember to set noatime and dirnoatime
shared_buffers = 20000
vacuum_cost_delay = 100
track_counts = on
autovacuum = on
log_autovacuum_min_duration = 10
checkpoint_segments = 20
checkpoint_timeout = 900
wal_buffers = 64
autovacuum = on
max_fsm_pages = 2048000
max_fsm_relations = 10000
wal_buffers = 256
# work_mem = 32768
# maintenance_work_mem = 524288
work_mem = 100MB
maintenance_work_mem = 128MB
synchronous_commit = off
wal_writer_delay = 10000ms
commit_delay = 100000
commit_siblings = 5

13.2.3. System considerations

13.2.3.1. RAM and swap

In order to monitor successfully (not too much slowly) a medium network which has almost 3000 checks, your machine should be provided with around 2GB RAM. A swap partition is also suggested.

If you do not have a swap dedicated partition, you can create a swapfile with the procedure:

helicopter:~# dd if=/dev/zero of=/swapfile count=1024 bs=1M
helicopter:~# mkswap /swapfile
helicopter:~# swapon /swapfile