Ad Widget

Collapse

After updates from 3.4 up to 4.0 some scripts stopped working 'Not supported'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ZFPuhi
    Junior Member
    • Oct 2019
    • 10

    #1

    After updates from 3.4 up to 4.0 some scripts stopped working 'Not supported'

    Hello,

    After successful update of the agents and zabbix server from 3.4 up to 4.0 I was really happy, but unfortunately I didn't notice in time that some of the scripts will need to be re-worked. In this case I need assistance on how to deal with the postfix collection script, here is what Zabbix web says "Value "/etc/zabbix/zabbix_agentd.scripts/postfix: line 48: logtail: command not found
    0" of type "string" is not suitable for value type "Numeric (unsigned)"" and here is the script itself:


    Code:
    module=$1
    
    item=$2
    
    
    
    
    function usage(){
    
            name=$(basename $0)
    
            echo "Postfix collect script for zabbix - http://www.netkiller.cn"
    
            echo "${name} <module> <item>"
    
            echo "<queue> <active|deferred>"
    
            echo "<status> <active|deferred|sent|bounced|expired>"
    
            echo "<log> <active|deferred|sent|bounced|expired|string>"
    
            echo "<code> <200|550|421|......>"
    
            exit
    
    }
    
    
    
    
    if [ -z ${module} ]; then
    
            usage
    
    fi
    
    
    
    
    if [ ${module} == "discovery" ]; then
    
            echo '{"data":[{"{#CODE}":"200"},{"{#CODE}":"211"},{"{#CODE}":"214"},{"{#CODE}":"220"},{"{#CODE}":"221"},{"{#CODE}":"250"},{"{#CODE}":"251"},{"{#CODE}":"252"},{"{#CODE}":"354"},{"{#CODE}":"421"},{"{#CODE}":"450"},{"{#CODE}":"451"},{"{#CODE}":"452"},{"{#CODE}":"50$
    
            exit
    
    else
    
        if [ -z ${item} ]; then
    
                    usage
    
            fi
    
    fi
    
    
    
    
    if [ ${module} == "queue" ]; then
    
            if [ ${item} == "active" ]; then
    
                    postqueue -p | egrep -c "^[0-9A-F]{10}[*]"
    
            fi
    
    if [ ${item} == "deferred" ]; then
    
                    postqueue -p | egrep -c "^[0-9A-F]{10}[^*]"
    
            fi
    
    elif [ ${module} == "status" ]; then
    
            status=("active" "deferred" "sent" "bounced" "expired")
    
            for val in ${status[@]}; do
    
    
    
    
                    if [ $val == $item ]; then
    
                            logtail -f /var/log/maillog -o /var/tmp/postfix.${item}.logtail | grep -c "postfix/smtp.*status=${item}"
    
                    fi
    
            done
    
    elif [ ${module} == "log" ]; then
    
            if [ ${item} == "timeout" ]; then
    
                    logtail -f /var/log/maillog -o /var/tmp/postfix.timeout.logtail | grep -c "postfix/smtp.* Connection timed out"
    
            elif [ ${item} == "unreachable" ]; then
    
                    logtail -f /var/log/maillog -o /var/tmp/postfix.unreachable.logtail | grep -c "Network is unreachable"
    
            elif [ ${item} == "refused" ]; then
    
                    logtail -f /var/log/maillog -o /var/tmp/postfix.refused.logtail | grep -c "Connection refused"
    
            fi
    
    elif [ ${module} == "code" ]; then
    
            logtail -f /var/log/maillog -o /var/tmp/postfix.${item}.logtail | grep -c "said: ${item} "
    
    else
    
        usage
    
    fi
    In this case i know that some changes need to be made, from the example in the documentation it was "$1" to be changed to "#FSNAME", but I didn't quite understand it. Could anyone simply inform me what needs to be changed here exactly and with what, so that I can afterwards work on all of the rest scripts/templates that the server is currently using I will be very thankful.


    Ho ho ho Happy Holidays.

  • AvaTTaR
    Member
    • Dec 2018
    • 96

    #2
    at first try "which logtail" on your server - it seems like you don`t have this app on the server, and you just need it to be installed, else you need to set full path to logtail in every place where is used in the script (of use something like logtail=$(which logtail) and replace in script all logtail to $logtail)

    Comment

    • ZFPuhi
      Junior Member
      • Oct 2019
      • 10

      #3
      Hello AvaTTaR , thank you for the suggestion.

      I did install the logtail but it still says the same thing, the next step was to change it to Float instead of
      unsigned, still no joy. I added

      /usr/sbin/logtail -f
      to all of the commands since I wasn't sure how to replace the path with variable such as
      logtail=$PATH:/usr/sbin/logtail
      but wasn't sure if it will work like that.

      Any other suggestions?

      Comment

      • AvaTTaR
        Member
        • Dec 2018
        • 96

        #4
        Strange... make sure that zabbix have permission to execute logtail, maybe even try to set chmod 777 logtail
        If it would not help try to create somewhere on your server shell script with this code(don`t foget to add #!/bin/bash at first line and execute chmod +x on the file) and try to execute it, and see what happens, it will help to fined where you have problem, try and put your result here.

        About path variable, just for future it will be PATH=$PATH:/usr/sbin/logtail correct

        Comment

        • ZFPuhi
          Junior Member
          • Oct 2019
          • 10

          #5
          Hello AvaTTaR , found that the issue is not in the script but that the /var/log/maillog is ROOT permissions and because of that zabbix agen't can't access it. Now I need to find a way to change the permissions

          Comment

          • AvaTTaR
            Member
            • Dec 2018
            • 96

            #6
            you can just execute chmod 777 /var/log/maillog

            Comment

            • ZFPuhi
              Junior Member
              • Oct 2019
              • 10

              #7
              AvaTTaR logrotate will overwrite permissions once it runs. In this case I have used:

              setfacl -m user:zabbixuser:r /var/log/maillog* If it fails I will then edit the logrotate and add permissions on it.

              Comment

              Working...