Ad Widget

Collapse

[13] Permission denied

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SgtMcFuzzyboots
    Junior Member
    • Oct 2015
    • 7

    #1

    [13] Permission denied

    Hi there!

    I am trying out some things that I find on the internet so I can learn new methods and techniques. Now I've come across a little tidbit from a Github user called Ericoc. The tidbit.

    Now I noticed how he made a connection between Zabbix and Slack, something I was interested in. I had set up a server at Digitaloceans, followed their instructions as how to setup Zabbix and I then followed Ericoc's instructions on how to make his script work.

    I tested the script using a terminal and it works just fine but here is the problem. When I make sure that my Zabbix server is having a problem, it fails to perform the action. The reason being: /etc/zabbix/alert.d//slack.sh: [13] Permission denied

    Now this is my first time using Zabbix and I'm practically an infant when it comes to ubuntu 14.04. Can someone hold my hand here and guide me through this? If so that would be smashing and it would be a good learning experience.

    Thanks
    Last edited by SgtMcFuzzyboots; 20-10-2015, 10:51.
  • bagni
    Senior Member
    Zabbix Certified Specialist
    • Mar 2012
    • 164

    #2
    Check your zabbix_server.conf to locate the path of "AlertScriptsPath" and put on it the slack.sh.

    If the path is /etc/zabbix/alert.d/ (sound strange but could be) check the permission on directory and file, because the script will be executed by zabbix user (not privileged).

    Comment

    • SgtMcFuzzyboots
      Junior Member
      • Oct 2015
      • 7

      #3
      The slack.sh is indeed in the path of the AlertScriptsPath and the path is indeed /etc/zabbix/alert.d/

      I checked the permissions on the /etc/zabbix/ folder which returned

      drwxr-xr-x 4 zabbix zabbix 4096 Oct 19 11:02 /etc/zabbix/

      and I also checked the /etc/zabbix/zabbix_agentd.conf which returned

      -rw-r--r-- 1 zabbix zabbix 7578 Oct 19 10:18 /etc/zabbix/zabbix_agentd.conf

      Like I mentioned before I'm not that experienced with Ubuntu 14.04 and everything I can do at the moment is via terminal. I expect that I should change the permissions but how would I do that?

      Thanks for helping me by the way

      Comment

      • bagni
        Senior Member
        Zabbix Certified Specialist
        • Mar 2012
        • 164

        #4
        Hi,
        it ins't a Ubnutu related issue, but a linux/unix administration.
        But maybe you can fix with this command:

        sudo chmod +x /etc/zabbix/alert.d/slack.sh

        Comment

        • SgtMcFuzzyboots
          Junior Member
          • Oct 2015
          • 7

          #5
          Originally posted by bagni
          Hi,
          it ins't a Ubnutu related issue, but a linux/unix administration.
          But maybe you can fix with this command:

          sudo chmod +x /etc/zabbix/alert.d/slack.sh
          Ahh my bad then ^^;
          That did seem to fix it! It now seems to have permissions.

          It now posts in Slack! Thanks I do happen to notice something about these posts. I tried it 4 times in total because I accidently screwed up the $subject bit so it showed the wrong emoji but not all messages are shown.

          It first shows PROBLEM and after that it should show OK when I fix my self made test error. During the first try it showed both PROBLEM and OK.
          At the 2nd try it only showed OK. Third only showed PROBLEM and 4th doesn't show anything at all.

          The 4th try had the same slack.sh script and the same Zabbix configurations as the 1st try.

          Is there a cap on the amount of messages within a certain amount of time???

          Comment

          • bagni
            Senior Member
            Zabbix Certified Specialist
            • Mar 2012
            • 164

            #6
            Hi,
            there isn't a cap but a rate limit:
            Slack platform features and APIs rely on rate limits to help provide a predictably pleasant experience for users.

            Comment

            • SgtMcFuzzyboots
              Junior Member
              • Oct 2015
              • 7

              #7
              Interesting but I don't think I went over this limit though.
              They stated: "In general we allow applications that integrate with Slack to send no more than one message per second"

              The PROBLEM and OK messages should have at least more than one second between each other. More like minutes actually.

              Comment

              • seanwasere
                Junior Member
                • May 2012
                • 12

                #8
                Sounds like you need to allow your script execute permission for the user.




                example, create file
                Code:
                /usr/lib/zabbix/alertscripts/slackalert.sh
                with code
                Code:
                #!/bin/bash
                curl -X POST -H 'Content-type: application/json' --data '{"text":"'"$1"'"}' https://hooks.slack.com/services/[your slack hook tokens]
                and allow it execute permission
                Code:
                $ chmod a+x /usr/lib/zabbix/alertscripts/slackalert.sh
                Go back into Zabbix and create a new media type,
                Name = 'Slack Alert'
                Type = 'Script'
                Script Name = slackalert.sh
                Script Parameters = {ALERT.SUBJECT}

                and in Zabbix4.2 you can test using the 'test' option next to your the new media type.

                Comment

                Working...