Ad Widget

Collapse

Monitoring Windows Shared Folder - need tips!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • edgdelgado
    Junior Member
    Zabbix Certified Specialist
    • Jul 2013
    • 19

    #1

    Monitoring Windows Shared Folder - need tips!

    Hi!

    Im trying to monitor if my shared folder going well like this:

    - Clear messages, umount (will use if later), try to mount and check /var/log/messages for errors.
    If null = (1)OK, else = (0)BAD

    If I run the script manually the zabbix update the item status after some time, if I let the zabbix do all the work, the item never updates

    Code:
    #!/bin/bash
    DOMAIN=****
    LOGIN=*****
    PWD=****
    LOGFILE=/var/log/messages
    umount /mnt/foz-fs01-pe/
    echo -n > /var/log/messages
    mount -t cifs //****/test /mnt/****/ -o username=$LOGIN,domain=$DOMAIN,password=$PWD
    
    RESULT=`cat /var/log/messages`
    
    if [ "$RESULT" == "" ]; then
       echo "1"
    
    else
       echo "0"
    fi
    agentd.conf:
    UserParameter=fs.check02,/opt/zabbix_scripts/smb2.sh

    messages when I manually execute my script
    * after doing this the item on zabbix updates

    Code:
    [root@FOZ-ZABBIX-PE zabbix_scripts]# ./smb2.sh
    1
    [root@FOZ-ZABBIX-PE zabbix_scripts]# ./smb2.sh
    mount error(13): Permission denied
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
    0
    [root@FOZ-ZABBIX-PE zabbix_scripts]#
  • steveboyson
    Senior Member
    • Jul 2013
    • 582

    #2
    Zabbix runs under a "normal" user account thus is neither allowed to mount/umount nor write into /var/log/messages.

    For the first, you shoud use "sudo" and place an entry in /etc/sudoers.
    For the second, use "logger" or simply write into a zabbix-writeable file.

    Third: "cat /var/log/messages" is nonsense. It spits out the whole file and succeeds if you have the rights to do so and fails if not. It gives no details about your mount attemps.

    Better you should test if your mount attemp succeeds either by checking the error code of the "mount" command or if there are any subdirectories under your mount-point /mnt/****
    Last edited by steveboyson; 31-10-2013, 01:39.

    Comment

    • edgdelgado
      Junior Member
      Zabbix Certified Specialist
      • Jul 2013
      • 19

      #3
      Hello!

      I just figured out yesterday I can't mount with normal user...

      Thanks for all other tips I will work to make it better...


      cya

      Comment

      Working...