Comments (4)
Knocked out some test code that works:
#!/usr/bin/perl
use strict;
my $log_dir;
my $size;
$log_dir = "/var/log/"; # would need logic to set $log_dir based on distribution
$size = 1024; # this is bytes, I know, for testing only!
print "Scanning $log_dir for files larger than $size bytes....\n";
opendir(my $dh, $log_dir) || die "Can't open $log_dir: $!";
while (readdir $dh) {
if ( -s >= $size ) {
print "$_\n";
}
}
from apache2buddy.
Test code committed to a test repository for ease of testing on different platforms, to develop the logic further
https://github.com/richardforth/perl_large_file_scanner/
from apache2buddy.
Working, next step is to merge into the main codebase of apache2buddy under staging.
from apache2buddy.
There is also a working function now in checkbox4 which is ready to port across (uses File::Find):
sub systemcheck_large_logs {
my ($logdir) = @_;
our $ymdhms;
my $logfile = $logdir . "/" . $ymdhms . "_large_logs.log";
unless (open(LOG_FILE, ">$logfile")) {
die "Can't open log file $logfile for writing: $!\n"
}
info_print("Scanning /var/log for files larger than 1GB:");
my $dir = '/var/log'; # whatever you want the starting directory to be
my @logs;
my $logfiles_raw = find(sub {push @logs, $File::Find::name if -s >= 1024000000;}, $dir);
foreach my $log (@logs) {
chomp($log);
my $size = -s $log;
my $humansize = sprintf "%.2f", $size/1024/1024/1024;
bad_print_item($log . " --> " . $humansize . "GB");
print LOG_FILE $log . " --> " . $humansize . "GB\n";
}
if (@logs == 0) {
good_print_item("No large logs files were found.");
} else {
bad_print("Consider setting up a log rotation policy.");
}
}
from apache2buddy.
Related Issues (20)
- Buddy cannot load includes HOT 4
- Support new debian stable HOT 4
- make it compatible with Litespeed HOT 1
- Plans to Support AlmaLinux 8.x and CloudLinux 7.9? HOT 5
- AmazonLinux Docker: Cannot find the 'hostname' executable. HOT 2
- AmazonLinux [ !! ] Python scripting failed. Python requires package 'distro' or 'platform' to determine the Operating System and Version. HOT 6
- Newer versions of python throw deprecation warnings HOT 5
- [ LOW PRIORITY ] Unable to detect apache on nonstandard ports - EOL Ubunutu 1604 with --skip-os-version-check HOT 1
- SS support along with netstat HOT 10
- Apache2buddy does not find apache on bitnami installation HOT 10
- --- a2bchk.sh --- showing MD5 mismatch HOT 4
- Add support for Ubuntu 22.04 HOT 8
- Add tests for ansible playbook in all Jenkins stages HOT 1
- Debian 12 support
- Running ISPconfig on ARM64: Bullseye with Linux 5.10.110-rockchip-rk3588: uninitialized value $apache_proc_php in concatenation (.) or string at - line 2524 (#1) HOT 1
- sub detect_php_memory_limit has hardcoded php executable path
- Support for Oracle Linux Server HOT 1
- Error: Illegal division by zero at line 987 HOT 4
- Support for SLES 12 with worker MPM HOT 1
- including Gentoo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apache2buddy.