The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ASNMTAP::Asnmtap::Applications is a Perl module that provides a nice object oriented interface for ASNMTAP Applications

Description

ASNMTAP::Asnmtap::Applications Subclass of ASNMTAP::Asnmtap

This version is still the old ASNMTAP Applications v3.000.001 addapted for using with the new ASNMTAP::Asnmtap, ASNMTAP::Asnmtap::Plugins and ASNMTAP::Asnmtap::Plugins::Nagios plugins.

We are working onto an new Object Oriented version for the ASNMTAP Applications

CONFIG FILES

located at /opt/asnmtap-3.000.xxx/applications
Applications.cnf

General configuration file for the ASNMTAP Applications

HTML to PDF

For testing HTML to PDF you can rename /opt/asnmtap-3.000.xxx/applications/htmlroot/img/logos/bodyimage.gif-orig to /opt/asnmtap-3.000.xxx/applications/htmlroot/img/logos/bodyimage.gif

You can lateron copy your wanted bodyimage picture to /opt/asnmtap-3.000.xxx/applications/htmlroot/img/logos/bodyimage.gif or you can change te parameter <COMMON><HTMLTOPD>OPTIONS into the Application.cnf config file.

 <COMMON>
   <HTMLTOPD>
     OPTIONS --bodyimage /opt/asnmtap-3.000.xxx/applications/htmlroot/img/logos/bodyimage.gif --charset iso-8859-1 --format pdf14 --size A4 --landscape --browserwidth 1280 --top 10mm --bottom 10mm --left 10mm --right 10mm --fontsize 10.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Helvetica --headfootsize 10.0 --headfootfont Helvetica --embedfonts --pagemode fullscreen --permissions no-copy,print --no-links --color --quiet --webpage --header ... --footer ...
   </HTMLTOPD>
 </COMMON>

If you change the --bodyimage parameter, don't forget also to change the same parameter into the file /opt/asnmtap-3.000.xxx/applications/htmlroot/cgi-bin/htmldoc.sh for the on the fly HTML to PDF generating.

located at /opt/asnmtap-3.000.xxx/applications/etc
ArchiveCT

the config file used by the program archive.pl

when the Application CGI module and CGI applications are installed, this config file is automatically generated by the program generateConfig.pl

format
 format: <Pagedir>#<uniqueKey>#check_nnn[|<uniqueKey>#check_mmm]

   <Pagedir>    : results subdir where the data from the collector is located
    <uniqueKey> : uniqueKey key for this plugin
    check_nnn   : plugin name
example
 more /opt/asnmtap-3.000.xxx/applications/etc/ArchiveCT

 # ArchiveCT - CTP-CENTRAL, generated on 2006/06/xx 9:01:36, ASNMTAP v3.000.009 or higher
 #
 # <Pagedir>#<uniqueKey>#check_nnn[|<uniqueKey>#check_mmm]
 #
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 #
 _ASNMTAP#_ASNMTAP#collectorDaemonSchedulingReports.pl
 #
 test-01#DUMMY-T1#check_dummy.pl
 #
 test-02#DUMMY-T2#check_dummy.pl
 #
 test-03#DUMMY-T3#check_dummy.pl
 #
 test-04#DUMMY-T4#check_dummy.pl
 #
 test-05#DUMMY-T5#check_dummy.pl
 #
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 # Einde ArchiveCT - CTP-CENTRAL
located at /opt/asnmtap-3.000.xxx/applications/master
rsync-wrapper-failover-*.sh

...

linux
standalone
 ln -s /opt/asnmtap-3.000.xxx/applications/master/root-display.sh   /etc/init.d/root-display

 ln -s /etc/init.d/root-display /etc/rc3.d/S99root-display
 ln -s /etc/init.d/root-display /etc/rc3.d/K99root-display
 ln -s /etc/init.d/root-display /etc/rc2.d/S99root-display
 ln -s /etc/init.d/root-display /etc/rc2.d/K99root-display
 
 ln -s /opt/asnmtap-3.000.xxx/applications/master/root-collector.sh /etc/init.d/root-collector

 ln -s /etc/init.d/root-collector /etc/rc3.d/S99root-collector
 ln -s /etc/init.d/root-collector /etc/rc3.d/K99root-collector
 ln -s /etc/init.d/root-collector /etc/rc2.d/S99root-collector
 ln -s /etc/init.d/root-collector /etc/rc2.d/K99root-collector
failover
 more /opt/asnmtap.sh
 #!/bin/sh
 # ---------------------------------------------------------------
 # © Copyright 2004-2005 Alex Peeters [alex.peeters@citap.be]
 # ---------------------------------------------------------------
 # This shell script takes care of starting and stopping

 AMNAME="All ASNMTAP"

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 start() {
   # Start daemons
   echo "Start: '$AMNAME' ..."
   /etc/init.d/root-display start
   /etc/init.d/root-collector start
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 stop() {
   # Stop daemons
   echo "Stop: '$AMNAME' ..."
   /etc/init.d/root-display stop
   /etc/init.d/root-collector stop
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 # See how we were called.
 case "$1" in
   start)
            start
            ;;
   stop)
            stop
            ;;
   *)
            echo "Usage: '$AMNAME' {start|stop}"
            exit 1
 esac

 exit 0

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 ln -s /opt/asnmtap.sh /etc/init.d/asnmtap

 ln -s /etc/init.d/asnmtap /etc/rc3.d/S99asnmtap
 ln -s /etc/init.d/asnmtap /etc/rc3.d/K99asnmtap
 ln -s /etc/init.d/asnmtap /etc/rc2.d/S99asnmtap
 ln -s /etc/init.d/asnmtap /etc/rc2.d/K99asnmtap
solaris
standalone
 ln -s /opt/asnmtap-3.000.xxx/applications/master/root-display.sh   /etc/init.d/root-display

 ln -s /etc/init.d/root-display /etc/rc3.d/S99root-display
 ln -s /etc/init.d/root-display /etc/rc3.d/K99root-display
 ln -s /etc/init.d/root-display /etc/rc0.d/S99root-display
 ln -s /etc/init.d/root-display /etc/rc0.d/K99root-display
 
 ln -s /opt/asnmtap-3.000.xxx/applications/master/root-collector.sh /etc/init.d/root-collector

 ln -s /etc/init.d/root-collector /etc/rc3.d/S99root-collector
 ln -s /etc/init.d/root-collector /etc/rc3.d/K99root-collector
 ln -s /etc/init.d/root-collector /etc/rc0.d/S99root-collector
 ln -s /etc/init.d/root-collector /etc/rc0.d/K99root-collector
failover
 more /opt/asnmtap.sh
 #!/bin/sh
 # ---------------------------------------------------------------
 # © Copyright 2004-2005 Alex Peeters [alex.peeters@citap.be]
 # ---------------------------------------------------------------
 # This shell script takes care of starting and stopping

 AMNAME="All ASNMTAP"

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 start() {
   # Start daemons
   echo "Start: '$AMNAME' ..."
   /etc/init.d/root-display start
   /etc/init.d/root-collector start
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 stop() {
   # Stop daemons
   echo "Stop: '$AMNAME' ..."
   /etc/init.d/root-display stop
   /etc/init.d/root-collector stop
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 # See how we were called.
 case "$1" in
   start)
            start
            ;;
   stop)
            stop
            ;;
   *)
            echo "Usage: '$AMNAME' {start|stop}"
            exit 1
 esac

 exit 0

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 ln -s /opt/asnmtap.sh /etc/init.d/asnmtap

 ln -s /etc/init.d/asnmtap /etc/rc3.d/S99asnmtap
 ln -s /etc/init.d/asnmtap /etc/rc3.d/K99asnmtap
 ln -s /etc/init.d/asnmtap /etc/rc2.d/S99asnmtap
 ln -s /etc/init.d/asnmtap /etc/rc2.d/K99asnmtap
located at /opt/asnmtap-3.000.xxx/applications/slave
linux
failover
 more /opt/asnmtap.sh
 #!/bin/sh
 # ---------------------------------------------------------------
 # © Copyright 2004-2005 Alex Peeters [alex.peeters@citap.be]
 # ---------------------------------------------------------------
 # This shell script takes care of starting and stopping

 AMNAME="All ASNMTAP"

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 start() {
   # Start daemons
   echo "Start: '$AMNAME' ..."
   /etc/init.d/root-display start
   /etc/init.d/root-collector start
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 stop() {
   # Stop daemons
   echo "Stop: '$AMNAME' ..."
   /etc/init.d/root-display stop
   /etc/init.d/root-collector stop
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 # See how we were called.
 case "$1" in
   start)
            start
            ;;
   stop)
            stop
            ;;
   *)
            echo "Usage: '$AMNAME' {start|stop}"
            exit 1
 esac

 exit 0

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 ln -s /opt/asnmtap.sh /etc/init.d/asnmtap

 /etc/rc3.d/S99asnmtap /etc/init.d/asnmtap
 /etc/rc3.d/K99asnmtap /etc/init.d/asnmtap
 /etc/rc2.d/S99asnmtap /etc/init.d/asnmtap
 /etc/rc2.d/K99asnmtap /etc/init.d/asnmtap
solaris
failover
 more /opt/asnmtap.sh
 #!/bin/sh
 # ---------------------------------------------------------------
 # © Copyright 2004-2005 Alex Peeters [alex.peeters@citap.be]
 # ---------------------------------------------------------------
 # This shell script takes care of starting and stopping

 AMNAME="All ASNMTAP"

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 start() {
   # Start daemons
   echo "Start: '$AMNAME' ..."
   /etc/init.d/root-display start
   /etc/init.d/root-collector start
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 stop() {
   # Stop daemons
   echo "Stop: '$AMNAME' ..."
   /etc/init.d/root-display stop
   /etc/init.d/root-collector stop
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 # See how we were called.
 case "$1" in
   start)
 #            start
            ;;
   stop)
 #            stop
            ;;
   *)
            echo "Usage: '$AMNAME' {start|stop}"
            exit 1
 esac

 exit 0

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 ln -s /opt/asnmtap.sh /etc/init.d/asnmtap

 /etc/rc3.d/S99asnmtap /etc/init.d/asnmtap
 /etc/rc3.d/K99asnmtap /etc/init.d/asnmtap
 /etc/rc0.d/S99asnmtap /etc/init.d/asnmtap
 /etc/rc0.d/K99asnmtap /etc/init.d/asnmtap

PROGRAMS

located at /opt/asnmtap-3.000.xxx/applications
archive.pl

the Archiver.

 This perl program
 - create automatically new comments and events archive tables when needed.
 - archiving the comments and events to the correspondending archiving tables
 - removes the old unused cgisess files
 - make backups and zips the csv, sql error, week, debug and report files
 - removes the old zipped csv, sql error, week, debug and report files
archive.sh

Shell script to run archive.pl with the default command line options

 crontab -e
  0  1 * * * /opt/ansmtap-3.000.xxx/applications/archive.sh >/dev/null 2>&1
located at /opt/asnmtap-3.000.xxx/applications/bin
generateCollectorDaemonSchedulingReports.pl

this program generating automatically Collector Daemon Scheduling Reports in PDF format

 Located at URL: http://asnmtap.citap.be/results/_ASNMTAP/reports/
generateCollectorDaemonSchedulingReports.sh

Shell script to run generateCollectorDaemonSchedulingReports.pl with the default command line options

 crontab -e
  0  0 * * * /opt/ansmtap-3.000.xxx/applications/bin/generateCollectorDaemonSchedulingReports.sh >/dev/null 2>&1
generateReports.pl

this program generate automatically reports in PDF format, defined by the CGI program reports.pl

generateReports.sh

Shell script to run generateReports.pl with the default command line options

 crontab -e
 30  0 * * * /opt/ansmtap-3.000.xxx/applications/bin/generateReports.sh >/dev/null 2>&1
holidayBundleSetDowntimes.pl

this program automatically set the plugin downtimes, defined by the CGI program plugin.pl and holidaysBundle.pl

holidayBundleSetDowntimes.sh

Shell script to run holidayBundleSetDowntimes.pl with the default command line options

 crontab -e
 15  0 * * * /opt/ansmtap-3.000.xxx/applications/bin/holidayBundleSetDowntimes.sh >/dev/null 2>&1
located at /opt/asnmtap-3.000.xxx/applications/sbin
sshWrapperASNMTAP.pl

ASNMTAP ssh wrapper script for ssh execution through a rsa or dsa key

 Accepted ssh calls are as follows:

   'script $APPLICATIONPATH/master/DisplayCT-<daemon name>.sh stop|start|restart|reload'
   'script $APPLICATIONPATH/slave/DisplayCT-<daemon name>.sh stop|start|restart|reload'

   'script $APPLICATIONPATH/master/CollectorCT-<daemon name>.sh stop|start|restart|reload'
   'script $APPLICATIONPATH/slave/CollectorCT-<daemon name>.sh stop|start|restart|reload'

   'remove $PIDPATH/DisplayCT-<daemon name>.pid'
   'remove $PIDPATH/CollectorCT-<daemon name>.pid'

   'killall <pid>'

 '../' are forbidden into a directory of filename for security reasons !!!

 You need to create an ssh account:

   ssh-keygen -t dsa -f /home/asnmtap/.ssh/asnmtap

   vi /home/asnmtap/.ssh/authorized_keys
   from="localhost", command="/opt/asnmtap-3.000.xxx/applications/sbin/sshWrapperASNMTAP.pl" ssh-dss AAAAB3Nza...+90k63Mx...3OmZOk= alex.peeters@citap.be

   vi hosts.allow
   ssh: localhost

   vi hosts.deny
   ssh: ALL

   ssh  -i '/home/asnmtap/.ssh/asnmtap' asnmtap@localhost 'killall number'
   ssh  -i '/home/asnmtap/.ssh/asnmtap' asnmtap@localhost 'remove /var/run/asnmtap/CollectorCT-zombie.pid'
   ssh  -i '/home/asnmtap/.ssh/asnmtap' asnmtap@localhost 'script /opt/asnmtap-3.000.xxx/applications/master/CollectorCT-test.sh stop'

 Dependencies:

 - Getopt::Long

INSTALL

when i have more time, this will also be automated, but for now ...

user asnmtap

DON't run the ASNMTAP Applications under the ROOT account, use one dedicated account for the ASNMTAP Applications instead!

create user asnmtap

adduser asnmtap

create ssh key

...

 <slave server>:
   ssh-keygen -q -t rsa -f /home/asnmtap/.ssh/ssh -N ''
 or
   ssh-keygen -q -t dsa -f /home/asnmtap/.ssh/ssh -N ''

 chmod go-w   /home/asnmtap/
 chmod 700    /home/asnmtap/.ssh
 chmod go-rwx /home/asnmtap/.ssh/*

 chmod 644 ssh.pub
 chown asnmtap:asnmtap ssh.pub

 chmod 600 ssh
 chown apache:asnmtap ssh

 cat /home/asnmtap/.ssh/ssh.pub >> /home/asnmtap/.ssh/authorized_keys
 chmod 600 /home/asnmtap/.ssh/authorized_keys
 vi /home/asnmtap/.ssh/authorized_keys
 add command='/opt/asnmtap-3.000.xxx/applications/sbin/sshWrapperASNMTAP.pl' before ssh.pub
Apache
Install for HTTPS support
 install openssh, openssl, openssl096 & openssl-devel
add /etc/httpd/conf.d/asnmtap.conf
 Link index.html and index-cv.html to the default screens
 [/opt/asnmtap-3.000.xxx/applications/htmlroot]# ln -s citap.html  index.html
 [/opt/asnmtap-3.000.xxx/applications/htmlroot]# ln -s citap-cv.html  index-cv.html

 vi /etc/httpd/conf.d/asnmtap.conf

 AddHandler cgi-script .cgi .pl

 DirectoryIndex index.htm index.html index.html.var index.shtml index.cfm index.pl

 <VirtualHost *:80>
   ServerName asnmtap.citap.com
   ServerAlias asnmtap.citap.be
   ServerAdmin webmaster@citap.com
   DocumentRoot /opt/asnmtap/applications/htmlroot
   ErrorLog /var/log/httpd/asnmtap.citap.com-error.log
   CustomLog /var/log/httpd/asnmtap.citap.com-combined.log combined
   IndexIgnore *.png *nok.txt *all.txt *.html
   IndexOptions NameWidth=* FancyIndexing FoldersFirst SuppressDescription
   IndexOrderDefault Ascending Name

   Alias /asnmtap/ "/opt/asnmtap/applications/htmlroot/"

   <Directory "/opt/asnmtap/applications/htmlroot">
     AllowOverride AuthConfig
     Options FollowSymLinks
     Order allow,deny
     Allow from all
   </Directory>

   Alias /results/ "/opt/asnmtap/results/"

   <Directory "/opt/asnmtap/results">
     HeaderName HEADER.html
     ReadmeName FOOTER.html
     AllowOverride AuthConfig
     Options Indexes
   # Options Indexes FollowSymLinks
     Order allow,deny
     Allow from all
   </Directory>

   Alias /config/ "/opt/asnmtap/applications/tmp/config/"

   <Directory "/opt/asnmtap/applications/tmp/config">
     HeaderName HEADER.html
     ReadmeName FOOTER.html
     AllowOverride AuthConfig
     Options Indexes
   # Options Indexes FollowSymLinks
     Order allow,deny
     Allow from all
   </Directory>

   ScriptAlias /cgi-bin/ "/opt/asnmtap/applications/htmlroot/cgi-bin/"

   <Directory "/opt/asnmtap/applications/htmlroot/cgi-bin">
     AllowOverride AuthConfig
     Options ExecCGI
     Order allow,deny
     Allow from all
   </Directory>
 </VirtualHost>
Install Mysql client
 Use rpm or download the source, for version 4.0 or later 'gzip' needed

 when the sourecode used (gcc, g++, binutils & make needed):
   ./configure --without-server
   make
   make install

 yum install mysql-devel
collector.pl need in general
onto the master and slave server:
 SQLyog -> Db -> Import from SQL Statements ... -> \opt\asnmtap-3.000.xxx\applications\tools\mysql\asnmtap-3.000.009.sql
 or
 mysql -u root -p  < /opt/asnmtap-3.000.xxx/applications/tools/mysql/asnmtap-3.000.009.sql
onto the master server:
 mysql -u root -p
 mysql> GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, CREATE TEMPORARY TABLES ON asnmtap.* TO 'asnmtap'@'localhost' IDENTIFIED BY 'passwd';
 mysql> GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, CREATE TEMPORARY TABLES ON asnmtap.* TO 'asnmtap'@'hostname-master-server' IDENTIFIED BY 'passwd';
 mysql> GRANT SELECT ON asnmtap.* TO 'asnmtapro'@'hostname-master-server' IDENTIFIED BY 'passwd-ro';
 mysql> GRANT SELECT, SUPER, REPLICATION CLIENT, REPLICATION SLAVE, RELOAD ON asnmtap.* TO 'replication'@'hostname-slave-server' IDENTIFIED BY 'passwd-replication';
 mysql> FLUSH TABLES WITH READ LOCK;
 mysql> QUIT;

 when master is in production before the slave exist
   mysqldump -u root -p asnmtap > asnmtap.sql
 or for big tables
   make sure mysqld is dead!!!
   tar -cvf /tmp/mysql-snapshot.tar /path/to/data-dir

 mysql -u root -p
 mysql> SHOW MASTER STATUS;
 #      If the master has been previously running without --log-bin enabled, the log
 #      name and position values displayed by SHOW MASTER STATUS will be empty.
 mysql> UNLOCK TABLES;
 mysql> QUIT;

 Write down the parrameters from SHOW MASTER STATUS when master already exists !!!

 Make sure the [mysqld] section of the `my.cnf' file on the master host includes a log-bin option. The section should also have a server-id=master_id option, where master_id must be an integer value from 1 to 2^32 - 1.

 vi /etc/my.cnf
 [mysqld]
   datadir=/var/lib/mysql
   socket=/var/lib/mysql/mysql.sock
   port=3306

   server-id=1
   log-bin=asnmtap
   log-slave-updates
   binlog-ignore-db=mysql
   replicate-ignore-db=mysql
   report-host=slave-server.citap.com

 [mysql.server]
   user=mysql
   basedir=/var/lib

 [safe_mysqld]
   err-log=/var/log/mysqld.log
   pid-file=/var/run/mysqld/mysqld.pid

 # If those options are not present, add them and restart the server.

 mysql -u root -p
 mysql> SHOW MASTER STATUS;
 # +---------------+----------+--------------+------------------+
 # |      File     | Position | Binlog_Do_DB | Binlog_Ignore_DB |
 # +---------------+----------+--------------+------------------+
 # | mysql-bin.001 | 73       | checklist    | mysql            |
 # +---------------+----------+--------------+------------------+
 mysql> QUIT;

 Write down the parrameters from SHOW MASTER STATUS, when master didn't exists befire!!!

 The File column shows the name of the log, while Position shows the offset. In the above example, the binary log value is mysql-bin.001 and the offset is 73. Record the values. You will need to use them later when you are setting up the slave. Once you have taken the snapshot and recorded the log name and offset, you can re-enable write activity on the master:
onto the slave server:
 Make sure there are NO update queries on the slave server at this point!!!

 mysql -u root -p
 mysql> STOP SLAVE;                                     <-- if replication was running
 mysql> QUIT;

 when master is in production before the slave exist:

   mysql -u root -p
   mysql> CREATE DATABASE asnmtap;
   mysql> QUIT;
   mysql -u root -p asnmtap < asnmtap.sql
   mysql -u root -p
 or
   make sure mysqld is dead!!!
   copy and untar mysql-snapshot.tar created earlier

 mysql -u root -p
 mysql> GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, CREATE TEMPORARY TABLES ON asnmtap.* TO 'asnmtap'@'localhost' IDENTIFIED BY 'passwd';
 mysql> GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, CREATE TEMPORARY TABLES ON asnmtap.* TO 'asnmtap'@'hostname-slave-server' IDENTIFIED BY 'passwd';
 mysql> GRANT SELECT ON asnmtap.* TO 'asnmtapro'@'hostname-slave-server' IDENTIFIED BY 'passwd-ro';
 mysql> GRANT SELECT, SUPER, REPLICATION CLIENT, REPLICATION SLAVE, RELOAD ON asnmtap.* TO 'replication'@'hostname-master-server' IDENTIFIED BY 'passwd-replication';
 mysql> FLUSH TABLES WITH READ LOCK;
 mysql> QUIT;

 Stop the server that is to be used as a slave server and add the following to its `my.cnf' file. The slave_id value, like the master_id value, must be an integer value from 1 to 2^32 - 1. In addition, it is very important that the ID of the slave be different than the ID of the master. If you are setting up multiple slaves, each one must have a server-id value that differs from that of the master and from each of the other slaves. Think of server-id values as something similar to IP addresses: These IDs uniquely identify each server instance in the community of replication partners. If you don't specify a server-id value, it will be set to 1 if you have not defined master-host, else it will be set to 2. Note that in the case of server-id omission, a master will refuse connections from all slaves, and a slave will refuse to connect to a master. Thus, omitting server-id is only good for backup with a binary log.

 vi /etc/my.cnf
 [mysqld]
   datadir=/var/lib/mysql
   socket=/var/lib/mysql/mysql.sock
   port=3306

   server-id=2
   log-bin=asnmtap
   log-slave-updates
   binlog-ignore-db=mysql
   replicate-ignore-db=mysql
   report-host=master-server.citap.com

 [mysql.server]
   user=mysql
   basedir=/var/lib

 [safe_mysqld]
   err-log=/var/log/mysqld.log
   pid-file=/var/run/mysqld/mysqld.pid

 Start the slave server. If it has been replicating previously, start the slave server with the --skip-slave-start option. You also may want to start the slave server with the --log-warnings option. That way, you will get more messages about problems (for example, network or connection problems). If you made a backup of the master server's data using mysqldump, load the dump file into the slave server:

 Execute the following command on the slave, replacing the values within <> with the actual values relevant to your system:

       This is where you put the values you got earlier from SHOW MASTER STATUS from 2)

 mysql> CHANGE MASTER TO
          MASTER_HOST='<master hostname>',
          MASTER_USER='<replication username>',
          MASTER_PASSWORD='<replication password>',
          MASTER_LOG_FILE='<recorded log file name>',   <-- replace with the value show 'SHOW MASTER STATUS' on the master server
          MASTER_LOG_POS=<recorded log offset>;         <-- replace with the value show 'SHOW MASTER STATUS' on the master server

 mysql> START SLAVE;                                    <-- if you want to restart replication

 mysql> SHOW MASTER STATUS;
        write down the values

 mysql> QUIT;

 At this point you got master -> slave replication
onto the master server, part II:
 copy the slave server *.bin.* (binary logs), put it in the master server mysql data dir

 mysql> STOP SLAVE;                                     <-- if replication was running
        This is where you put the values you got earlier from SHOW MASTER STATUS from 3)

 mysql> CHANGE MASTER TO
          MASTER_HOST='<slave hostname>',
          MASTER_USER='<replication username>',
          MASTER_PASSWORD='<replication password>',
          MASTER_LOG_FILE='<recorded log file name>',   <-- replace with the value show 'SHOW MASTER STATUS' on the master server
          MASTER_LOG_POS=<recorded log offset>;         <-- replace with the value show 'SHOW MASTER STATUS' on the master server

 mysql> START SLAVE;                                    <-- if you want to restart replication

 At this point you got master -> slave -> master replication

 You can now execute any query on any of them, and it will appear on both. 

 We will do it always onto the master server, unless the master server is down then we uses the slave server!!!
Update your ASNMTAP configuration
 vi /opt/asnmtap-3.000.xxx/Asnmtap.cnf

 Here you can modify all the varibales used by the ASNMTAP package !!!

 vi /opt/asnmtap-3.000.xxx/applications/custom/Applications.cnf

 URL: http://asnmtap.citap.be/cgi-bin/sadmin/index.pl

 Now you can build your config !!!
Install perl modules from CPAN
 export http_proxy=http://proxy:8080
 export ftp_proxy=http://proxy:8080

 perl -MCPAN -e shell
 install Bundle::CPAN
 install Bundle::DBI
 install Bundle::DBD::mysql                             # need mysql-devel
Perfparse integration

Perfparse (http://perfparse.sourceforge.net/)

We use the 'Pipe to Perfparse' methode

Compiling Perfparse
 wget http://belnet.dl.sourceforge.net/sourceforge/perfparse/perfparse-0.105.7.tar.gz
 cd /export/download/
 tar -xvzf perfparse-0.105.7.tar.gz
 cd /export/download/perfparse-0.105.7
 ./configure --prefix=/opt/asnmtap-3.000.xxx/perfparse --with-imagedir=/opt/asnmtap-3.000.xxx/applications/htmlroot/img/ --with-cgidir=/opt/asnmtap-3.000.xxx/applications/htmlroot/cgi-bin --with-http_image_path=/asnmtap/img --with-data-source=asnmtap
 make
 make install-strip
Installing Perfparse database
 cd /export/download/perfparse-0.105.7/scripts
 cat mysql_create.sql | mysql -u root -p -D asnmtap
Configuration of Perfparse for ASNMTAP
 cp /opt/asnmtap-3.000.xxx/perfparse/etc/perfparse.cfg.example /opt/asnmtap-3.000.xxx/perfparse/etc/perfparse.cfg

 First you should edit '/opt/asnmtap-3.000.xxx/perfparse/etc/perfparse.cfg', adding the correct database settings (if using something other than 'nagios' as DB name, username, and password). The options are :

 Use_Storage_Mysql (only in perfparsed; considered as enabled in perfparse-log2mysql)

 vi /opt/asnmtap-3.000.xxx/perfparse/etc/perfparse.cfg
   ...
   Service_Log "-"
   ...
   # Error handling :
   Error_Log =                  "/var/log/perfparse-asnmtap-all"
   Drop_File =                  "/var/log/perfparse-asnmtap-drop"
   ...

  # Database managment :
  # ====================
  Use_Storage_Mysql =              "yes"

  No_Raw_Data =                    "no"
  No_Bin_Data =                    "no"

  # Database Authentication
  DB_User =                    "asnmtap"
  DB_Name =                    "asnmtap"
  DB_Pass =                    "passwd"
  DB_Host =                    "localhost"
Testing configuration
 http://asnmtap.citap.be/cgi-bin/perfparse.cgi
 > An error occured with the SQL:
 >   "Could not connect to MySQL using:  Database  = 'asnmtap',  Host  = '127.0.0.1',  Username =  'asnmtap', Password  = 'asnmtap'"
 >
 > Failure Message:
 >   "Access denied for user: 'asnmtap@localhost.localdomain' (Using password: YES)"

 You need to verify your access right for the database

 Host & Service string from Nagios:
   "$TIMET$"\t"$HOSTNAME$"\t"$SERVICEDESC$"\t"$OUTPUT$"\t"$SERVICESTATE$"\t"$PERFDATA$"\n

   $TIMET$              $HOSTNAME$                          $SERVICEDESC$               $OUTPUT$                                                                                        $SERVICESTATE$  $PERFDATA$
   1107692805   chablis.dvkhosting.com  process ColdFusion      OK - 40 processes running with command name cfusion     OK                              label=1;2;3;4;5

   Test command:
   /usr/bin/printf "%b" "1107692900\tDUMMY-T1\tDUMMY-T1\tCRITICAL - Check Dummy: +DUMMY-T2+\tCRITICAL\ttperfdata=1;1;;;\n" | /opt/asnmtap-3.000.xxx/perfparse/bin/perfparse-log2mysql -c /opt/asnmtap-3.000.xxx/perfparse/etc/perfparse.cfg
Database Maintenance

Deletion policies are defined at various places with default and user-defined policies available. A policy defines the time at which data is permanently deleted from the DB. The data is deleted by running the provided program 'perfparse-db-purge'. It is advised that this is run daily at some time when the server is at low load.

 To purge the DB daily using 'perfparse-db-purge' from crontab, you might use something like this:

 # Purge PerfParse DB daily at 3 AM.
 00 3 * * * /opt/asnmtap-3.000.xxx/perfparse/bin/perfparse-db-purge > /dev/null 2>&1
Install HTML to PDF converter for Perl

HTMLDOC: http://www.htmldoc.org/

Downloading the Software
 Get the software from http://www.htmldoc.org/
   cd /export/download
   wget http://ftp.easysw.com/pub/htmldoc/1.8.25/htmldoc-1.8.25-source.tar.gz
Installing the Software
 After downloading the software, install the software using the following commands:
   cd /export/download/directory
   rpm -i htmldoc-1.8.25-linux-intel.rpm
   /usr/bin/htmldoc
   tar -xvzf htmldoc-1.8.25-source.tar.gz
   cd /export/download/htmldoc-1.8.25
   ./configure
   make
   make install
Licensing the Software

The HTMLDOC License window is shown the first time you run the software.

Click on the Update License button to add a license to your system

 perl -MCPAN -e shell
 install HTML::HTMLDoc

 ln -s /usr/bin/htmldoc /opt/asnmtap-3.000.xxx/applications/htmlroot/cgi-bin/htmldoc.cgi

 vi httpd.conf
 AcceptPathInfo On
 AddHandler cgi-script .cgi .pl
 Options ExecCGI FollowSymLinks
Install ChartDirector 4.x for Perl
 download chartdir_perl_linux.tar.gz from http://www.advsofteng.com/
   wget http://www.advsofteng.com/chartdir_perl_linux.tar.gz
   mv chartdir_perl_linux.tar.gz /opt/.
   tar -xvzf chartdir_perl_linux.tar.gz
   rm chartdir_perl_linux.tar.gz
Install Awstats
 # vi /usr/local/apache2/conf/httpd.conf
 CustomLog logs/access_log combined

 # wget http://belnet.dl.sourceforge.net/sourceforge/awstats/awstats-6.3.tgz
 # tar -xvzf awstats-6.3.gz
 # chown -R nagios.nagios awstats-6.3
 # mv awstats-6.3 /usr/local/
 # mv /usr/local/awstats-6.3 /usr/local/awstats
 # cd /usr/local/awstats/tools
 # ./awstats_configure.pl

 # mkdir /var/lib
 # mkdir /var/lib/awstats

 # chown -R nobody /usr/local/awstats/wwwroot

 # vi /var/spool/cron/crontabs/root
 15 * * * * /usr/local/awstats/tools/awstats_updateall.pl now > /dev/null 2> &1

 http://awstats.sourceforge.net/docs/awstats_setup.html

HOWTO

SQL statement to query one results from the database
 SELECT id, title, status, endDate, endTime, statusMessage, step, timeslot FROM `events` where uKey = '<uKey>' and endDate = 'yyyy-mm-dd' order by id desc limit 1;

 status
 ----------------------------------------------------------------------------------------
 OK             no problems
 WARNING        indicates that there is something wrong, but not critical
 CRITICAL       indicates a critical problem
 UNKNOWN        indicates that we don't now the correct status
 NO-TEST        there is no test for this timeslot
 OFFLINE        this application is offline (no test sheduled for this timeslot)
 <NIHIL>        problem with the execution from the plugin

  <keyl>
 --------
 DUMMY-T1
 DUMMY-T2
 DUMMY-T3
 DUMMY-T4
 DUMMY-T5
run archiver.pl on cygwin
 Install libpng... needed, install this now

 mount -f -s -b "D:/cygwin/usr/sbin" "/usr/sbin" <-- to update the registry

 cygrunsrv --install "CYGWIN crontab" --path /usr/sbin/cron.exe -a '-D' -e CYGWIN=ntsec
 cygrunsrv --stop    "CYGWIN crontab"
 cygrunsrv --start   "CYGWIN crontab"
 cygrunsrv --remove  "CYGWIN crontab"

 0   2 * * * cd /opt/asnmtap-3.000.xxx/applications; ./archive.sh > /dev/null 2>&1  <-- crontab op master server
 30 23 * * * cd /opt/asnmtap-3.000.xxx/applications/bin; ./holidayBundleSetDowntimes.sh > /dev/null 2> &1  <-- crontab op master server
maximum timeslot interval greather then 2 hours:

asyncroon scheduling required

Perl
update every CPAN module that is outdated

perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'

Apache
How create simple test certificates with openssl?

http://www.vanemery.com/Linux/Apache/apache-SSL.html

Step 1: Setup your own CA (Certificate Authority)
 # openssl genrsa -des3 -out server-ca.key 2048
 # openssl req -new -x509 -days 3650 -key server-ca.key -out server-ca.crt
 To remove the pass phrase from the key file, execute this: 
 # openssl rsa -in server-ca.key -out server-ca-nopass.key
 # openssl x509 -in server-ca.crt -text -noout
Step 2: Make a key and a certificate for the web server:
 # openssl genrsa -des3 -out citap-server.key 1024
 # openssl req -new -key citap-server.key -out citap-server.csr
   ...
   Common Name (eg, your name or your server's hostname) []:secure.citap.com <=== This must be the real FQDN of your server!!!
 # openssl rsa -in citap-server.key -out citap-server-nopass.key
 # openssl x509 -req -in citap-server.csr -out citap-server.crt -sha1 -CA server-ca.crt -CAkey server-ca.key -CAcreateserial -days 3650
 # openssl x509 -in citap-server.crt -text -noout
Step 3: Creating Client Certificates for Authentication
 # openssl genrsa -des3 -out alex-peeters.key 1024
 # openssl req -new -key alex-peeters.key -out alex-peeters.csr
 # openssl x509 -req -in alex-peeters.csr -out alex-peeters.crt -sha1 -CA server-ca.crt -CAkey server-ca.key -CAcreateserial -days 3650
 # openssl pkcs12 -export -in alex-peeters.crt -inkey alex-peeters.key -name "Alex Peeters" -out alex-peeters.p12
 # openssl pkcs12 -in alex-peeters.p12 -clcerts -nokeys -info

 when:
   [error] Re-negotiation handshake failed: Not accepted by client!?
   [error] Certificate Verification: Error (20): unable to get local issuer certificate

 # vi /etc/httpd/cond.d/ssl.conf
   SSLCertificateFile /etc/httpd/conf/ssl.crt/citap-server.crt
   SSLCertificateKeyFile /etc/httpd/conf/ssl.key/citap-server.key
   SSLCertificateChainFile /etc/httpd/conf/ssl.crt/server-ca.crt
   SSLCACertificateFile /etc/httpd/conf/ssl.crt/server-ca.crt
MySQL
A -> B -> C -> A replication

MySQL Reference Manual http://mysqld.active-venture.com/

It is safe to connect servers in a circular master/slave relationship with log-slave-updates enabled. Note, however, that many queries will not work correctly in this kind of setup unless your client code is written to take care of the potential problems that can happen from updates that occur in different sequence on different servers. This means that you can do a setup like the following:

A -> B -> C -> A

Server IDs are encoded in the binary log events. A will know when an event it reads had originally been created by A, so A will not execute it and there will be no infinite loop. But this circular setup will work only if you only if you perform no conflicting updates between the tables. In other words, if you insert data in A and C, you should never insert a row in A that may have a conflicting key with a row insert in C. You should also not update the same rows on two servers if the order in which the updates are applied matters.

PURGE MASTER LOGS

PURGE {MASTER|BINARY} LOGS TO 'log_name'

PURGE {MASTER|BINARY} LOGS BEFORE 'date'

Deletes all the binary logs listed in the log index that are strictly prior to the specified log or date. The logs also are removed from this list recorded in the log index file, so that the given log now becomes the first.

If you have an active slave that is currently reading one of the logs you are trying to delete, this command does nothing and fails with an error. However, if you have a dormant slave, and happen to purge one of the logs it wants to read, the slave will be unable to replicate once it comes up. The command is safe to run while slaves are replicating. You do not need to stop them.

You must first check all the slaves with SHOW SLAVE STATUS to see which log they are reading, then do a listing of the logs on the master with SHOW MASTER LOGS, find the earliest log among all the slaves (if all the slaves are up to date, this will be the last log on the list), backup all the logs you are about do delete (optional) and purge up to the target log.

RESET MASTER

Deletes all binary logs listed in the index file, resetting the binlog index file to be empty

RESET SLAVE

Makes the slave forget its replication position in the master's binlogs. This statement is meant to be used for a clean start: it deletes the `master.info' and `relay-log.info' files, all the relay logs, and starts a new relay log.

Note: All relay logs are deleted, even if they had not been totally executed by the slave SQL thread. (This is a condition likely to exist on a replication slave that is highly loaded, or if you have issued a STOP SLAVE statement.) Connection information stored in the `master.info' file is immediately reset to the values specified in the corresponding startup options, if they were specified. This information includes values such as master host, master port, master user, and master password. If the slave SQL thread was in the middle of replicating temporary tables when it was stopped, and RESET SLAVE is issued, these replicated temporary tables are deleted on the slave.

How do I configure a slave if the master is already running and I do not want to stop it?

There are several options. If you have taken a backup of the master at some point and recorded the binlog name and offset ( from the output of SHOW MASTER STATUS ) corresponding to the snapshot, do the following:

Make sure the slave is assigned a unique server ID.

Execute the following statement on the slave, filling in appropriate values for each parameter:

 mysql> CHANGE MASTER TO
   ->     MASTER_HOST='master_host-name',
   ->     MASTER_USER='master_user_name',
   ->     MASTER_PASSWORD='master_pass',
   ->     MASTER_LOG_FILE='recorded_log_name',
   ->     MASTER_LOG_POS=recorded_log_pos;

Execute START SLAVE on the slave.

If you do not have a backup of the master already, here is a quick way to do it consistently:

 FLUSH TABLES WITH READ LOCK 
 gtar zcf /tmp/backup.tar.gz /var/lib/mysql (or a variation of this) 
 SHOW MASTER STATUS - make sure to record the output - you will need it later 
 UNLOCK TABLES 

An alternative is taking an SQL dump of the master instead of a binary copy like above; for this you can use mysqldump --master-data on your master and later run this SQL dump into your slave. However, this is slower than makeing a binary copy.

No matter which of the two methods you use, afterwards follow the instructions for the case when you have a snapshot and have recorded the log name and offset. You can use the same snapshot to set up several slaves. As long as the binary logs of the master are left intact, you can wait as long as several days or in some cases maybe a month to set up a slave once you have the snapshot of the master. In theory the waiting gap can be infinite. The two practical limitations is the diskspace of the master getting filled with old logs, and the amount of time it will take the slave to catch up.

You can also use LOAD DATA FROM MASTER. This is a convenient command that takes a snapshot, restores it to the slave, and adjusts the log name and offset on theslave all at once. In the future, LOAD DATA FROM MASTER will be the recommended way to set up a slave. Be warned, howerver, that the read lock may be held for a long time if you use this command. It is not yet implemented as efficiently as we would like to have it. If you have large tables, the preferred method at this time is still with a local tar snapshot after executing FLUSH TABLES WITH READ LOCK.

Contrains

Foreign keys definitions are subject to the following conditions:

Both tables must be InnoDB type!

In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order.

In the referenced table, there must be an index where the referenced columns are listed as the first columns in the same order.

Index prefixes on foreign key columns are not supported. One consequence of this is that BLOB and TEXT columns cannot be included in a foreign key, because indexes on those columns must always include a prefix length.

 [CONSTRAINT symbol] FOREIGN KEY [id] (index_col_name, ...)
   REFERENCES tbl_name (index_col_name, ...)
   [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}]
   [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}]

 SET FOREIGN_KEY_CHECKS = 0; or SET FOREIGN_KEY_CHECKS = 1;
How to import a *.sql generated recovery file?
 mysql -u root -p
   -> USE asnmtap;

      If you use LOAD DATA INFILE ... the file must be on the server
   -> LOAD DATA LOW_PRIORITY INFILE '<filename>.sql' INTO TABLE events FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n';

      If you use LOAD DATA LOCAL INFILE ... the file is expected to be on the client.
      If you specify the keyword LOW_PRIORITY, execution of the LOAD DATA statement is delayed until no other clients are reading from the table. 
   -> LOAD DATA LOW_PRIORITY LOCAL INFILE '<filename>.sql' INTO TABLE events FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n';
How to import drop a InnoDB table that is referenced by a FOREIGN KEY constraint?

InnoDB does not allow you to drop a table that is referenced by a FOREIGN KEY constraint, unless you do SET FOREIGN_KEY_CHECKS=0. When you drop a table, the constraints that were defined in its create statement are also dropped.

EXPORT

...

AUTHOR

Alex Peeters [alex.peeters@citap.be]

SEE ALSO

ASNMTAP::Asnmtap, ASNMTAP::Asnmtap::Applications::CGI, ASNMTAP::Asnmtap::Applications::Collector, ASNMTAP::Asnmtap::Applications::Display

DEPENDENCIES

 ASNMTAP::Time
 ASNMTAP::Asnmtap
 Carp
 Config::General
 Config::General::Interpolated
 Getopt::Long
 HTML::Entities
 Mail::Sendmail
 Time::Local

COPYRIGHT NOTICE

(c) Copyright 2000-2006 by Alex Peeters [alex.peeters@citap.be], All Rights Reserved.

ASNMTAP is based on 'Process System daemons v1.60.17-01', Alex Peeters [alex.peeters@citap.com]

 Purpose: CronTab (CT, sysdCT),
          Disk Filesystem monitoring (DF, sysdDF),
          Intrusion Detection for FW-1 (ID, sysdID)
          Process System daemons (PS, sysdPS),
          Reachability of Remote Hosts on a network (RH, sysdRH),
          Rotate Logfiles (system activity files) (RL),
          Remote Socket monitoring (RS, sysdRS),
          System Activity monitoring (SA, sysdSA).

'Process System daemons' is based on 'sysdaemon 1.60' written by Trans-Euro I.T Ltd

LICENSE

This ASNMTAP CPAN library and Plugin templates are free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The other parts of ASNMTAP may be used and modified free of charge by anyone so long as this copyright notice and the comments above remain intact. By using this code you agree to indemnify Alex Peeters from any liability that might arise from it's use.

Selling the code for this program without prior written consent is expressly forbidden. In other words, please ask first before you try and make money off of my program.

Obtain permission before redistributing this software over the Internet or in any other medium. In all cases copyright and header must remain intact.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 127:

Non-ASCII character seen before =encoding in '©'. Assuming CP1252