Statusengine Worker is a PHP application that will consume the events provided by the
Statusengine Broker Module.
All status data are save in a database (CrateDB, MySQL or Redis)
In addition, the Worker is able to parse and process performance data to
store them in a time series databases like Graphite.
If you work load grows, and you split up your monitoring configuration through
multiple monitoring nodes, you shoud deploy a new instance of Statusengine Worker
on every monitoring node in your cluster.
Make sure to set a unique node_name
for each Statusengine Worker in the cluster!
The default value of node_name
is set to Crowbar
.
Please select your operating system first. If your operating system is not in the list, pick the operating system version that matches your operating system best. You can still install Statusengine on your system, even if it is not in the list.
Check out the tutorial, of how to install php composer, if you don't have it installed to your system yet.
yum install epel-release yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum check-update yum install yum-utils yum-config-manager --enable remi-php72
yum install epel-release yum install http://rpms.remirepo.net/enterprise/remi-release-8.rpm yum check-update dnf module reset php dnf module install php:remi-7.3
{[{commands[selectedOs].dependencies}]}
Unfortunately the php-gearman extension is missing or broken in Ubuntu 20.04 / Ubuntu 16.04 Follow this guide to install it manually
systemctl start redis systemctl enable redis
mkdir -p /opt/statusengine cd /opt/statusengine git clone https://github.com/statusengine/worker.git worker cd /opt/statusengine/worker chmod +x bin/* composer install
At this point you need to decide, which database you prefer to use.
For large environments or high availability you should use CrateDB. For smaller systems or to keep things simple, you should go with MySQL.
/opt/statusengine/worker/lib/crateDB.sql
via the Crate Admin UI.
CREATE USER 'statusengine'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS `statusengine` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON `statusengine`.* TO 'statusengine'@'localhost';
Since Statusengine 3.7 Statusengine will manage the database schema automatically
# -p statusengine does not mean that "statusengine" is the password! This is the name of the database! mysql -u statusengine -p statusengine < /opt/statusengine/worker/lib/mysql.sql
Due to the fact that the Statusengine Worker Config file has a lot of options you may be don't need, I striped this down to the basics you need to change.
Statusengine Worker can also be configured through environment variables. This can be handy if you want to run Statusengine Worker inside of Docker. See the list of environment variables for more information.
If you are going to use CrateDB you can ignore all MySQL settings and vice vera.
Copy example configuration
cp /opt/statusengine/worker/etc/config.yml.example /opt/statusengine/worker/etc/config.yml
node_name
use_mysql
mysql username
mysql password
mysql database
use_crate
crate nodes
external_command_file
Load MySQL database schema
/opt/statusengine/worker/bin/Console.php database --update
Statusengine Worker can store Nagios and Naemon Performance data to different storage backends.
cp /opt/statusengine/worker/lib/statusengine.service /lib/systemd/system/statusengine.service
If you use Statusengine with CrateDB, add
crate.serviceto the
After=
line in the file
/lib/systemd/system/statusengine.service
After=syslog.target network.target gearman-job-server.service crate.service
{[{mysqlShort}]}to the
After=
line in the file
/lib/systemd/system/statusengine.service
{[{mysqlLong}]}
systemctl daemon-reload systemctl enable statusengine systemctl start statusengine
cp /opt/statusengine/worker/lib/statusengine.init /etc/init.d/statusengine chmod +x /etc/init.d/statusengine
If you use Statusengine with CrateDB, add
crateto the
Required-Start
line in the file
/etc/init.d/statusengine
Required-Start: gearman-job-server crate
mysqlto the
equired-Start
line in the file
/etc/init.d/statusengine
Required-Start: gearman-job-server mysql
update-rc.d statusengine defaults service statusengine start
The Statusengine Database cleanup cronjob should only run at one node of your cluster.
You can run the cron on as many nodes as you want, but this will increase the load of the system.
If you want to run the cronjob on more than one node, you should set different times for scheduling the cron.
For example at 01:00AM on node1 and at 01:00PM on node2.
echo "0 1 * * * /opt/statusengine/worker/bin/Console.php cleanup -q" > /etc/cron.d/statusengineYou can define, how long Statusengine will keep your data in
/opt/statusengine/worker/etc/config.yml
The parameter -q
or --quiet
is required, if the
cron gets executed via crontab! Otherwise crond will send the output
of the script to your mail addres - which could be annoying
For debugging purpose you can also execute the cronjob by your self.
If you start a new Statusengine Worker Node, the Node gets automatically
added to the table statusengine_nodes
.
This is one of the reasons, why the node_name
needs to be unique.
How ever. If you want to remove a node from your cluster, you need to do this
manually.
For this task, you can use the command /opt/statusengine/worker/bin/Console.php cluster
To keep things automatable (e.g. using Ansible), you can pass all data as parameters, like in the following example.
Admins can run the command without the parameter --nodename
to get into an interactive shell.
--help
is your friend
Statusengine Worker provides a simple CLI tool, to get basic metrics about
the worker performance.
Execute the command /opt/statusengine/worker/bin/Console.php statistics
to get a human friendly output
/opt/statusengine/worker/bin/Console.php statistics --watch 3
for automatically refresh every 3 seconds.
/opt/statusengine/worker/bin/Console.php statistics --naemon
to change to output format to Naemon/Nagios performance data
Example Grafana Dashboard
--help
is your friend
Statusengine Worker is able to store live data to an Redis in-memory database.
Use cases:
Statusengine Worker will save the following data to Redis:
Statusengine always require an alternative storage backend to Redis (MySQL or CrateDB), for
the cluster status and the external command router. To enable the Redis backend,
set use_redis=1
in the Statusengine Worker config.yml
.
A list of all Services in state "Ok"
Service status data of a particular service
Internal Statusengine statistics
Statusengine 3.7 contains major changes to the MySQL database schema. Please follow the Update to 3.7 instructions first.
Make sure you have installed the php extension bcmath
. You can check if the extension is loaded using this command: php -m |grep bcmath
.
If you had installed Statusengine through git
, the update will be done quickly.
{[{commands[selectedOs].stopStatusengineWorker}]}
cp -r /opt/statusengine/worker /some/backup/path
cd /opt/statusengine/worker git pull origin master composer update
--dry-run
the update statements will only be print to the CLI but not executed.
/opt/statusengine/worker/bin/Console.php database --update
/opt/statusengine/worker/lib
for any database update files.
crateDB_3.1.0_TO_3.2.0.sql
for example.
statusengine_dbversion
.
vimdiff /opt/statusengine/worker/etc/config.yml /opt/statusengine/worker/etc/config.yml.example
{[{commands[selectedOs].startStatusengineWorker}]}
{[{commands[selectedOs].stopStatusengineWorker}]}
cp -r /opt/statusengine/worker /some/backup/path
mysqldump -u statusengine -p --databases statusengine --flush-privileges --single-transaction --triggers --routines --no-tablespaces --events --hex-blob --ignore-table=statusengine.statusengine_perfdata > /opt/statusengine/statusengine_dump.sql
cd /opt/statusengine/worker git pull origin master composer update
vimdiff /opt/statusengine/worker/etc/config.yml /opt/statusengine/worker/etc/config.yml.example
mysql -u statusengine -p statusengine < /opt/statusengine/worker/lib/mysql_update.sql
/opt/statusengine/worker/bin/Console.php database --update
{[{commands[selectedOs].startStatusengineWorker}]}
For better debugging, you can run Statusengine in foreground. (Exit with STRG+C)