...
Setting the Log Level Permanently To make a permanent change, omit the
-t
parameter:Code Block bash
Copy code
3./log_level_script.sh -d 192.168.1.100 -p admin:password -i
15
This sets the log level to 3 15 permanently until you manually change it.
Setting the Log Level Temporarily Specify a duration (in seconds) with the
-t
parameter to revert automatically after a defined period: bashCode Block Copy
3Code Block ./log_level_script.sh -d 192.168.1.100 -p admin:password -i
15 -t 600
In this example, the log level is set to 3 15 and reverts to the original level after 600 seconds (10 minutes).
Monitoring Log File Size
The script identifies the log file (
castor.log
) in either/var/log/caringo/
or/var/log/datacore/
.Initial file size is shown before setting the new log level.
Final file size and size difference are displayed after the temporary duration ends, indicating logs generated during this period.
Output Details
The script displays Swarm IP, log file location, initial and final log file sizes, and the cluster name.
For temporary log levels, a countdown timer displays time remaining before reverting.
Once completed, it provides the approximate amount of logs generated, duration, and confirms reversion to the original log level.
Example Output
Code Block |
---|
Swarm IP: 192.168.1.100 Credentials: [hidden for security] Cluster Name: Cluster_01 Log file located at: /var/log/datacore/castor.log Initial log file size: 10.5MB Retrieving the current log level... New log level: 15 Current log level is 30. Updating log level to 15... Log level changed successfully from 30 → 15. Keeping log level at 15 for 600 second(s)... Time's up! Reverting log level back to 30... Approximate 1.2MB new logs were generated at log level 15. Current castor.log size is 11.7MB after 00:10:00. Log level reverted successfully back to 30. |
Error Handling
Missing Parameters: Missing parameters prompt a usage message.
Invalid Duration: If a non-numeric duration is provided, you’re prompted to enter a valid duration in seconds.
Connection Issues: If unable to connect to the Swarm API, check the IP, credentials, and network access.
Notes
Credentials are masked in the output for security.
Log file sizes are shown in human-readable format (GB, MB, KB, B).
...