Ad Widget

Collapse

Monitor several paths for new files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aratom
    Junior Member
    • Oct 2022
    • 6

    #1

    Monitor several paths for new files

    Hey there!

    I'm wondering how I could optimize my system. I'm monitoring several paths on different servers where different application export data or write a backup. Basically if I there has been no new file within 24 hours Zabbix notifies me and I know that some system failed.

    I already have a template with an item setup successfully. My key is vfs.dir.count[{$PATH},{$REG_INCL},{$REG_EXCL},{$TYPES_INCL},{$TY PES_EXCL},{$MAX_DEPTH},{$SIZE_MIN},{$SIZE_MAX},{$A GE_MIN},{$AGE_MAX},{$REG_EXCL_DIR}]. On the host I can specify the desired macro values.

    Trigger is last(item)<=0 and recovery last(item)>0 for the item.

    Until now I was very satisfied with my setup. Now I was wondering how could I improve my setup to e.g. monitor two paths on one server. Of course the exporting software could notify me over mail, Zabbix send, log file, Windows events, ... but I cannot change the software code because I don't have the source code and the developers stopped supporting this product.

    I thought a lot about how to implement this. My only idea was to create an item directly one the host for each file to monitor.

    I'm sure there would be a better way to implement this.

    If anything is unclear, I can try to improve my explanation.

    Thank you!
    Thomas
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    I will briefly describe the solution path (for details, go to the documentation): Create an LLD rule of the script type (in the script field, create a json containing a list of directories to track) which creates items from this json. https://www.zabbix.com/documentation...evel_discovery
    Hint: in the script, you can simply output the value of the macro, and write json to the macro.​

    Comment

    • aratom
      Junior Member
      • Oct 2022
      • 6

      #3
      thank you Hamardaban!

      I was able to get my basic setup working with your guidance.
      It was not easy to setup. Mostly because I didn't know how to work with macros and JavaScript. According to my research the official documentation has no example on this. So for future reference, hopefully it helps someone

      I created a template with a discovery rule of type script
      Code:
      var macro = '{$PATHS}';
      var array = macro.split(',');
      var obj = [];
      
      for(var i = 0; i < array.length; i++){
          obj.push({"{#PATH}": array[i]})
      }
      
      return JSON.stringify(obj);​
      Also I was not able to use forEach. Maybe it is my fault. I found no documentation on which functions are available.

      My item prototype uses the following key
      Code:
      vfs.dir.count[{#PATH},{$REG_INCL},{$REG_EXCL},{$TYPES_INCL},{$TYPES_EXCL},{$MAX_DEPTH},{$SIZE_MIN},{$SIZE_MAX},{$AGE_MIN},{$AGE_MAX},{$REG_EXCL_DIR}]
      On the host I can define all the macros.

      Most important macro is {$PATHS}. It can be populated with encoded paths (\\ instead of \) like C:\\Windows,C:\\temp
      Several paths can be separated with comma

      Have fun!

      Comment


      • Hamardaban
        Hamardaban commented
        Editing a comment
        I'm glad for you that everything worked out.
    Working...