TYPE-0
FILEMANAGER
UP LEVEL
HOME
EXIT
Current Directory:
scripts2
/
EDIT: find_accounts_with_many_files_custom.sh
#!/bin/bash report_file='/tmp/report_inodes.txt' trusted_accounts_file='/etc/higher_inodes_accounts.conf' normal_threshold=30000 # Default threshold hostname=$(hostname) # Ensure config file exists [[ ! -f "$trusted_accounts_file" ]] && touch "$trusted_accounts_file" && chmod 644 "$trusted_accounts_file" declare -A custom_thresholds # Load trusted accounts and thresholds while IFS='=' read -r user threshold || [[ -n "$user" ]]; do user=$(echo "$user" | xargs) threshold=$(echo "$threshold" | xargs) custom_thresholds["$user"]=$threshold done < "$trusted_accounts_file" > "$report_file" # Get cPanel users via WHM API user_list=$(whmapi1 listaccts | awk -F': ' '/user: / {print $2}') # Target folders to scan scan_targets=("mail" "public_html" "tmp") for user in $user_list; do home_path="/home/$user" [[ ! -d "$home_path" ]] && continue threshold=${custom_thresholds[$user]:-$normal_threshold} total_inodes=0 user_report=() for subdir in "${scan_targets[@]}"; do target="$home_path/$subdir" [[ ! -d "$target" ]] && continue while IFS= read -r dir; do inode_count=$(find "$dir" -type f 2>/dev/null | wc -l) #echo "$dir → $inode_count" # Esta linea es DEBUG MODE para ver output en pantalla total_inodes=$((total_inodes + inode_count)) if (( inode_count >= threshold )); then user_report+=("$dir ($inode_count files)") fi done < <(find "$target" -maxdepth 3 -type d) done if (( ${#user_report[@]} > 0 )); then [[ -n "${custom_thresholds[$user]}" ]] && label="(custom limit allowed)" || label="" { echo "$user – $total_inodes inodes $label" printf '%s\n' "${user_report[@]}" echo "" } >> "$report_file" fi done # Send email only if report has content [[ -s "$report_file" ]] && mail -s "Inode usage alert – $hostname" sysadmin@sitioshispanos.com < "$report_file"
SAVE CHANGES
BACK TO DIR
TYPE-0 MANAGER © 2026 |
System Ready