BTW:

I've just written a small shell-script which I'm executing as a user-
cronjob once per hour, which alerts me in case this happens again:

```shell
#!/bin/bash

SYSLOG="/var/log/syslog"
MAX_GROWTH_LINES=100000  # Max allowed lines since last invocation
ALERT_EMAIL="[email protected]"

# Store previous line count in a temp file
COUNT_FILE="/tmp/syslog_line_count.tmp"

if [ -f "$COUNT_FILE" ]; then
    PREV_COUNT=$(cat "$COUNT_FILE")
else
    PREV_COUNT=$(wc -l < "$SYSLOG")
    echo "$PREV_COUNT" > "$COUNT_FILE"
    exit 0
fi

CURRENT_COUNT=$(wc -l < "$SYSLOG")
GROWTH=$((CURRENT_COUNT - PREV_COUNT))

last_modified=$(date -r "$COUNT_FILE" +%s)  # Get modification time in seconds
now=$(date +%s)
diff_seconds=$((now - last_modified))
human_readable=$(date -d "@$last_modified" +"%F %T")  # Convert to readable 
datetime
time_ago=$(date -d "@$last_modified" +"%F %T was %A, %Y-%m-%d (%H:%M:%S)")  # 
More verbose

if [ "$GROWTH" -gt "$MAX_GROWTH_LINES" ]; then
    echo "Warning: $SYSLOG grew by ${GROWTH} lines within $(date -d 
"@$diff_seconds" -u +"%H hours, %M minutes, %S seconds") (max allowed: 
${MAX_GROWTH_LINES})" | \
    mail -s "Syslog Growth Alert" "$ALERT_EMAIL"
    notify-send -u critical "Syslog Alert" "Syslog grew by ${GROWTH} lines 
within $(date -d "@$diff_seconds" -u +"%H hours, %M minutes, %S seconds") (max 
allowed: ${MAX_GROWTH_LINES})"
fi

# Update the count file
echo "$CURRENT_COUNT" > "$COUNT_FILE"
```

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2110082

Title:
  syslog spammed with "file not found" errors

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/tracker-miners/+bug/2110082/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to