Monitoring script using Zabbix UserPatameter for Joomla application.
- https://www.zabbix.com/documentation/current/pt/manual/concepts/agent
- https://www.zabbix.com/documentation/guidelines/en/coding/php
- Import
zbx_export_templates_joomla.xml
. zabbix doc - Link template to hosts. zabbix doc
To use it, it is necessary to enable script execution as root by editing the /etc/zabbix/zabbix_agentd.conf file and modifying the AllowRoot and User directives
### Option: AllowRoot
# Allow the agent to run as 'root'. If disabled and the agent is started by 'root', the agent
# will try to switch to the user specified by the User configuration option instead.
# Has no effect if started under a regular user.
# 0 - do not allow
#1 - allow
#
# Mandatory: no
# Default:
# AllowRoot=0
AllowRoot=1
### Option: User
# Drop privileges to a specific, existing user on the system.
# Only has effect if run as 'root' and AllowRoot is disabled.
#
# Mandatory: no
# Default:
# User=zabbix
User=root
# Adding running CMS Joomla!
UserParameter=joomla.site[*],/etc/zabbix/zabbix_agentd.d/zabbix_joomla.php $1 $2 $3
For console testing
zabbix_agentd -t joomla.site[{$site},option]
Where {$site} is the Macro with the name of the CMS Host to be monitored
Returns Virtual Host information (apache2 configuration file located in /etc/apache2/sites-avaliables/)
zabbix_agentd -t joomla.site[{$site},virtualhosts]
Output:
{
"ports":["80","443"],
"file":"\/etc\/apache2\/sites-avaliable\/site.com.br.conf",
"documentRoot":"\/var\/www\/site\/",
"serverName":"www.site.com.br",
"serverAlias":"site.com.br"
}
Return path of portal files location
zabbix_agentd -t joomla.site[{$site},folder]
Output:
/var/www/site/
Returns the name of the Virtual Host
zabbix_agentd -t joomla.site[{$site},serverName]
Output:
www.site.com.br
Return Virtual Server Alias
zabbix_agentd -t joomla.site[{$site},serverAlias]
Output:
site.com.br
Returns Port(s) used for site publication
zabbix_agentd -t joomla.site[{$site},port]
Output:
80.443
Return apache settings
zabbix_agentd -t joomla.site[{$site},apacheconf]
Output:
/etc/apache2/sites-available/site.com.br.conf
Returns the JPA files contained in the directory and information about those files
zabbix_agentd -t joomla.site[{$site},jpas]
Output:
[
{
"size": 554543,
"size":"541.55 KB",
"name":"\/var\/www\/site\/\/administrator\/components\/com_akeeba\/Master\/Installers\/angie.jpa",
"date":"2021-09-01 11:02:56"
},
{
"size": 27120,
"size":"26.48 KB",
"name":"\/var\/www\/site\/\/administrator\/components\/com_akeeba\/Master\/Installers\/angie-joomla.jpa",
"date":"2021-09-01 11:02:56"
},
{
"size":46692,
"size":"45.6 KB",
"name":"\/var\/www\/site\/\/administrator\/components\/com_akeeba\/Master\/Installers\/angie-mautic.jpa",
"date":"2016-09-19 11:31:24"
},
]
Returns the total size of JPAs contained in the Joomla directory
zabbix_agentd -t joomla.site[{$site},hjpasize]
Output:
628355
Returns the total number of JPAs contained in the Joomla directory
zabbix_agentd -t joomla.site[{$site},njpas]
Output:
3
Returns the total size occupied by Joomla files
zabbix_agentd -t joomla.site[{$site},folderssize]
Output:
623471397
Returns the total size occupied by Joomla (formatted) files
zabbix_agentd -t joomla.site[{$site},hfolderssize]
Output:
594.59 MB
Return Joomla file permissions
zabbix_agentd -t joomla.site[{$site},permission]
Output:
2770
Return installed version of Joomla
zabbix_agentd -t joomla.site[{$site},jm_version]
Output:
3.9.27
Returns the latest stable and released version of CMS Joomla
zabbix_agentd -t joomla.site[{$site},jm_lastversion]
Output:
4.0.3
Returns the information contained in the Joomla configuration.php file with some properties
zabbix_agentd -t joomla.site[{$site},jm_dataconfiguration]
Output:
{
"sitename" : "MySite",
"editor" : "jce",
"dbtype" : "mysqli",
"host" : "localhost",
"user" : "web_site",
"dbprefix" : "myjml_",
"mailfrom" : "support@site.com.br",
"fromname" : "My Site",
"smtphost" : "smtp.site.com.br"
}
Returns users registered in the application's database with administrative access
zabbix_agentd -t joomla.site[{$site},jm_users]
Output:
{
"users":[
{
"name" : "Super User",
"username" : "admin",
"email" : "admin@site.com.br"
},
{
"name" : "security",
"username" : "security",
"email" : "seguranca@site.com.br"
},
{
"name" : "Social Communication",
"username" : "comsoc",
"email" : "comsoc@site.com.br"
}
]
}
Returns the total number of users registered in the application's database with administrative access
zabbix_agentd -t joomla.site[{$site},jm_nusers]
Output:
3