Skip to content

Instantly share code, notes, and snippets.

@mattrice
Created September 15, 2020 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattrice/35b8202935bdd4dd476a218fa25bf8e1 to your computer and use it in GitHub Desktop.
Save mattrice/35b8202935bdd4dd476a218fa25bf8e1 to your computer and use it in GitHub Desktop.
Monitor Concrete5's allowed upload file types/extensions

A need arose to monitor the list of file types/extensions that users are allowed to upload into Concrete5.

These two scripts allow Zabbix to remotely view the configuration.

Scripts

Bash Wrapper Script

list_c5_upload_extensions.sh

Should be placed wherever it can be accessed by the Zabbix agent; I chose /usr/lib/zabbix/externalscripts/ for consistency with other scripts that could be called externally (although external checks only work on scripts located on the Zabbix server itself).

PHP script

list_c5_upload_extensions.php

This will do the heavy lifting of parsing the Concrete5 config file, and should be located in the same directory as the wrapper script

Zabbix configuration

Agent UserParameter configuration

On the Concrete5 webserver:

# e.g. /etc/zabbix/zabbix_agent.conf
# Add this line wherever is appropriate
UserParameter=concrete5.upload_file_extensions,/usr/lib/zabbix/externalscripts/list_c5_upload_extensions.sh

# restart the agent, e.g.
sudo service zabbix-agent restart

# verify the key is available for use

# login as the zabbix user
sudo su zabbix -s /bin/bash
zabbix-agentd -t "concrete5.upload_file_extensions"

Zabbix Item

In the Zabbix GUI, Add an item

  • Name: Concrete5 Allowed Upload File Extensions
  • Type: Zabbix agent
  • Key: concrete5.upload_file_extensions
  • Other attributes as desired (e.g.)
    • Update interval: 600 (s)

Zabbix Trigger

In the Zabbix GUI, Add a trigger

<?php
// Do not report PHP notices
// Specifically, we do not care about undefined constants
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// The path to the concrete5 settings file
// containing the persisted setting we are interested in
$settings_path = "/path/to/your/concrete/config/concrete.php";
// Load the data into a variable
$settings = include $settings_path;
// Concrete5 referes to this setting internally as
// 'concrete.upload.extensions'
// https://github.com/concrete5/concrete5/blob/8.5.2/concrete/controllers/single_page/dashboard/system/files/filetypes.php#L42
echo $settings["upload"]["extensions"];
#!/bin/bash
# Get directory of script
# from https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself/246128#246128
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Echo the list of file types/extensions users are allowed to upload
php -f "$DIR"/list_c5_upload_extensions.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment