-TESTS = createdb upgradedb read_messages read_bad_messages read_apache_error read_without_hostname
+TESTS = createdb upgradedb read_messages read_bad_messages read_apache_error read_without_hostname \
+ notifications
clean-local:
rm -f gcm_input.log log.tbl
--- /dev/null
+#!/bin/bash
+
+#
+# Test the service and log check notifications.
+# Create a database with two objects and no services. After reading two
+# log file fragments for these two objects, gcm_daemon should create
+# several notifications, three for each object.
+#
+# This tests problem report nr. 23
+
+#LD_LIBRARY_PATH=/usr/local/pqxx/lib
+#export LD_LIBRARY_PATH
+
+
+rm -f gcm_input.log
+
+createdb gnucomo_test
+
+result=0
+
+if psql gnucomo_test -q <../src/database/create.sql >/dev/null
+then
+ # Prepare the database
+
+ psql gnucomo_test -q -c "insert into object (objectname) values ('example1.gnucomo.test')"
+ psql gnucomo_test -q -c "insert into object (objectname) values ('example2.gnucomo.test')"
+ psql gnucomo_test -q -c "delete from service"
+
+ # read logs for both objects
+
+ ../src/gcm_input/gcm_input -c gnucomo_test -h example1.gnucomo.test -d 'sep 5 2002 20:30:45' <messages.bad
+ ../src/gcm_input/gcm_input -c gnucomo_test -h example2.gnucomo.test -d 'sep 5 2002 20:30:45' <messages
+
+ # Make the notifications.
+ cd ../src/gcm_daemon; ./gcm_daemon.php -c gnucomo_test; cd ../../test
+
+ # Check the notifications, 3 for each object.
+
+ NR_NOTIF1=`psql gnucomo_test -q -t -c "select count(*) from notification where objectid=1"`
+ NR_NOTIF2=`psql gnucomo_test -q -t -c "select count(*) from notification where objectid=2"`
+
+ if [[ $NR_NOTIF1 -ne 3 ]]
+ then
+ echo "$NR_NOTIF1 notifications for object 1 (3 expected)."
+ result=2
+ fi
+
+ if [[ $NR_NOTIF2 -ne 3 ]]
+ then
+ echo "$NR_NOTIF2 notifications for object 2 (3 expected)."
+ result=3
+ fi
+
+ # Clean up.
+
+ psql gnucomo_test -f ../src/database/destroy.sql -q
+ dropdb gnucomo_test
+
+ exit $result
+else
+ echo Can not create test database
+ dropdb gnucomo_test
+ exit 1
+fi
+++ /dev/null
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "object_abuse_pkey" for table "object_abuse"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "object_statistics_pkey" for table "object_statistics"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_pkey" for table "parameter"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_class_pkey" for table "parameter_class"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_notification_pkey" for table "parameter_notification"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "property_pkey" for table "property"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "service_pattern_pkey" for table "service_pattern"
-ERROR: role "view" already exists
-ERROR: role "ops" already exists
-ERROR: role "admin" already exists
-ERROR: role "daemon" already exists
-ERROR: role "gnucomo" already exists
-Can not determine the hostname where the message came from.
+++ /dev/null
- objectid | objectname | objectcode | scp_enabled | scp_inet | mail_enabled | mail_from | sms_enabled | sms_number | fax_enabled | fax_number | object_description | object_owner | physical_location | timezone | remark | os | os_version | log_count | notification_count | parameter_count
-----------+----------------------+------------+-------------+----------+--------------+-----------+-------------+------------+-------------+------------+--------------------+--------------+-------------------+----------+--------+----+------------+-----------+--------------------+-----------------
- 1 | kithira.andromeda.nl | | | | | | | | | | | | | | | | | | |
-(1 row)
-
- logid | objectid | original_filename | servicecode | object_timestamp | timestamp | rawdata | processed | recognized
--------+----------+-------------------+-------------+------------------+-----------+---------+-----------+------------
-(0 rows)
-
+++ /dev/null
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "object_abuse_pkey" for table "object_abuse"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "object_statistics_pkey" for table "object_statistics"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_pkey" for table "parameter"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_class_pkey" for table "parameter_class"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_notification_pkey" for table "parameter_notification"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "property_pkey" for table "property"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "service_pattern_pkey" for table "service_pattern"
-ERROR: role "view" already exists
-ERROR: role "ops" already exists
-ERROR: role "admin" already exists
-ERROR: role "daemon" already exists
-ERROR: role "gnucomo" already exists
+++ /dev/null
- objectid | objectname | objectcode | scp_enabled | scp_inet | mail_enabled | mail_from | sms_enabled | sms_number | fax_enabled | fax_number | object_description | object_owner | physical_location | timezone | remark | os | os_version | log_count | notification_count | parameter_count
-----------+----------------------+------------+-------------+----------+--------------+-----------+-------------+------------+-------------+------------+--------------------+--------------+-------------------+----------+--------+----+------------+-----------+--------------------+-----------------
- 1 | kithira.andromeda.nl | | | | | | | | | | | | | | | | | | |
-(1 row)
-
- logid | objectid | original_filename | servicecode | object_timestamp | timestamp | rawdata | processed | recognized
--------+----------+-------------------+-------------+------------------------+------------------------+---------------------------------------------------------------------------------------------------------+-----------+------------
- 1 | 1 | | syslogd | 2002-09-01 04:02:51+02 | 2002-09-05 00:00:00+02 | Sep 1 04:02:51 kithira syslogd 1.4.1: restart. | f | f
- 2 | 1 | | CROND | 2002-09-01 04:10:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:10:00 kithira CROND[17405]: (root) CMD ( /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) | f | f
- 3 | 1 | | kernel | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira kernel: isdn_net: local hangup ippp0 | f | f
- 4 | 1 | | kernel | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira kernel: ippp0: Chargesum is 0 | f | f
- 5 | 1 | | ipppd | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira ipppd[1513]: Modem hangup | f | f
- 6 | 1 | | ipppd | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira ipppd[1513]: Connection terminated. | f | f
- 7 | 1 | | ipppd | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira ipppd[1513]: taking down PHASE_DEAD link 0, linkunit: 0 | f | f
- 8 | 1 | | ipppd | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira ipppd[1513]: closing fd 7 from unit 0 | f | f
- 9 | 1 | | ipppd | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira ipppd[1513]: link 0 closed , linkunit: 0 | f | f
- 10 | 1 | | ipppd | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira ipppd[1513]: reinit_unit: 0 | f | f
- 11 | 1 | | ipppd | 2002-09-01 04:11:07+02 | 2002-09-05 00:00:00+02 | Sep 1 04:11:07 kithira ipppd[1513]: Connect[0]: /dev/ippp0, fd: 7 | f | f
- 12 | 1 | | CROND | 2002-09-01 04:15:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:15:00 kithira CROND[17423]: (uucp) CMD (/usr/sbin/uucico -r1) | f | f
- 13 | 1 | | CROND | 2002-09-01 04:20:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:20:00 kithira CROND[17581]: (root) CMD ( /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) | f | f
- 14 | 1 | | kernel | 2002-09-01 04:20:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:20:00 kithira kernel: solo1: unloading | f | f
- 15 | 1 | | kernel | 2002-09-01 04:20:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:20:00 kithira kernel: Uniform CD-ROM driver unloaded | f | f
- 16 | 1 | | kernel | 2002-09-01 04:20:01+02 | 2002-09-05 00:00:00+02 | Sep 1 04:20:01 kithira kernel: ide-floppy driver 0.99.newide | f | f
- 17 | 1 | | kernel | 2002-09-01 04:20:02+02 | 2002-09-05 00:00:00+02 | Sep 1 04:20:02 kithira kernel: hdb: ATAPI 40X CD-ROM drive, 128kB Cache, DMA | f | f
- 18 | 1 | | kernel | 2002-09-01 04:20:02+02 | 2002-09-05 00:00:00+02 | Sep 1 04:20:02 kithira kernel: Uniform CD-ROM driver Revision: 3.12 | f | f
- 19 | 1 | | kernel | 2002-09-01 04:20:02+02 | 2002-09-05 00:00:00+02 | Sep 1 04:20:02 kithira kernel: Attached scsi CD-ROM sr0 at scsi0, channel 0, id 4, lun 0 | f | f
- 20 | 1 | | kernel | 2002-09-01 04:20:02+02 | 2002-09-05 00:00:00+02 | Sep 1 04:20:02 kithira kernel: sr0: scsi3-mmc drive: 20x/20x writer cd/rw xa/form2 cdda tray | f | f
- 21 | 1 | | CROND | 2002-09-01 04:22:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:22:00 kithira CROND[17587]: (root) CMD (run-parts /etc/cron.weekly) | f | f
- 22 | 1 | | anacron | 2002-09-01 04:22:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:22:00 kithira anacron[17591]: Error opening /etc/anacrontab: No such file or directory | f | f
- 23 | 1 | | anacron | 2002-09-01 04:22:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:22:00 kithira anacron[17591]: Aborted | f | f
- 24 | 1 | | CROND | 2002-09-01 04:30:00+02 | 2002-09-05 00:00:00+02 | Sep 1 04:30:00 kithira CROND[27975]: (root) CMD ( /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) | f | f
- 25 | 1 | | su | 2002-09-01 04:30:51+02 | 2002-09-05 00:00:00+02 | Sep 1 04:30:51 kithira su(pam_unix)[27979]: session opened for user news by (uid=0) | f | f
- 26 | 1 | | su | 2002-09-01 04:30:51+02 | 2002-09-05 00:00:00+02 | Sep 1 04:30:51 kithira su(pam_unix)[27979]: session closed for user news | f | f
- 27 | 1 | | named | 2002-09-01 04:31:03+02 | 2002-09-05 00:00:00+02 | Sep 1 04:31:03 kithira named[996]: listening on IPv4 interface ippp0, 195.121.198.124#53 | f | f
- 28 | 1 | | named | 2002-09-01 04:31:03+02 | 2002-09-05 00:00:00+02 | Sep 1 04:31:03 kithira named[996]: no longer listening on 195.121.198.217#53 | f | f
-(28 rows)
-
+++ /dev/null
-#!/bin/sh
-
-#
-# Create an object 'kithira.andromeda.nl' in the database and
-# parse a piece of a syslog file without specifying a time.
-# This tests wether an improper time still creates valid data.
-
-cd ..
-
-if psql gnucomo_test -q <src/database/create.sql >/dev/null
-then
- psql gnucomo_test -q -c "insert into object (objectname) values ('kithira.andromeda.nl')"
- psql gnucomo_test -c "select * from object"
- src/gcm_input/gcm_input -c gnucomo_test -h kithira.andromeda.nl -d 'sep 5 2002' <test/messages
- psql gnucomo_test -c "select * from log"
- psql gnucomo_test -f src/database/destroy.sql -q
- exit $result
-else
- echo Can not create test database
- exit 1
-fi
+++ /dev/null
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "object_abuse_pkey" for table "object_abuse"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "object_statistics_pkey" for table "object_statistics"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_pkey" for table "parameter"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_class_pkey" for table "parameter_class"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parameter_notification_pkey" for table "parameter_notification"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "property_pkey" for table "property"
-NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "service_pattern_pkey" for table "service_pattern"
-ERROR: role "view" already exists
-ERROR: role "ops" already exists
-ERROR: role "admin" already exists
-ERROR: role "daemon" already exists
-ERROR: role "gnucomo" already exists
-gcm_input WARNING: Not a valid line: nearly empty line
-gcm_input WARNING: Not a valid line: Jun 5 04:02:16 vd
+++ /dev/null
-Processing logs...
-Last processed logid = 0
-Running service check from log id 0.
-Gathering statistics for object 2
-Gathering statistics for object 1
-
- notificationid | objectid | type_of_issueid
-----------------+----------+-----------------
- 1 | 2 | 8
- 2 | 2 | 10
- 3 | 1 | 8
- 4 | 1 | 9
- 5 | 2 | 5
- 6 | 1 | 5
-(6 rows)
-
+++ /dev/null
-#!/bin/sh
-
-#
-# Test the service and log check notifications.
-# Create a database with two objects and no services. After reading two
-# log file fragments for these two objects, gcm_daemon should create
-# several notifications, three for each object.
-#
-# This tests problem report nr. 23
-
-LD_LIBRARY_PATH=/usr/local/pqxx/lib
-export LD_LIBRARY_PATH
-
-cd ..
-
-if psql gnucomo_test -q <src/database/create.sql >/dev/null
-then
- # Prepare the database
-
- psql gnucomo_test -q -c "insert into object (objectname) values ('kithira.andromeda.nl')"
- psql gnucomo_test -q -c "insert into object (objectname) values ('vd.wt.tno.nl')"
- psql gnucomo_test -q -c "delete from service"
-
- # read logs for both objects
-
- src/gcm_input/gcm_input -c gnucomo_test -h vd.wt.tno.nl -d 'sep 5 2002 20:30:45' <test/vd.messages
- src/gcm_input/gcm_input -c gnucomo_test -h kithira.andromeda.nl -d 'sep 5 2002 20:30:45' <test/messages
-
- # Make the notifications.
- cd src/gcm_daemon; ./gcm_daemon.php -c gnucomo_test; cd ../..
-
- # Check the notifications.
-
- psql gnucomo_test -c "select notificationid,objectid,type_of_issueid from notification"
-
- # Clean up.
-
- psql gnucomo_test -f src/database/destroy.sql -q
-
- exit 0
-else
- echo Can not create test database
- exit 1
-fi