Ad Widget

Collapse

IF statement in trigger expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bubi92
    Junior Member
    • Mar 2019
    • 18

    #1

    IF statement in trigger expression

    Eyo Guys!

    I would like to build a new disk space template with some dependency.
    For example:
    IF the full disk size is bigger than 100GB, and there is less then 10GB free space
    OR
    IF the full disk size is smaller than 100GB, and there is less then 5GB free space
    I would like to get an alert.

    I know how to add an "AND" variable.


    Click image for larger version

Name:	Screenshot 2022-07-13 at 13.32.42.png
Views:	2419
Size:	26.9 KB
ID:	447808

    My problem is, how to make an IF statement in the expression.
    Gino
    Attached Files
  • vladimir_lv
    Senior Member
    • May 2022
    • 240

    #2
    Regarding documentation, there is no way to use IF statement

    Comment

    • Hamardaban
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • May 2019
      • 2713

      #3
      The entire trigger expression is an IF condition! You don't need anything more
      Here is the trigger expression scheme you need:
      Code:
      (last(disk_size) >100G and last(free_space)<10G) or (last(disk_size) <100G and last(free_space)<5G)

      Comment

      • bubi92
        Junior Member
        • Mar 2019
        • 18

        #4
        Okay. So i translated to my enviroment

        4 new TAG on every windows hosts

        $BIGDISK_UTIL_CRIT=10GB

        $SMALLDISK_UTIL_CRIT=5GB

        $XCH_DISKUTIL_CRIT=12%

        $XCH= X (Is it exchange server or not)


        So first two line: not equal to xch, so if bigger than 100GB will alert under under 10GB and not equal to xch, and smaller than 100GB will alert under 5GB - clear

        In the next lines i would like to define if XCH=X(its an exchange server) check the C drive with percentage, and every other drives with the same metod as the not exchange server drives(if bigger than 100GB will alert under under 10GB - if smaller than 100GB will alert under 5GB)


        Code:
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[{#FSNAME},total])>100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[{#FSNAME},free])<{$BIGDISK_UTIL_CRIT} and {$XCH}<>"X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[{#FSNAME},total])<100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[{#FSNAME},free])<{$SMALLDISK_UTIL_CRIT} and {$XCH}<>"X"
        
        or
        
        last (/Template OS Windows Disk Space Deepblue/vfs.fs.size[C:,pfree])<{$XCH_DISKUTIL_CRIT} and {$XCH}="X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[D:,total])>100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[D:,free])<{$BIGDISK_UTIL_CRIT} and {$XCH}="X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[D:,total])<100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[D:,free])<{$SMALLDISK_UTIL_CRIT} and {$XCH}="X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[E:,total])>100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[F:,free])<{$BIGDISK_UTIL_CRIT} and {$XCH}="X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[E:,total])<100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[F:,free])<{$SMALLDISK_UTIL_CRIT} and {$XCH}="X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[G:,total])>100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[G:,free])<{$BIGDISK_UTIL_CRIT} and {$XCH}="X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[G:,total])<100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[G:,free])<{$SMALLDISK_UTIL_CRIT} and {$XCH}="X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[H:,total])>100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[H:,free])<{$BIGDISK_UTIL_CRIT} and {$XCH}="X"
        
        or
        
        last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[H:,total])<100G and last(/Template OS Windows Disk Space Deepblue/vfs.fs.size[H:,free])<{$SMALLDISK_UTIL_CRIT} and {$XCH}="X"
        This code unfortunately not working, guess the problem is that i defined the drive letters. Is it a syntax or a logical error? What is the correct syntax? Or is there a "smarter", easier way to do this.

        (The final result what i want: Use only one disk template on every windows host and control the triggers with tags)
        (Template OS Windows Disk Space Deepblue is the name of my template)

        Comment

        Working...