
[[minion-tuning]]
= Tuning Minion
:description: How to adjust tuneable parameters on Minion, such as Java Heap, or open file descriptors.

Minion's resource requirements scale with its workload.
When assigned to locations with more nodes, interfaces, and services, the default settings may be insufficient.

[[minion-heap]]
== Tuning Java heap memory

. Edit the file `/etc/sysconfig/minion` (RHEL) or `/etc/default/minion` (Debian)

. Uncomment and modify the values for the `JAVA_MIN_MEM` and `JAVA_MAX_MEM` variables
+
[source, console]
----
# minimum amount of memory for the Karaf container to allocate
export JAVA_MIN_MEM=512M

# maximum amount of memory for the Karaf container to allocate
export JAVA_MAX_MEM=4096M
----

. If Minion is running when this change is made, it must be restarted to take effect.
+
[source, console]
----
systemctl restart minion
----


[[minion-nofile]]
== Tuning file descriptor limits

. Edit the minion unit file: 
+
[source, console]
----
systemctl edit minion
----

. In the area dictated by the comments in the editor, add:
+
[source, console]
----
LimitNOFILE=100000
----
NOTE: the value `100000` is used as an example only.

. Edit `/etc/sysconfig/minion` (RHEL) or `/etc/default/minion` (Debian)

. Uncomment and modify the values for the `MAX_FD` variable:
+
[source, console]
----
# maximum number of file descriptors to allocate
export MAX_FD=100000
----
NOTE: the value `100000` is used as an example only.

. Confirm the unit file reflects the changes:
+
[source, console]
----
# systemctl daemon-reload
# systemctl cat minion
[Unit]
Description=The OpenNMS Minion distributed client.
Requires=network.target network-online.target
After=network.target network-online.target

[Service]
User=minion
EnvironmentFile=-/opt/minion/etc/minion

PIDFile=/opt/minion/data/log/minion.pid
Type=forking

ExecStart=/opt/minion/bin/minion start
ExecStop=/opt/minion/bin/minion stop

AmbientCapabilities=CAP_NET_RAW CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

# /etc/systemd/system/minion.service.d/override.conf
LimitNOFILE=100000
----

. If the minion is running when this change is made, it must be restarted to take effect.
+
[source, console]
----
systemctl restart minion
----

[[minion-loglevel]]
== Adjusting the minion log level

In many situations it can be beneficial to change the log level to be more or less verbose.
Follow these steps to change it.

. Edit `$MINION_HOME/etc/org.ops4j.pax.logging.cfg`
+
NOTE: `$MINION_HOME` is `/opt/minion` on RHEL, and `/etc/minion` on Debian.

. Find and modify the `logger.opennms` section
+
[source, console]
----
# OPENNMS: Display all INFO logs for OpenNMS code
log4j2.logger.opennms.name = org.opennms
log4j2.logger.opennms.level = DEBUG
----

. No restart is required to change the log level.
