OK, here it is, a self contained rule with notification and php program to monitor it...
Here's the php program:
#!/usr/bin/php -q
<?php
$conn = pg_connect("dbname=test user=user");
pg_query("listen record_deleted");
$interval = 10;
for (;1;){
sleep($interval);
$notify = pg_get_notify($conn);
if ($notify){
print "Now we do something";
}
}
?>
And the sql code:
CREATE TABLE ntest (
id serial primary key,
path text
);
create table naudit (
id int primary key,
path text
);
create rule audit_test as on delete to ntest do (
insert into naudit(id,path) values (OLD.id, OLD.path);
notify record_deleted
);
insert into ntest (path) values ('/usr/local/lib/php.ini2');
delete from ntest;