Ad Widget

Collapse

Solaris SSH check dont work!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sperr0w
    Member
    • Oct 2014
    • 44

    #1

    Solaris SSH check dont work!

    Hello!

    I'm trying to create Template for agentless Solaris monitoring in Zabbix.

    Here I trying to create LLD of Solaris disks. For my LLD I use SSH check and in Script box I type:

    Code:
    #!/usr/bin/bash
    
    {
      echo "{"
      echo "  \"data\":["
      while read -r line; do
        FSNAME=$(echo $line|awk '{print $2}'|sed -e 's/\\/\\\\/g' -e 's|/|\\/|g' -e 's/\./\\./g')
        FSTYPE=$(echo $line|awk '{print $3}')
        echo "  {"
        echo "    \"{#FSNAME}\":\"${FSNAME}\","
        echo "    \"{#FSTYPE}\":\"${FSTYPE}\""
        echo "  },"
      done < /etc/mnttab | sed -e '$d'
      echo "  }"
      echo "  ]"
      echo "}"
    }
    After I start this LLD on Solaris, I get error: Value Should be a JSON object.

    Here is what I know:

    1) Exactly the same LLD work fine on Linux. The only change is /etc/mtab instead of /etc/mnttab
    2) If I create /tmp/fs.sh file on solaris with this code, it also work fine and return me valid JSON.
    3) If I put /tmp/fs.sh in script field of LLD rule in solaris, LLD is also work fine.

    The only problem is if I trying to put script itseld in script field of LLD rule.
    Where is the problem? May be somebody find solution?
  • sperr0w
    Member
    • Oct 2014
    • 44

    #2
    I find the root problem.

    Code:
    FSTYPE=$(echo $line|awk '{print $3}')
    need to replace by:

    Code:
    FSTYPE=`echo $line|awk '{print $3}'`
    the same with FSNAME.

    Also
    Code:
    while read -r line; do
    must be replaced by:

    Code:
    while read line
    do
    The only thing is that I have error with sed:

    sed: command garbled: s/\/\\g

    How command

    Code:
    FSNAME=`echo $line|awk '{print $2}'|sed -e 's/\\/\\\\/g' -e 's|/|\\/|g' -e 's/\./\\./g'` m
    must looks like in Solaris?

    Comment

    Working...