Ad Widget

Collapse

Zabbix Server problem need to be automate.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • access2nitan
    Junior Member
    • Mar 2017
    • 8

    #1

    Zabbix Server problem need to be automate.

    Hello All.

    This my first post here.

    We've installed Zabbix 3.2 on Centos 7 and its working perfectly. But I want to take one more step and want that if any server/service is getting down, with the help of automation that problem should be resolved.Would it be possible in zabbix through scripts.

    I gone through Google but it says that we can only automate zabbix installation and configuration.
  • GPegel
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2015
    • 113

    #2
    I'm not really sure what your goal is. May I take a guess?

    For example, you have 10 servers running Apache and all are being monitored by Zabbix. All the 10 servers are running an Zabbix agent. When Apache is going down on 1 server and the Zabbix server is giving an alert about that Apache service being down, you want to automatically resolve this?

    If that is the case then you are able to use Zabbix for this. You have to create an action based on an alert. So the first operation within that action is, alerting, the second operation can be "operation type" -> "remote command" -> "Type" -> "Custom Script" and that could be something like this "systemctl restart httpd.service"

    When Apache is back up and running you will receive a new alert saying that Apache is back up and running thus your alert is being automatically resolved.

    I hope this helps.

    Comment

    • access2nitan
      Junior Member
      • Mar 2017
      • 8

      #3
      zabbix problem automation.

      Yes Sir, you guess me right.

      As you've mention above the goal i want to achieve it and working on it.
      Thanks for your valuable reply and I'm going to follow your instructions.Once I got something which is related to my goal and I'll come back with solution.

      Comment

      • access2nitan
        Junior Member
        • Mar 2017
        • 8

        #4
        zabbix problem automation.

        Dear Sir,

        Thanks for your help and its helps me lots to understand lots of other things.

        Sir I have also followed below given video URL and I did all the configuration.
        But still service is still not starting and scratching my hair with this problem.

        Please help me what I'm doing wrong and do i need to take more action on it.

        URL:- https://www.youtube.com/watch?v=1QqoftGxbAM

        Waiting for your response.

        Comment

        • access2nitan
          Junior Member
          • Mar 2017
          • 8

          #5
          zabbix problem automation.

          Hi Sir,

          Thanks for your help and I've learned lots from your post. And I also followed more one more video about Zabbix Remote Command. Everything is going well excepted the Remote command.I'm getting the below given Error message.


          Error message:-
          Command actions

          Step Time Status Command Error
          1 2017-03-08 23:27:23 Not sent ip-Hostanem:sudo /etc/init.d/httpd start Not supported by Zabbix Agent

          Comment

          • GPegel
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2015
            • 113

            #6
            At first, you do not need to enter the "sudo" command because the Zabbix user should not be in the sudoers file. Anyway... could you try to make a screenshot of your current actions and operation steps? Maybe I'm able to see what's wrong.

            Comment

            • access2nitan
              Junior Member
              • Mar 2017
              • 8

              #7
              zabbix problem automation.

              Sir,

              Thank for your help.


              Sir this time i took one step ahead and now I can see the zabbix server is trying to take command action on zabbix client httpd service,Which is already down. and also executing the service command.But when I check the service on client machine its still down. And now waiting for some help from your end.

              Sorry Sir i could not upload my zabbix configuration Don't know why.May be due to attachment upload restriction.
              Below is the Action status.

              1 2017-03-11 07:26:29 Executed ip-ClientmachineIP:/etc/init.d/httpd start
              No error
              Last edited by access2nitan; 11-03-2017, 04:30.

              Comment

              • GPegel
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Dec 2015
                • 113

                #8
                It almost seems that the Zabbix user is not able to start or execute a command. Could you try this one?

                1. open a CLI
                2. type: "sudo visudo"
                3. add this line at the end of the file "Defaults:zabbix !requiretty"

                And if this doesn't work, try to this:

                1. open a CLI
                2. type: "vi /etc/zabbix/scripts/my_super_awesome_script.sh"
                3. add the following to this file:

                Code:
                #!/bin/bash
                systemctl start httpd.service
                4. save and exit by pressing ":wq"
                5. type: "chmod +x /etc/zabbix/scripts/my_super_awesome_script.sh" to make it executable.
                6. In Zabbix set the action to execute the "/etc/zabbix/scripts/my_super_awesome_script.sh" and see what happens.
                Last edited by GPegel; 13-03-2017, 15:35. Reason: i forgot step 5

                Comment

                • access2nitan
                  Junior Member
                  • Mar 2017
                  • 8

                  #9
                  Zabbix automation.

                  Dear Sir,

                  Sorry for being late response.

                  Thanks for your reply.Sir I've followed your given instruction.I've compile zabbix agent and I am using Aws linux server for zabbix agent installation.

                  1:- Create a file inside /usr/local/etc default config location.
                  2:- name zabbix.sh and copy and paste above given lines.
                  3:- Then go back to zabbix server and edit action and edit and then script> and put the script path where it is in zabbix-agent.

                  OR I've also did one more step.
                  Create a Global script with the name of zabbix.sh and attach with action.

                  Don't want to give up please give me more suggestions.
                  See the below given command output.

                  1 2017-03-19 12:34:29 Executed ip-172-31-0-231:/usr/local/etc/zabbix/zabbix.sh
                  1 2017-03-19 12:34:29 Executed ip-172-31-0-231:/usr/local/etc/zabbix/zabbix.sh

                  Service is still stopped on zabbix agent.

                  Sir I'm also thinking to change the OS once may be due to OS problem zabbix is unable to start httpd service n zabbix-agent.

                  Please advice.

                  Comment

                  • GPegel
                    Senior Member
                    Zabbix Certified SpecialistZabbix Certified Professional
                    • Dec 2015
                    • 113

                    #10
                    Keep in mind, when Zabbix says it executed the script it doesn't say anything about actually being executed. Zabbix send the request to execute, that actions happens indeed but it doesnt't say antyhing about the script being actually executed at the OS.

                    Is your script executable? As in, did you do a "chmod +x" on that ".sh" file?

                    Comment

                    • access2nitan
                      Junior Member
                      • Mar 2017
                      • 8

                      #11
                      Zabbix automate

                      Yes sir. I have give execute permission to .sh file .
                      # chmod +x filename.sh

                      I have also read lots of other form but none of competed the requirment.Most of the video are only showing how to take action in it .But none of one show how the procedure how we can do it.

                      Comment

                      • GPegel
                        Senior Member
                        Zabbix Certified SpecialistZabbix Certified Professional
                        • Dec 2015
                        • 113

                        #12
                        I have another suggestion for you. Can you add this to your "visudo" ? :

                        Code:
                        zabbix  ALL=NOPASSWD: /usr/lib/zabbix/scripts/filename.sh
                        Keep in mind that your folder could be different from my configuration. ;-)

                        Comment

                        • access2nitan
                          Junior Member
                          • Mar 2017
                          • 8

                          #13
                          zabbix problem automation.

                          Hi,

                          I've also tried the above given suggest but could get success.And I also doing google alot.

                          # zabbix ALL=NOPASSWD: /usr/local/zabbix/filename.sh

                          Comment

                          Working...