Ad Widget

Collapse

How to run root command with using key system.run[]

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • studero
    Member
    • Aug 2023
    • 84

    #1

    How to run root command with using key system.run[]

    Hi all,

    I want to verify if on the server they are some files does not correctly removed. I have made a script to do this check. It's work nice. But I need to use zabbix_sender with this script on the client and schedule it.

    I have found may be another solution. It's to create a new item with the key system.run[lsof |grep u02]. But if I test this commande the result is empty.

    If I run only system.run[lsof], I have a result but with some "permission denied" for all open file does not run with zaggix agent user.

    Do you have a solution to resolve this permission problem ?

    THX
    Regards
    Olivier

  • Answer selected by studero at 04-04-2024, 09:44.
    tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    The general solution for this problem is to have the item do system.run[/usr/bin/sudo /usr/bin/lsof | grep u02]

    and then add an /etc/sudoers.d/zabbix-agent file with the necessary sudo rule, including the NOPASSWD tag, so that the 'zabbix' user can use sudo to run /usr/bin/lsof without needing a password.

    What you're doing isn't a "Remote command" (that's something else), but remote commands often need the same type of elevated privileges, so there's an example in that section of the documentation on setting up sudo for zabbix so that it can run some set of commands as root without a password.

    Comment

    • tim.mooney
      Senior Member
      • Dec 2012
      • 1427

      #2
      The general solution for this problem is to have the item do system.run[/usr/bin/sudo /usr/bin/lsof | grep u02]

      and then add an /etc/sudoers.d/zabbix-agent file with the necessary sudo rule, including the NOPASSWD tag, so that the 'zabbix' user can use sudo to run /usr/bin/lsof without needing a password.

      What you're doing isn't a "Remote command" (that's something else), but remote commands often need the same type of elevated privileges, so there's an example in that section of the documentation on setting up sudo for zabbix so that it can run some set of commands as root without a password.

      Comment

      Working...