diff options
Diffstat (limited to 'awk/rawk/scratch/tests_old/real_world/README.md')
-rw-r--r-- | awk/rawk/scratch/tests_old/real_world/README.md | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/awk/rawk/scratch/tests_old/real_world/README.md b/awk/rawk/scratch/tests_old/real_world/README.md new file mode 100644 index 0000000..c4ba349 --- /dev/null +++ b/awk/rawk/scratch/tests_old/real_world/README.md @@ -0,0 +1,130 @@ +# Real-World Examples + +This directory contains practical examples that demonstrate rawk's utility for common data processing tasks. + +## Test Files + +### `test_system_monitor.rawk` - System Monitoring +Processes output from common system commands: +- **df**: Disk usage monitoring with warnings +- **ps**: Process resource analysis +- **ls -l**: File categorization and statistics + +**Features:** +- Disk usage alerts (WARNING/CRITICAL thresholds) +- Process resource monitoring (CPU/MEM usage) +- File type categorization (DIRECTORY/EXECUTABLE/LARGE/SMALL) +- Statistical summaries + +**Run with:** +```bash +awk -f ../../rawk.awk test_system_monitor.rawk | awk -f - ../data/test_data.txt +``` + +**Sample Output:** +``` +DISK: WARNING: /dev/sdb1 (/home) is 90% full +PROCESS: HIGH CPU: stress (PID: 3456, 25.7% CPU) +FILE: EXECUTABLE: executable.sh (2048 bytes) +``` + +### `test_log_parser.rawk` - Log Parsing +Processes common log formats: +- **Apache logs**: Web server access logs +- **Syslog**: System log entries + +**Features:** +- HTTP status code categorization (SUCCESS/ERROR/REDIRECT) +- Log level detection (INFO/WARNING/ERROR) +- Request type classification +- Error rate calculation + +**Run with:** +```bash +awk -f ../../rawk.awk test_log_parser.rawk | awk -f - ../data/test_logs.txt +``` + +**Sample Output:** +``` +APACHE: ERROR: 404 - GET /nonexistent.html from 192.168.1.104 +SYSLOG: ERROR: kernel - ERROR: Out of memory +``` + +### `test_csv_processor.rawk` - CSV Data Processing +Processes CSV files with validation: +- **Email validation**: Basic email format checking +- **Age categorization**: Group employees by age +- **Salary statistics**: Calculate averages and ranges +- **Department analysis**: Employee distribution + +**Features:** +- Data validation and categorization +- Statistical analysis +- Report generation +- Error detection + +**Run with:** +```bash +awk -f ../../rawk.awk test_csv_processor.rawk | awk -f - ../data/test_employees.csv +``` + +**Sample Output:** +``` +EMPLOYEE: John Smith (ADULT, Engineering) - VALID email, $65000 +Average salary: $73916.7 +Email validity rate: 100% +``` + +### `test_data_processing.rawk` - General Data Processing +General data processing scenarios: +- Array filtering and manipulation +- Data aggregation +- Formatting and reporting + +**Run with:** +```bash +awk -f ../../rawk.awk test_data_processing.rawk | awk -f - +``` + +### `test_mixed.rawk` - Mixed awk/rawk Code +Demonstrates mixing rawk functions with regular awk code: +- Line-by-line processing +- Integration with awk patterns +- Combined functionality + +**Run with:** +```bash +awk -f ../../rawk.awk test_mixed.rawk | awk -f - ../data/test_input.txt +``` + +## Use Cases + +These examples demonstrate rawk's practical applications: + +### System Administration +- Monitor disk usage and alert on thresholds +- Track process resource consumption +- Analyze file system contents + +### Web Server Management +- Parse and analyze web server logs +- Monitor error rates and traffic patterns +- Identify problematic requests + +### Data Analysis +- Process CSV files with validation +- Generate business intelligence reports +- Analyze employee or customer data + +### Log Analysis +- Parse various log formats +- Identify system issues +- Generate operational reports + +## Data Files + +The examples use sample data files in the `../data/` directory: +- `test_data.txt`: Simulated system command outputs +- `test_logs.txt`: Sample Apache and syslog entries +- `test_employees.csv`: Sample employee data +- `test_input.txt`: Simple input data for mixed tests \ No newline at end of file |