This file is indexed.

/usr/sbin/bd_pgsql_purge is in bandwidthd-pgsql 2.0.1+cvs20090917-7.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh

echo "SET sort_mem TO 45000;"
for TABLE in bd_rx_log bd_tx_log bd_rx_total_log bd_tx_total_log
do
cat << EOF
BEGIN;
insert into $TABLE (sensor_id, ip, timestamp, sample_duration, total, icmp, udp, tcp, ftp, http, p2p) 
select sensor_id, ip, 
date_trunc('day', timestamp) + (case when extract(hour from timestamp) >= 12 then interval '12 hours' 
else interval '0 hours' end) + interval '12 hours',
60*60*12, sum(total), sum(icmp), sum(udp), sum(tcp), sum(ftp), sum(http), sum(p2p)

from $TABLE
where sample_duration < 60*60*12
and timestamp < now() - interval '35 days'
group by sensor_id, ip, 
date_trunc('day', timestamp) + (case when extract(hour from timestamp) >= 12 then interval '12 hours'
else interval '0 hours' end);                                                                                                                             

delete from $TABLE where sample_duration < 60*60*12 and timestamp < now() - interval '35 days';
COMMIT;
BEGIN;
insert into $TABLE (sensor_id, ip, timestamp, sample_duration, total, icmp, udp, tcp, ftp, http, p2p) 
select sensor_id, ip, 
date_trunc('hour', timestamp)+interval '1 hour', 
60*60, sum(total), sum(icmp), sum(udp), sum(tcp), sum(ftp), sum(http), sum(p2p)

from $TABLE
where sample_duration < 60*60
and timestamp < now() - interval '7 days'
group by sensor_id, ip, 
date_trunc('hour', timestamp);

delete from $TABLE where sample_duration < 60*60 and timestamp < now() - interval '7 days';
COMMIT;
BEGIN;
insert into $TABLE (sensor_id, ip, timestamp, sample_duration, total, icmp, udp, tcp, ftp, http, p2p)
select sensor_id, ip, 
date_trunc('hour', timestamp) + (interval '1 minute' * trunc(EXTRACT(MINUTE FROM timestamp)::numeric,-1)) 
+ interval '10 minutes',
10*60, sum(total), sum(icmp), sum(udp), sum(tcp), sum(ftp), sum(http), sum(p2p)
                                                                                                                             
from $TABLE
where sample_duration < 10*60
and timestamp < now() - interval '2 days'
group by sensor_id, ip, 
date_trunc('hour', timestamp) + (interval '1 minute' * trunc(EXTRACT(MINUTE FROM timestamp)::numeric,-1));

delete from $TABLE where sample_duration < 10*60 and timestamp < now() - interval '2 days';
COMMIT;
EOF
done
echo "VACUUM ANALYZE"