Ad Widget

Collapse

windows diskfree - without agents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michu
    Junior Member
    • Nov 2004
    • 20

    #1

    windows diskfree - without agents

    hey all

    i needed to check, if my windows server running out of disk-space but without any agents... so i created some scripts to check it.. not the most elegant solution but perhaps someone find it usefull:

    (you need to install this scrips on the zabbix machine)

    -[hdvoll.sh]------------------------------
    #!/bin/bash

    ##
    ## 25.05.05 - michael vogt - v 1.0
    ##
    ## gibt benutzen plattenplatz in prozent zurueck
    ## parameter 1 ist hostname, parameter 2 ist disk id
    ##
    ## zb "./df 192.168.22.42 1" gibt die diskauslastung der disk 1 zurueck
    ##

    host=$1
    disk=$2

    mulfix=1000000000 #because bash dosnt know floats... (or i dont know how to use it..)

    SUSED=$(snmpget -P e -O q $host public host.hrStorage.hrStorageTable.hrStorageEntry.hrSto rageUsed.$disk | cut -f2 -d" ")
    STOTAL=$(snmpget -P e -O q $host public host.hrStorage.hrStorageTable.hrStorageEntry.hrSto rageSize.$disk | cut -f2 -d" ")

    #echo "tot: $STOTAL"
    #echo "use: $SUSED"

    if [ "$STOTAL" = "0" ]
    then printf 'ERROR\n'
    else
    if [ "$STOTAL" = "" ]
    then printf 'ERROR\n'
    exit 1;
    fi
    divres=$((100 * $mulfix / $STOTAL))
    resultm=$(($divres * $SUSED))
    resultUnrounded=$(($resultm / ($mulfix/10))) # a primitive rounding algo...
    resultUnroundedA=$(($resultUnrounded + 5))
    result=$(($resultUnroundedA /10))
    echo $result
    fi
    --------------------------------------------------------------

    -[cronjob.sh]-------------------------------------------------------------
    #use the tmp file, else its too fast and we get strange results
    #SERVER01 F:
    /opt/zabbix/hd_voll server01 4 > /opt/zabbix/disk/tmp
    mv /opt/zabbix/disk/tmp /opt/zabbix/disk/server014
    #SERVER01 C:
    /opt/zabbix/hd_voll server01 2 > /opt/zabbix/disk/tmp
    mv /opt/zabbix/disk/tmp /opt/zabbix/disk/server012
    --------------------------------------------------------------

    add the following lines to zabbix_agentd.conf and restart zabbix_agentd
    UserParameter=DiskFree[SERVER01f],/bin/cat /opt/zabbix/disk/server014
    UserParameter=DiskFree[SERVER01c],/bin/cat /opt/zabbix/disk/server012

    now make sure, that the cronjob.sh script is called once per hour with cron.

    now in zabbix use the localhost to add these 2 hosts (image1)

    detail host view: image2.png

    check image3.png for a rela life example..

    regards
    michu
    Attached Files
  • morgolis
    Member
    • Oct 2004
    • 33

    #2
    From reading the script, it appears you are using SNMP to get the information therefore a SNMP Daemon / service needs to be running on the Microsoft server.

    Comment

    • michu
      Junior Member
      • Nov 2004
      • 20

      #3
      ..

      yes exactly... but i think in a company, the microsoft snmp service is easier to install than a 3rd party service...

      Comment

      Working...