Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
Created January 14, 2019 10:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tuxmartin/e0bd2f41399c5fc3c3e98de0587eef3d to your computer and use it in GitHub Desktop.
Save tuxmartin/e0bd2f41399c5fc3c3e98de0587eef3d to your computer and use it in GitHub Desktop.
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