Skip to main content
Version: 2.0.32

Real-time malware scanning

opencli malware-realtime scans website files for malware a few seconds after they are uploaded or changed, instead of waiting for the next scheduled scan.

A service watches the html_data volume of every account. When a file is written or moved into place, it waits until the file has been quiet for 2 seconds and hands it to a scanner. Uploads from PHP, FTP, the file manager and SSH are all seen, because the watch is on the filesystem and not on a single service.

It needs Linux 5.9 or newer and /home on a filesystem that supports fanotify file handles (ext4 and XFS do).

Scanners​

The service doesn't scan files itself. It uses one of the scanners installed on the server:

ScannerWhat it isWho handles a detection
imunifyImunifyAV, installed with opencli imunify installWith the free license ImunifyAV only reports, so OpenPanel moves the file to quarantine. With ImunifyAV+ or Imunify360, ImunifyAV cleans the file and OpenPanel leaves it alone.
clamavThe clamav container used by the Malware Scanner moduleOpenPanel moves the file to quarantine.
maldetLinux Malware Detect, if you installed itOpenPanel moves the file to quarantine, unless maldet already quarantined it.

With auto, the default, the first one that is installed and answering is used, in that order. The choice is checked again every 10 minutes, so installing ImunifyAV later is picked up without a restart.

ImunifyAV scans one path at a time. To keep its queue short, more than 5 changed files in one folder are scanned as that folder, and more than 20 paths in one batch are scanned as their site folders.

When ImunifyAV is installed, enable also adds every account's .quarantine folder to ImunifyAV's ignore list, so its manual and scheduled scans don't report the quarantined files again.

Enable​

opencli malware-realtime enable
Example output
# opencli malware-realtime enable
Real-time malware scanning is on, using ImunifyAV.
Detected files are moved to the account's quarantine.

This creates and starts the openpanel-realtime-scan systemd service. --scanner= and --action= set the scanner and what happens on a detection in the same step:

opencli malware-realtime enable --scanner=clamav --action=notify
Example output
# opencli malware-realtime enable --scanner=clamav --action=notify
Real-time malware scanning is on, using ClamAV.
Detected files are reported and left in place.

The command stops with an error when the chosen scanner isn't available or the kernel can't watch the filesystem, and leaves the service off.

Disable​

opencli malware-realtime disable
Example output
# opencli malware-realtime disable
Real-time malware scanning is off.

Status​

opencli malware-realtime status
Example output
# opencli malware-realtime status
Real-time malware scanning: on
Scanner: ImunifyAV (picked automatically)
ImunifyAV license: imunifyAV
On detection: Detected files are moved to the account's quarantine.
Account emails: on
Excluded folders (scanned every 15 minutes): wp-content/cache, wp-content/litespeed, templates_c, storage/framework/views, var/cache, generated/code, generated/metadata, .git
Available scanners:
imunify yes
clamav yes
maldet no (maldet is not installed)
Since 2026-11-30 12:11:01: 5994 file changes seen, 2 matched, 2 scanned, 1 detections, 1 quarantined
Waiting in excluded folders: 14 files
Last detection: 2026-11-30 12:11:13 stefan /home/stefan/docker-data/volumes/stefan_html_data/_data/example.com/shell.php (SMW-BLKH-SA-CLOUDAV-eicar.tst-05057-2, quarantined)

"File changes seen" counts every finished write on the filesystem that holds /home. "Matched" is how many of those were website files with a watched extension. "Waiting in excluded folders" is shown while changed files in excluded folders wait for their scan.

--json prints the same as JSON:

opencli malware-realtime status --json
Example output
# opencli malware-realtime status --json
{
"enabled": true,
"configured_scanner": "auto",
"scanner": "imunify",
"on_detect": "quarantine",
"notify_user": true,
"imunify_license": "imunifyAV",
"note": "Detected files are moved to the account's quarantine.",
"scanners": [
{
"name": "imunify",
"available": true
},
{
"name": "clamav",
"available": true
},
{
"name": "maldet",
"available": false,
"reason": "maldet is not installed"
}
],
"excludes": [
"wp-content/cache",
"wp-content/litespeed",
"templates_c",
"storage/framework/views",
"var/cache",
"generated/code",
"generated/metadata",
".git"
],
"state": {
"pid": 116696,
"started": "2026-11-30 12:11:01",
"scanner": "imunify",
"events": 5994,
"matched": 2,
"scanned": 2,
"batches": 2,
"detections": 1,
"quarantined": 1,
"pending": 0,
"deferred": 14,
"overflows": 0,
"last_scan": "2026-11-30 12:11:10",
"last_error": ""
},
"last_detection": {
"action": "quarantined",
"path": "/home/stefan/docker-data/volumes/stefan_html_data/_data/example.com/shell.php",
"scanner": "imunify",
"signature": "SMW-BLKH-SA-CLOUDAV-eicar.tst-05057-2",
"time": "2026-11-30 12:11:13",
"user": "stefan"
}
}

Change the scanner​

opencli malware-realtime scanner <auto|imunify|clamav|maldet>
Example output
# opencli malware-realtime scanner clamav
Real-time scanner set to clamav.

The scanner has to be available, otherwise the setting is not changed. A running service is restarted to pick it up.

Change what happens on a detection​

opencli malware-realtime action <quarantine|notify>
Example output
# opencli malware-realtime action notify
Detected files will be reported and left in place.
  • quarantine, the default, moves the file to .quarantine in the account's html_data volume, the same place the scheduled ClamAV scan uses. The user sees it on Malware Scanner > Quarantine in OpenPanel and can delete or restore it.
  • notify leaves the file where it is.

Either way the admin gets a notification in OpenAdmin > Notifications, the user gets the "Malware found" email if they have it turned on, and the detection is added to the user's activity log and to /var/log/openpanel/admin/realtime_scan.log.

Notifications during an outbreak​

A mass infection can produce hundreds of detections in a few minutes, so they are combined:

  • The first detection adds one notification, Real-time scan found malware, in OpenAdmin > Notifications. Its email or webhook is held for one minute, so it reports the first wave and not a single file.
  • Detections on any account in the next 30 minutes update that same notification (37 malicious files on 4 accounts: ...), and nothing more is sent for them.
  • When no new detection arrived for 10 minutes, one summary goes out with the totals. While detections keep coming it goes out once an hour.
  • After 30 quiet minutes the next detection starts a new notification.

The title never changes, so snoozing it in OpenAdmin keeps working while the counts go up.

Each user gets one email about a minute after their first detection, and one more with the summary if more of their files were found after it. These emails can be turned off with notify-user no.

The notification can be turned off with Real-time malware scan on OpenAdmin > Settings > Notifications, or with realtime_scan=no under [ACTIONS] in /etc/openpanel/openadmin/config/notifications.ini.

With ImunifyAV as the scanner a failed scan adds a notification at most once an hour.

Every single detection is still in the user's activity log and in /var/log/openpanel/admin/realtime_scan.log.

Files a user marked as safe on the Malware Scanner page are not quarantined again.

Emails to accounts​

By default both the admin and the account are notified. To keep only the admin notification and stop the emails to accounts:

opencli malware-realtime notify-user <yes|no>
Example output
# opencli malware-realtime notify-user no
Accounts will no longer get an email when real-time scanning finds malware, the admin notification is not changed.

Detections are still quarantined, logged and added to the admin notification. The change applies to the next email, no restart is needed.

Excluded folders​

Page cache plugins write a file for every visited URL, so a busy site would keep the scanner busy with its own cache. Files written in an excluded folder are not scanned right away. Each one is scanned once, 15 minutes after its first change, however often it was rewritten in between. A folder moved into an excluded folder is still scanned right away.

The folders are matched by name anywhere in the account's files, like node_modules: wp-content/cache covers /var/www/html/example.com/wp-content/cache and the same folder of every other site. The defaults are wp-content/cache, wp-content/litespeed, templates_c, storage/framework/views, var/cache, generated/code, generated/metadata and .git.

opencli malware-realtime exclude list
Example output
# opencli malware-realtime exclude list
Changes in these folders are scanned once every 15 minutes instead of right away:
wp-content/cache
wp-content/litespeed
templates_c
storage/framework/views
var/cache
generated/code
generated/metadata
.git

--json prints the list as JSON:

opencli malware-realtime exclude list --json
Example output
# opencli malware-realtime exclude list --json
{
"excludes": [
"wp-content/cache",
"wp-content/litespeed",
"templates_c",
"storage/framework/views",
"var/cache",
"generated/code",
"generated/metadata",
".git"
],
"rescan_minutes": 15
}

Add a folder:

opencli malware-realtime exclude add <folder>
Example output
# opencli malware-realtime exclude add wp-content/et-cache
Changes in wp-content/et-cache folders are now scanned once every 15 minutes instead of right away.

Remove one, including a default:

opencli malware-realtime exclude remove <folder>
Example output
# opencli malware-realtime exclude remove .git
Changes in .git folders are scanned right away again.

A running service is restarted to pick up the change. Files that were waiting are kept across the restart.

Settings​

Settings are kept in /etc/openpanel/openadmin/config/realtime_scan.ini. Restart the service after editing the file by hand: systemctl restart openpanel-realtime-scan.

KeyDefaultMeaning
scannerautoauto, imunify, clamav or maldet
on_detectquarantinequarantine or notify
notify_useryesno stops the detection emails to accounts, the admin notification is not changed.
extensionsphp,php3,php4,php5,php7,php8,phtml,pht,phar,phps,inc,js,mjs,html,htm,shtml,svg,htaccess,pl,py,cgi,sh,so,exe,ico,suspectedFile extensions that are scanned, comma separated. * scans every file.
delay2Seconds a file has to stay unchanged before it is scanned, 1 to 60.
excludessee Excluded foldersFolders whose changes are scanned every 15 minutes instead of right away, comma separated. Without the key the defaults are used, an empty excludes= excludes nothing.

Files under .quarantine and node_modules are never scanned.

The service keeps its state in /var/lib/openpanel/realtime-scan: the paths it queued in ImunifyAV, the open notification and the files waiting in excluded folders. They survive a reboot, so ImunifyAV scans still queued at that moment are still recognized as real-time scans.

Was this helpful?