systemctl zabbix invoke sudo shell command in python scrip

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












two days ago,I change my running of zabbix-agent from zabbix_agentd run directly to systemctl start zabbix-agent.There is a weired thing.I write a python script to monitor java GC status, which invoke "sudo".



command jstat is installed with jdk env in the $PATH setting in /etc/profile((/xxx/xxx/bin/jstat,not in/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin))
the two line which python invoke shell command



  1. jstat = commands.getoutput("which jstat")

  2. subprocess.Popen(['sudo',jstat, opts, self.pdict['pid']], stdout=subprocess.PIPE)

when using zabbix_agentd directly. commands.getoutput("which jstat") can give value of the abosolutely path to the statement 2.However it is not recognise when running zabbix agent with supervisor.which give a output
enter image description here



what cause this difference between running process directly and systemctl ?










share|improve this question







New contributor




focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • when running zabbix agent with systemctl
    – focus zheng
    8 mins ago














up vote
0
down vote

favorite












two days ago,I change my running of zabbix-agent from zabbix_agentd run directly to systemctl start zabbix-agent.There is a weired thing.I write a python script to monitor java GC status, which invoke "sudo".



command jstat is installed with jdk env in the $PATH setting in /etc/profile((/xxx/xxx/bin/jstat,not in/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin))
the two line which python invoke shell command



  1. jstat = commands.getoutput("which jstat")

  2. subprocess.Popen(['sudo',jstat, opts, self.pdict['pid']], stdout=subprocess.PIPE)

when using zabbix_agentd directly. commands.getoutput("which jstat") can give value of the abosolutely path to the statement 2.However it is not recognise when running zabbix agent with supervisor.which give a output
enter image description here



what cause this difference between running process directly and systemctl ?










share|improve this question







New contributor




focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • when running zabbix agent with systemctl
    – focus zheng
    8 mins ago












up vote
0
down vote

favorite









up vote
0
down vote

favorite











two days ago,I change my running of zabbix-agent from zabbix_agentd run directly to systemctl start zabbix-agent.There is a weired thing.I write a python script to monitor java GC status, which invoke "sudo".



command jstat is installed with jdk env in the $PATH setting in /etc/profile((/xxx/xxx/bin/jstat,not in/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin))
the two line which python invoke shell command



  1. jstat = commands.getoutput("which jstat")

  2. subprocess.Popen(['sudo',jstat, opts, self.pdict['pid']], stdout=subprocess.PIPE)

when using zabbix_agentd directly. commands.getoutput("which jstat") can give value of the abosolutely path to the statement 2.However it is not recognise when running zabbix agent with supervisor.which give a output
enter image description here



what cause this difference between running process directly and systemctl ?










share|improve this question







New contributor




focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











two days ago,I change my running of zabbix-agent from zabbix_agentd run directly to systemctl start zabbix-agent.There is a weired thing.I write a python script to monitor java GC status, which invoke "sudo".



command jstat is installed with jdk env in the $PATH setting in /etc/profile((/xxx/xxx/bin/jstat,not in/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin))
the two line which python invoke shell command



  1. jstat = commands.getoutput("which jstat")

  2. subprocess.Popen(['sudo',jstat, opts, self.pdict['pid']], stdout=subprocess.PIPE)

when using zabbix_agentd directly. commands.getoutput("which jstat") can give value of the abosolutely path to the statement 2.However it is not recognise when running zabbix agent with supervisor.which give a output
enter image description here



what cause this difference between running process directly and systemctl ?







sudo python zabbix systemctl






share|improve this question







New contributor




focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 11 mins ago









focus zheng

1




1




New contributor




focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • when running zabbix agent with systemctl
    – focus zheng
    8 mins ago
















  • when running zabbix agent with systemctl
    – focus zheng
    8 mins ago















when running zabbix agent with systemctl
– focus zheng
8 mins ago




when running zabbix agent with systemctl
– focus zheng
8 mins ago










1 Answer
1






active

oldest

votes

















up vote
0
down vote













I also try to add jstat to /usr/bin it is ok because when using sudo,it find the command in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin.





share








New contributor




focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    focus zheng is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477870%2fsystemctl-zabbix-invoke-sudo-shell-command-in-python-scrip%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I also try to add jstat to /usr/bin it is ok because when using sudo,it find the command in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin.





    share








    New contributor




    focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote













      I also try to add jstat to /usr/bin it is ok because when using sudo,it find the command in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin.





      share








      New contributor




      focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



















        up vote
        0
        down vote










        up vote
        0
        down vote









        I also try to add jstat to /usr/bin it is ok because when using sudo,it find the command in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin.





        share








        New contributor




        focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        I also try to add jstat to /usr/bin it is ok because when using sudo,it find the command in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin.






        share








        New contributor




        focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share


        share






        New contributor




        focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 6 mins ago









        focus zheng

        1




        1




        New contributor




        focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        focus zheng is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




















            focus zheng is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            focus zheng is a new contributor. Be nice, and check out our Code of Conduct.












            focus zheng is a new contributor. Be nice, and check out our Code of Conduct.











            focus zheng is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477870%2fsystemctl-zabbix-invoke-sudo-shell-command-in-python-scrip%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?