Skip to content

Zal Ultra Artisan Commands

This document provides a comprehensive reference for all custom Artisan commands available in Zal Ultra ISP CRM.

⚠️ CRITICAL WARNING - READ BEFORE PROCEEDING

These commands are intended for Senior Zal Ultra Experts and System Administrators ONLY.

Running these commands incorrectly can result in:

  • Permanent data loss (subscribers, invoices, payments, accounting records)
  • Service disruption for all connected subscribers
  • Corrupted RADIUS data causing authentication failures
  • Financial data inconsistencies that may be impossible to recover

Before running ANY command:

  1. Create a full database backup
  2. Test on a staging environment first
  3. Understand exactly what the command does
  4. Use --dry-run option when available
  5. Consult with Onezeroart support if unsure

Commands marked as "DESTRUCTIVE" will permanently delete data. There is NO undo.

If you are not 100% certain about what you are doing, STOP and contact support.


Table of Contents

  1. Subscriber Management Commands
  2. Quota Management Commands
  3. Accounting Commands
  4. RADIUS Commands
  5. Graph & Monitoring Commands
  6. Queue & Cache Commands
  7. System Health Commands
  8. OLT Commands
  9. Maintenance Commands
  10. Testing Commands

Subscriber Management Commands

Auto Renew Subscribers

Command: php artisan command:autorenew

Purpose: Automatically renews subscribers whose packages have expired based on package and profile settings.

How It Works:

  • Finds subscribers with expired or expiring radcheck entries
  • Checks if subscriber, salesperson, and package all have auto-renew enabled
  • Processes activation with proper accounting (balance cut, profit distribution)
  • Prevents duplicate activations within 2 minutes

Usage:

bash
php artisan command:autorenew

Scheduled: Runs every minute via cron

Related Files:

  • app/Services/Command/AutorenewServices.php

Expiring Subscribers Notification

Command: php artisan command:expiringsubscribers

Purpose: Sends SMS and email notifications to subscribers whose packages are about to expire.

How It Works:

  • Identifies subscribers expiring within configured days
  • Sends SMS alerts using configured gateway
  • Sends email notifications
  • Respects subscriber notification preferences

Usage:

bash
php artisan command:expiringsubscribers

Scheduled: Runs daily


Usage Data Quota

Command: php artisan command:usagedataquota

Purpose: Processes subscriber data usage and updates quota consumption.

How It Works:

  • Calculates data usage from RADIUS accounting
  • Updates subscriber's used quota fields
  • Triggers quota-based actions (throttling, disconnection)

Usage:

bash
php artisan command:usagedataquota

Scheduled: Runs periodically (every few minutes)


Quota Management Commands

Reset Daily Quota

Command: php artisan quota:reset-daily

Purpose: Resets daily data quota for all subscribers at midnight.

How It Works:

  • Resets used_daily_data_quota to 0 for all eligible subscribers
  • Syncs total_daily_data_quota from package settings
  • Respects lock_daily_volume_status (skips locked subscribers)
  • Prevents duplicate resets on same day
  • Logs to storage/logs/daily_quota.log

Usage:

bash
php artisan quota:reset-daily

Scheduled: Runs daily at midnight (00:00)


Reset Weekly Quota

Command: php artisan quota:reset-weekly

Purpose: Resets weekly data quota for subscribers based on their package's reset day setting.

How It Works:

  • Checks package's weekly_reset_day setting (0=Sunday to 6=Saturday)
  • Only resets subscribers whose reset day matches current day
  • Resets used_weekly_data_quota to 0
  • Syncs total_weekly_data_quota from package settings
  • Respects lock_weekly_volume_status
  • Logs to storage/logs/weekly_quota.log

Usage:

bash
php artisan quota:reset-weekly

Scheduled: Runs daily at midnight (checks if today is reset day)


Accounting Commands

Auto Invoice

Command: php artisan command:autoinvoice

Purpose: Generates automatic invoices for subscribers based on billing cycle.

How It Works:

  • Identifies subscribers due for invoicing
  • Generates invoices with proper amounts
  • Handles pro-rated billing if applicable

Usage:

bash
php artisan command:autoinvoice

Scheduled: Runs daily


Flush Accounting Tables

🔴 DESTRUCTIVE COMMAND

This command permanently deletes ALL accounting data. This action CANNOT be undone.

Command: php artisan command:flushaccounting

Purpose: Truncates accounting tables data. DESTRUCTIVE OPERATION - USE WITH CAUTION!

Options:

  • --all - Flush all accounting tables
  • --tables= - Comma-separated list of specific tables to flush

Available Tables:

  • payments
  • ledgers
  • reseller_distributions
  • activation_records
  • invoices
  • cashflows
  • activation_extra_fees
  • invoice_package_extra_fees

Usage:

bash
# Flush all accounting tables
php artisan command:flushaccounting --all

# Flush specific tables
php artisan command:flushaccounting --tables=payments,invoices

Safety: Requires typing "YES" and confirmation prompt.


RADIUS Commands

Sync RADIUS Attributes

Command: php artisan command:sync-attributes

Purpose: Synchronizes RADIUS attributes by removing duplicates and keeping only the newest records.

Options:

  • --dry-run - Show which records would be deleted without actually deleting
  • --force - Execute without confirmation prompt (for scheduled runs)

How It Works:

  • Finds duplicate radcheck entries for same username/attribute
  • Keeps only the newest record (highest ID)
  • Deletes older duplicate records
  • Shows summary of cleaned records

Usage:

bash
# Preview what would be deleted
php artisan command:sync-attributes --dry-run

# Run with confirmation
php artisan command:sync-attributes

# Run without confirmation (for cron)
php artisan command:sync-attributes --force

Delete Unused RADIUS Data

🟠 CAUTION - DATA DELETION

This command deletes RADIUS data. Always use --dry-run first to preview what will be deleted.

Command: php artisan command:delete-unused-radius-data

Purpose: Deletes RADIUS data (radcheck, radusergroup, radreply) for usernames not found in subscribers or vouchers tables.

Options:

  • --dry-run - Show which records would be deleted without actually deleting
  • --force - Execute without confirmation prompt
  • --chunk=1000 - Number of records to process at once

How It Works:

  • Scans radcheck, radusergroup, radreply tables
  • Identifies usernames not in subscribers or vouchers tables
  • Deletes orphaned RADIUS entries
  • Processes in chunks for memory efficiency

Usage:

bash
# Preview what would be deleted
php artisan command:delete-unused-radius-data --dry-run

# Run cleanup
php artisan command:delete-unused-radius-data --force

# Custom chunk size
php artisan command:delete-unused-radius-data --force --chunk=500

Fix Expiration Format

Command: php artisan command:fixExpirationFormat

Purpose: Standardizes radcheck Expiration attribute date format to DD MMM YYYY HH:MM:SS format.

Options:

  • --dry-run - Simulate the operation without making changes
  • --force - Run without confirmation

How It Works:

  • Finds Expiration attributes with non-standard formats
  • Converts formats like "01 January 2025" to "01 Jan 2025 00:00:00"
  • Handles various date formats (MySQL datetime, full month names, etc.)
  • Shows before/after comparison

Usage:

bash
# Preview changes
php artisan command:fixExpirationFormat --dry-run

# Apply changes
php artisan command:fixExpirationFormat --force

Graph & Monitoring Commands

Interface Graph

Command: php artisan command:interface-graph

Purpose: Collects and broadcasts real-time interface bandwidth data via WebSocket.

How It Works:

  • Gets active interface graph sessions from session manager
  • Collects traffic data from MikroTik routers via API
  • Broadcasts data to WebSocket channels for live graphs
  • Logs to graph_interface channel

Usage:

bash
php artisan command:interface-graph

Scheduled: Runs every second via scheduler


Subscriber Graph

Command: php artisan command:subscriber-graph

Purpose: Collects and broadcasts real-time subscriber bandwidth data via WebSocket.

How It Works:

  • Gets active subscriber graph sessions
  • Collects traffic data for each subscriber
  • Broadcasts to WebSocket for live subscriber graphs
  • Logs to graph_subscriber channel

Usage:

bash
php artisan command:subscriber-graph

Scheduled: Runs every second via scheduler


Graph Cleanup

Command: php artisan graph:cleanup

Purpose: Cleans up expired graph sessions and stale router connections.

How It Works:

  • Removes expired graph sessions from cache
  • Closes stale MikroTik API connections
  • Frees up memory and resources

Usage:

bash
php artisan graph:cleanup

Scheduled: Runs every 1-5 minutes


Clear Graph Cache

Command: php artisan graph:clear-cache

Purpose: Clears graph system cache (adapters, NAS details, sessions).

Options:

  • --nas-id= - Clear cache for specific NAS ID
  • --all - Clear all graph-related cache

Usage:

bash
# Clear cache for specific NAS
php artisan graph:clear-cache --nas-id=5

# Clear all graph cache
php artisan graph:clear-cache --all

Resource Monitor

Command: php artisan command:realtime-update

Purpose: Dispatches real-time CPU and memory usage data via WebSocket.

How It Works:

  • Reads CPU usage from /proc/stat or top command
  • Reads memory usage from free command
  • Broadcasts via ResourceMonitorEvent

Usage:

bash
php artisan command:realtime-update

Scheduled: Runs every second


Queue & Cache Commands

Clear Redis Queue

🔴 DESTRUCTIVE COMMAND - EMERGENCY USE ONLY

This command permanently deletes ALL queued jobs (SMS, emails, reports, etc.). Use only in emergencies.

Command: php artisan queue:clear-redis

Purpose: Clears Redis queue to free up memory. EMERGENCY USE ONLY!

Arguments:

  • queue - The name of the queue to clear (default: "default")

Options:

  • --all - Clear all queues
  • --confirm - Skip confirmation prompt

How It Works:

  • Deletes all jobs from specified queue(s)
  • Clears delayed and reserved jobs
  • Shows queue sizes before clearing

Usage:

bash
# Clear default queue
php artisan queue:clear-redis default --confirm

# Clear all queues
php artisan queue:clear-redis --all --confirm

# Clear specific queue
php artisan queue:clear-redis sms --confirm

Warning: This permanently deletes all queued jobs!


System Health Commands

System Health

🟠 CAUTION - SYSTEM CRITICAL

The --flush and --clear-cache options affect license data. Use only when instructed by Onezeroart support.

Command: php artisan system:health

Purpose: System health management and diagnostics for license verification.

Options:

  • --init - Initialize system metrics for first time setup
  • --check - Perform health check and sync with license portal
  • --status - Show current system status (default)
  • --flush - Clear system_metrics data and re-sync with portal
  • --clear-cache - Clear license cache file (empty license.txt)

Usage:

bash
# Show current status
php artisan system:health
php artisan system:health --status

# Initialize system (first time setup)
php artisan system:health --init

# Force health check and sync
php artisan system:health --check

# Flush and re-sync (after database migration)
php artisan system:health --flush

# Clear license cache file
php artisan system:health --clear-cache

Status Values:

  • healthy - License valid, all operations allowed
  • grace_period - License sync failed, temporary grace period active
  • safe_mode - License issues, read-only mode (admin only)

OLT Commands

Diagnose OLT

Command: php artisan olt:diagnose {olt_id}

Purpose: Diagnoses OLT device and discovers supported SNMP OIDs.

Arguments:

  • olt_id - The ID of the OLT to diagnose

How It Works:

  • Tests system information OIDs
  • Tests vendor-specific OIDs (BDCOM, Huawei, ZTE, V-Sol, MikroTik)
  • Shows which OIDs work with the device
  • Helps identify OLT type for adapter implementation

Usage:

bash
php artisan olt:diagnose 1

Discover ONUs

Command: php artisan olt:discover-onus

Purpose: Discovers ONUs from OLT devices via SNMP.

Options:

  • --olt-id= - Specific OLT ID to discover ONUs from
  • --sync - Run synchronously instead of queuing

How It Works:

  • Queries enabled OLTs via SNMP
  • Discovers connected ONUs (serial numbers, MAC addresses)
  • Creates/updates ONU records in database
  • Can run as queued job or synchronously

Usage:

bash
# Discover from all enabled OLTs (queued)
php artisan olt:discover-onus

# Discover from specific OLT
php artisan olt:discover-onus --olt-id=5

# Run synchronously
php artisan olt:discover-onus --sync

Monitor ONU Metrics

Command: php artisan olt:monitor-metrics

Purpose: Monitors signal metrics (RX power, TX power) for ONUs.

Options:

  • --olt-id= - Monitor ONUs from specific OLT only
  • --online-only - Monitor only online ONUs
  • --limit=100 - Maximum number of ONUs to monitor per run
  • --sync - Run synchronously instead of queuing

How It Works:

  • Queries ONU signal metrics via SNMP
  • Updates ONU records with latest metrics
  • Prioritizes least recently updated ONUs
  • Shows progress bar during execution

Usage:

bash
# Monitor all ONUs (queued)
php artisan olt:monitor-metrics

# Monitor online ONUs only
php artisan olt:monitor-metrics --online-only

# Monitor specific OLT with limit
php artisan olt:monitor-metrics --olt-id=5 --limit=50 --sync

Maintenance Commands

Clear All Logs

🟠 CAUTION - DATA DELETION

This command deletes all log files. You may lose important debugging information.

Command: php artisan logs:clear-all

Purpose: Deletes all log files from storage/logs directory.

Options:

  • --force - Force deletion without confirmation

How It Works:

  • Scans storage/logs directory recursively
  • Shows total files and size
  • Deletes all log files with progress bar
  • Shows summary of freed space

Usage:

bash
# With confirmation
php artisan logs:clear-all

# Without confirmation (for automation)
php artisan logs:clear-all --force

Clear Tables

Command: php artisan command:cleartables

Purpose: Clears unnecessary tables (jobs, CoA request logs).

How It Works:

  • Clears old entries from jobs table
  • Clears CoA request logs

Usage:

bash
php artisan command:cleartables

Scheduled: Runs daily at 4 AM


Clear Stale Sessions

Command: php artisan command:clearstalesession

Purpose: Clears stale RADIUS sessions from radacct table.

How It Works:

  • Identifies sessions without stop time that are stale
  • Cleans up orphaned session records
  • Helps maintain accurate online user count

Usage:

bash
php artisan command:clearstalesession

CoA Request

Command: php artisan command:coarequest

Purpose: Processes pending CoA (Change of Authorization) requests.

How It Works:

  • Finds pending CoA requests in queue
  • Sends CoA packets to NAS devices
  • Updates request status

Usage:

bash
php artisan command:coarequest

Scheduled: Runs frequently (every minute or less)


Testing Commands

Test CoA Performance

Command: php artisan test:coa-performance

Purpose: Tests CoA processing performance with current setup.

How It Works:

  • Checks online subscriber count
  • Verifies database schema (CoA tracking columns)
  • Checks queue configuration (sync, database, redis)
  • Tests Redis connection if applicable
  • Estimates processing time
  • Provides performance recommendations
  • Optionally runs quick test with 10 subscribers

Usage:

bash
php artisan test:coa-performance

Output Includes:

  • Online subscriber count
  • Queue driver status
  • Estimated processing time
  • Performance recommendations
  • Optional quick test

Scheduled Commands Summary

CommandSchedulePurpose
command:autorenewEvery minuteAuto-renew expired subscribers
command:coarequestEvery minuteProcess CoA requests
command:usagedataquotaEvery 5 minutesUpdate usage quotas
quota:reset-dailyDaily at 00:00Reset daily quotas
quota:reset-weeklyDaily at 00:00Reset weekly quotas (on reset day)
command:expiringsubscribersDailySend expiration notifications
command:autoinvoiceDailyGenerate auto invoices
command:cleartablesDaily at 04:00Clean up old data
command:clearstalesessionHourlyClean stale sessions
command:sync-attributesWeeklyClean duplicate RADIUS entries
graph:cleanupEvery 1-5 minutesClean graph sessions
command:interface-graphEvery secondCollect interface data
command:subscriber-graphEvery secondCollect subscriber data
command:realtime-updateEvery secondBroadcast system metrics

Best Practices

  1. Always use --dry-run first for destructive commands
  2. Use --force for scheduled/automated runs to skip prompts
  3. Check logs after running commands: tail -f storage/logs/laravel.log
  4. Monitor queue when using queued jobs: php artisan queue:work
  5. Backup database before running flush/delete commands

Troubleshooting

Command Not Found

bash
php artisan list | grep command:

Permission Issues

bash
sudo chown -R www-data:www-data storage
sudo chmod -R 775 storage

Queue Jobs Not Processing

bash
php artisan queue:restart
php artisan queue:work --tries=3

View Failed Jobs

bash
php artisan queue:failed
php artisan queue:retry all

www.onezeroart.com