Skip to content

Commit 5b363b0

Browse files
committed
add removal and alert rules
1 parent 497009a commit 5b363b0

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

.github/workflows/populate_syslog_incoming.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,44 @@
44
# Number of iterations
55
ITERATIONS=100
66

7-
# SQL statement to execute
8-
SQL_INSERT="INSERT INTO syslog_incoming (facility_id, priority_id, program, logtime, host, message, status) VALUES
7+
8+
SQL_ALERT_RULE_INSERT="INSERT INTO syslog_alert (id,hash,name,severity,method,level,num,type,enabled,repeat_alert,open_ticket,message,body,user,date,email,notify,command,notes)
9+
VALUES (1,'8f440030d3425e37cb66e5df54902bb0','interface down alert',1,0,1,1,'messageb','on',0,'','interface down','admin',1767376990,NULL,0,NULL,NULL);"
10+
11+
SQL_REMOVAL_RULE_INSERT="INSERT INTO syslog_remove (id,hash,name,type,enabled,method,message,user,date,notes)
12+
VALUES (1,'0faf589f7b6b7da1bcec40b92340487d','exploded','messageb','on','del',
13+
'the box exploded','admin',1767376604,NULL);"
14+
15+
16+
SYSLOG_EVENTS_INSERT="INSERT INTO syslog_incoming (facility_id, priority_id, program, logtime, host, message, status) VALUES
917
(1, 1, 'app1', NOW(), 'bob', 'interface down', 0),
1018
(2, 3, 'app2', NOW(), 'alice', 'cpu high', 1),
1119
(1, 2, 'app1', NOW(), 'router_1', 'the box exploded', 0);"
1220

21+
1322
echo "Starting insert of $ITERATIONS batches (30,000 total records)..."
1423
echo "Start time: $(date)"
1524

1625
# MySQL connection parameters
1726
export MYSQL_PWD="cactiuser"
1827
MYSQL_CMD="mysql -h 127.0.0.1 -u cactiuser cacti"
1928

20-
# Loop and insert
29+
# Create Rules
30+
$MYSQL_CMD -e "$SQL_ALERT_RULE_INSERT"
31+
$MYSQL_CMD -e "$SQL_REMOVAL_RULE_INSERT"
32+
33+
34+
# Create test syslog events
2135
for i in $(seq 1 $ITERATIONS); do
22-
$MYSQL_CMD -e "$SQL_INSERT"
36+
$MYSQL_CMD -e "$SYSLOG_EVENTS_INSERT"
2337

2438
# Show progress every 100 iterations
2539
if [ $((i % 100)) -eq 0 ]; then
2640
echo "Progress: $i / $ITERATIONS batches inserted"
2741
fi
2842
done
2943

44+
3045
echo "Completed!"
3146
echo "End time: $(date)"
3247
echo "Total records inserted: $((ITERATIONS * 3))"

0 commit comments

Comments
 (0)