Ad Widget

Collapse

Low Level Discovery to add file size monitors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DomWilko
    Junior Member
    • Jan 2014
    • 3

    #1

    Low Level Discovery to add file size monitors

    Hi,

    Is there any way to set up a discovery rule to add an item that monitors a file size, within a specific folder?

    I have already tested the file size monitor item (using vfs.file.size)and it is working like a charm. The trouble is, I have about 100 files that I need to monitor and it is a bit of a pain adding them all individually. The other thing is that we are adding a couple of new files a week and it would be good if they were automatically found and monitored.

    I tried using vfs.file.size[*], vfs.file.discovery[*] (* being the folder path), but I am getting a not supported status.

    I am guessing it will come down to a custom LLD rule? If so, I may need some help with that...

    Does anyone have some examples I could use? I am new to both Zabbix and JSON.

    Any help is appreciated.

    Useful stuff:
    Server: Zabbix 2.0.10
    OS: Ubuntu 12.04
    Files are in a folder on a Windows 2008 R2 Datacenter machine.
  • steveboyson
    Senior Member
    • Jul 2013
    • 582

    #2
    You definitely have to write a custom LLD script for that.

    Comment

    • DomWilko
      Junior Member
      • Jan 2014
      • 3

      #3
      Thanks for the confirmation.

      It was my initial guess so I have already written a Powershell script to output a list of the filenames in JSON format.

      Once I get it the whole thing working, I will post my scripts here for others to use.

      Comment

      • DomWilko
        Junior Member
        • Jan 2014
        • 3

        #4
        In case anyone else needs this:

        Powershell script to run on the monitored server (called FileSize.ps1):
        Code:
        WRITE-HOST "{"
        WRITE-HOST "`"data`":["
        Get-ChildItem <PathTofolder> |
        	ForEach-Object {
        		$n = $_ -replace('\\','/')
        		WRITE-HOST  "`{ `"`{`#FILENAME`}`":`"$n`",`},"} 
        WRITE-HOST "]"
        WRITE-HOST "}"
        User Parameter within zabbix_agentd.conf:
        Code:
        UserParameter=file.discovery,powershell -File "C:\Program Files\Zabbix Agent\FileSize.ps1"
        Zabbix Discovery Rule Setup:
        Key: file.discovery
        Filter Macro: {#FILENAME}

        Item Prototype:
        Name: {#FILENAME}
        Key: vfs.file.size[{~FILENAME}]

        Comment


        • abevern
          abevern commented
          Editing a comment
          This is GOLD! Thanks for posting this.
      • tchjts1
        Senior Member
        • May 2008
        • 1605

        #5
        DomWilko - How has this been working for you?
        I may have to implement something similar for a directory which contains about a dozen rotational logs.

        Regards -
        Jeff

        Comment

        Working...