Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nahrazeni/pridani parametru u systemd sluzby

Priklad: chceme zmenit hodnotu Nice pro sluzbu zabbix-agent.service

Vychozi je /lib/systemd/system/zabbix-agent.service, na ten nesahame, protoze by nam ho prepsalo apt pri aktualizaci.

Vyvorime adresar a soubor s nastavenim:

mkdir -p /etc/systemd/system/zabbix-agent.service.d
touch /etc/systemd/system/zabbix-agent.service.d/10-custom-nice.conf

Syntaxe je JMENO.service.d, tedy zabbix-agent.service.d.

do souboru /etc/systemd/system/zabbix-agent.service.d/10-custom-nice.conf dame:

[Service]
Nice=-4

a pote:

systemctl daemon-reload
systemctl restart zabbix-agent.service

a uz to funguje :-)

root@server:/# systemctl status zabbix-agent.service 
● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/zabbix-agent.service.d
           └─10-custom-nice.conf
   Active: active (running) since Mon 2019-01-14 11:05:42 CET; 1min 59s ago

root@server:/# ps ax -o ni,cmd | grep [z]abbix
 -4 /usr/sbin/zabbix_agentd --foreground
 -4 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
 -4 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
 -4 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
 -4 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
 -4 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root@server:/#

systemd pouziva i nas config a podle vypisu ps je nice hodnota pro vsechny zabbix procesy opravdu -4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.