|
4 | 4 | # Number of iterations |
5 | 5 | ITERATIONS=100 |
6 | 6 |
|
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 |
9 | 17 | (1, 1, 'app1', NOW(), 'bob', 'interface down', 0), |
10 | 18 | (2, 3, 'app2', NOW(), 'alice', 'cpu high', 1), |
11 | 19 | (1, 2, 'app1', NOW(), 'router_1', 'the box exploded', 0);" |
12 | 20 |
|
| 21 | + |
13 | 22 | echo "Starting insert of $ITERATIONS batches (30,000 total records)..." |
14 | 23 | echo "Start time: $(date)" |
15 | 24 |
|
16 | 25 | # MySQL connection parameters |
17 | 26 | export MYSQL_PWD="cactiuser" |
18 | 27 | MYSQL_CMD="mysql -h 127.0.0.1 -u cactiuser cacti" |
19 | 28 |
|
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 |
21 | 35 | for i in $(seq 1 $ITERATIONS); do |
22 | | - $MYSQL_CMD -e "$SQL_INSERT" |
| 36 | + $MYSQL_CMD -e "$SYSLOG_EVENTS_INSERT" |
23 | 37 |
|
24 | 38 | # Show progress every 100 iterations |
25 | 39 | if [ $((i % 100)) -eq 0 ]; then |
26 | 40 | echo "Progress: $i / $ITERATIONS batches inserted" |
27 | 41 | fi |
28 | 42 | done |
29 | 43 |
|
| 44 | + |
30 | 45 | echo "Completed!" |
31 | 46 | echo "End time: $(date)" |
32 | 47 | echo "Total records inserted: $((ITERATIONS * 3))" |
|
0 commit comments