Pages

Friday, February 16, 2024

All the databases are showing size 0 MB in cpanel

When managing a server with cPanel, encountering an issue where all databases are showing as 0 MB in size can be concerning. This typically indicates a configuration issue rather than actual data loss. The solution involves a simple tweak in the cPanel configuration file and running a script to update the database cache. Here's a step-by-step guide to resolve this problem:

Step 1: Access the Server

First, you need to access your server's command line interface (CLI). This is usually done via SSH. Once logged in as the root user, you're ready to proceed to the next step.

Step 2: Edit the cPanel Configuration File

The cPanel configuration file, cpanel.config, contains various settings that control how cPanel behaves. To edit this file, you'll use the vi editor, a widely-used text editor in Unix-like operating systems. The command to open the file is:vi /var/cpanel/cpanel.config

Step 3: Modify the Configuration

While in the vi editor, you're looking to change the setting that includes database sizes in the disk usage calculations. By default, or due to a misconfiguration, this setting might be disabled (set to 0). You need to find the line that reads:
disk_usage_include_sqldb=0
and change it to:
disk_usage_include_sqldb=1

This change tells cPanel to include SQL database sizes in its disk usage calculations.

To edit in vi:
Navigate to the line using the arrow keys.
Press i to enter insert mode.
Make the necessary changes.
Press Esc to exit insert mode.
Type :wq and press Enter to save the changes and quit vi.

Step 4: Run the Update Script

After saving the changes to the cpanel.config file, you'll need to update the cPanel database cache. This is done by running a script included with cPanel:/scripts/update_db_cache


This script will process the change you've made and update the database sizes accordingly.
Conclusion

Following these steps should resolve the issue of databases showing as 0 MB in size within cPanel. It's a straightforward fix that addresses a common configuration oversight. After running the update script, you can verify the changes by checking the disk usage statistics in cPanel again. If the problem persists, it might be wise to consult with cPanel's documentation or reach out to their support for further assistance.

Troubleshooting Python Module Import Errors in Ansible

Are you encountering issues with importing Python modules in Ansible? Don't worry; you're not alone. In this blog post, we'll explore common reasons for module import errors in Ansible and provide step-by-step solutions to resolve them.

Problem Description

You may have encountered error messages like the following when running Ansible tasks:

ModuleNotFoundError: No module named 'requests'


or

ModuleNotFoundError: No module named 'pyVim'



These errors indicate that Ansible is unable to find the required Python modules (requests and pyVim) in your Python environment.

Solution Steps

Here's a breakdown of the steps you can take to resolve these module import errors:

Install Missing Python Modules: Use pip or your preferred package manager to install the missing modules. For example:
pip install requests pyVim
Verify Python Interpreter: Ensure that Ansible is using the correct Python interpreter. You can specify the Python interpreter using the ansible_python_interpreter variable in your Ansible inventory or configuration file.


Check Python Environment: Make sure that the Python environment being used by Ansible is properly configured and has the necessary permissions to access the modules.

Consider Virtual Environments: Using virtual environments can help manage Python dependencies and avoid conflicts between projects. Create a virtual environment and install the required modules inside it.

Update Ansible Configuration: If necessary, update your Ansible configuration to point to the correct Python interpreter or virtual environment.

Debugging: Enable verbose output (-vvv) to get more detailed error messages and traceback information. This can help identify the root cause of the problem.

Conclusion

By following these steps, you should be able to resolve module import errors in Ansible and ensure that your tasks run smoothly. Remember to always check your Python environment, install missing modules, and update Ansible configuration as needed.

If you continue to encounter issues, don't hesitate to consult the Ansible documentation or seek assistance from the Ansible community. With a little troubleshooting and perseverance, you'll have your Ansible playbook up and running in no time!

Stay tuned for more Ansible tips and tricks on our blog. Happy automating!

Monday, January 22, 2024

Resolving Disk Quota Discrepancies in cPanel and Server

Occasionally, you might encounter discrepancies between the disk usage reported by cPanel and the actual usage on the server. This situation can be puzzling and frustrating. This guide provides a step-by-step solution to resolve these differences and ensure that cPanel reflects the correct disk usage.

Step 1: Log in to the Server

Access your server as the root user via SSH:

ssh root@server

Once logged in, you'll have the necessary permissions to perform system-wide operations.

Step 2: Run Reset and Fix Quota Scripts

cPanel provides scripts to reset and fix quotas. Running these might resolve the issue immediately.

Reset Quotas: This script resets user quotas to ensure they're in sync:

/scripts/resetquotas

Fix Quotas: This script attempts to correct any quota problems:

/scripts/fixquotas

Step 3: Verify the Quota Adjustment

After running the scripts, check if the disk quota issue is resolved. If the discrepancy persists, proceed to the next step.

Step 4: Use Screen for a Detailed Quota Check

If the issue is still unresolved, it's time to perform a more thorough quota check. Using screen allows this process to continue running even if your SSH session is disconnected.

Start a Screen Session:

screen -S ea

Run Quotacheck: In the screen session, force a check and update of disk quotas for all filesystems:

quotacheck -avfumg
  • -a: Check all filesystems.
  • -v: Verbose mode.
  • -f: Force checking even if the system believes quotas are correct.
  • -u: Check user quotas.
  • -m: Do not try to remount the file system read-only.
  • -g: Check group quotas.

Exiting Screen: To detach from the screen session without stopping the running process:

Ctrl + A + D

Re-enter Screen: If you need to go back to your screen session:

screen -x

Step 5: Completion and Verification

Once the quotacheck process completes, you should see a summary of the directories and files checked:

quotacheck: Scanning /dev/simfs [/] done quotacheck: Checked 90761 directories and 772655 files.

Check in WHM: Now, verify whether the disk usage in cPanel reflects the actual usage on the server:

  1. Log in to WHM.
  2. Navigate to the account in question and review the disk space usage.

Conclusion

Resolving discrepancies between cPanel and server-reported disk usage can usually be handled through the provided scripts and a thorough quota check. Remember, keeping your cPanel and server environment updated and regularly monitored is crucial for maintaining accuracy and performance. If the issue persists after these steps, consider contacting cPanel support or a server administrator for further assistance.