Ad Widget

Collapse

Zabbix user; command not found

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrlindenwillow
    Junior Member
    • Oct 2013
    • 4

    #1

    Zabbix user; command not found

    Zabbix 2.0.9
    CentOS 6.4 Final 64bit

    I created a MediaType: script (aws_sms.sh)
    I realized that zabbix user passwd is /sbin/nologin updated to /bin/bash

    the home directory did not get created during install; I created one, manually added .bashrc.

    restarted zabbix-server.

    during an alert the command in the script that is referring to AWS cli tools is not found?

    Code:
    #!/bin/bash
    to=$1
    subject=$2
    body=$3
    
    aws sns publish  --topic-arn "<mytopicarn>" --message "$subject**$body"
    I can login as zabbix user and run command but then none of my .bashrc env. variables are picked up, which I think i may need .bash_profile? will test next.. But that wont solve the real problem when zabbix-server runs command i get aws command not found.

    Also tried doing some stuff in visudo
    Cmnd_Alias AWS = /usr/lib/aws/

    %zabbix ALL=AWS NOPASSWD=ALL

    Which gave me errors every time i tried to save.

    also tried
    %zabbix ALL=(ALL) ALL

    Maybe I should not refer to the zabbix group and just user?
    I was trying to keep it simple?

    Any hints or experience in allowing zabbix user to run bash scripts referring to shell commands would be appreciated!

    Thank you for your diligence.


    EDIT:
    I have updated the script with:
    #!/bin/sh
    /usr/lib/bin/aws

    The command is found!

    HOW do I give or get Environment variables for user zabbix?
    I created a .bashrc and .bash_profile with the correct data, but shell still returns please define AWS_DEFAULT_REGION
    i can set this in the command line, but after i fix this error it will ask for credentials, which i have created a path to for Env variable AWS_Credentials?

    Your insight is appreciated!
    Last edited by mrlindenwillow; 28-10-2013, 21:11. Reason: PROGRESS
  • mrlindenwillow
    Junior Member
    • Oct 2013
    • 4

    #2
    Sorted..
    I suppose this is not a Zabbix question, but a linux question.. My bad..
    The full solution for getting zabbix user to use AWS cli tools in bash script was as follows:

    point directly to AWS CLI tools command; i stored my cli tools in /usr/local/bin/aws

    in zabbix home directory create .aws file with config file for AWS credentials and default region.

    Create script to do the things you want..
    I Used AWS to send Texts

    /usr/local/bin/aws sns publish --topic-arn "<mytopicarn>" --message "$subject**$body"

    Happy successes!

    Comment

    Working...