Ad Widget

Collapse

Flexible Template for Monitoring multiple Files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel4711
    Senior Member
    • Jul 2014
    • 126

    #1

    Flexible Template for Monitoring multiple Files

    Hello everyone,

    Everyone knows it, it always happens that we have to monitor a file size on a system.
    This is not difficult in itself, you create a template with a macro and assign it to a system.
    However, it can happen that you have to monitor several files on a system.
    It would be good if this could be handled in the same way as with Windows services.
    One possibility is to call a discovery script with corresponding item prototypes.
    vfs.file.get can unfortunately only handle one file - which makes sense in principle.
    vfs.dir.get can unfortunately only check one folder - which basically makes sense.

    Does anyone have an idea of how to implement this with on-board resources or know a suitable template?

    If not, I would create a Powershell script here which can be "fed" with one or more file paths via a macro.

    Target would be to create a macro with the path names at host/template level.
    {$FILE.MONITORING} = "C:\sqlpath\file1.mdf", "c:\anotherpath\whatever.db"​
  • troffasky
    Senior Member
    • Jul 2008
    • 567

    #2
    It would be good if this could be handled in the same way as with Windows services.
    Services are well-defined and straightforward to discover. Is there anything that your files have in common that could be used in a discovery rule?

    Comment

    • Daniel4711
      Senior Member
      • Jul 2014
      • 126

      #3
      The services.discovery item offers the option of passing several values (separated by a pipe) as a macro.
      I am also looking for something like this for files.

      I would like to assign a template for the Windows servers.
      It should be possible to enter file paths conveniently in this template using a macro.

      It should not matter which file extension is present.
      I also only want to monitor the file size and monitor it via a trigger.

      Comment

      • PeterZielony
        Senior Member
        • Nov 2022
        • 146

        #4
        Are you trying to get db sizes for SQL?

        There is MSSQL template that reads db sizes

        Unless you want something else?

        Hiring in the UK? Drop a message

        Comment

        • Daniel4711
          Senior Member
          • Jul 2014
          • 126

          #5
          It happens from time to time that some file sizes need to be monitored.
          SQL file sizes are certainly also a use case.
          I am currently still looking for a simple SQL Express template (I don't need all the items of the big template).
          I want to keep the template very general and flexible.
          I haven't found anything yet and have started to create my own.
          Requirement: A Powershell file and a file with the files to be monitored.
          The discovery script then creates one item etc. per file.
          But it will take a few more days as I will be on vacation tomorrow.​

          Comment

          • markfree
            Senior Member
            • Apr 2019
            • 868

            #6
            I think you can figure this out without a script.
            Note that "vfs.dir.get" can traverse a directory. So the higher up you go in a filesystem tree, the broader you can traverse.
            Your scenario is interesting, and others may have similar requirements.

            So I've created a simple template that discovers multiple files in a directory.
            It is based on the "vfs.dir.get" item key, which returns the file sizes right away, and some macros to make it somewhat flexible.
            Of course, you will need to customize it for your scenario, and for files in different directories, you will need flexible regular expressions.


            Download at GitHub

            In my tests, I was able to find multiple files in a given directory.
            Click image for larger version  Name:	image.png Views:	46 Size:	33.5 KB ID:	486805

            Try it and see if it works for you.
            Last edited by markfree; 13-07-2024, 00:40. Reason: Updated template and included information

            Comment

            • Daniel4711
              Senior Member
              • Jul 2014
              • 126

              #7
              Hello and thank you for your reply.
              I will have a look at your template.

              Comment

              • Daniel4711
                Senior Member
                • Jul 2014
                • 126

                #8
                So... I happened to have a use case for your template yesterday.
                We have about 500 FSLogix vhdx files on a profile server.
                These are all on one partition and the users have a 3GB size limit within the vhdx file.
                I still need to clean this up and see if we can customize the names of the vhdx files.... for this scenario, your script is obviously better than my manual variant!

                I'm still using my variant because I find it a bit more flexible when it comes to files on different partitions.

                I have also registered with Github and will upload the template there.

                As soon as I understand Github

                Comment

                • Daniel4711
                  Senior Member
                  • Jul 2014
                  • 126

                  #9
                  So... it took a while... but I uploaded the template from Github.
                  GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

                  Comment


                  • markfree
                    markfree commented
                    Editing a comment
                    I'm glad it worked out for you. Cheers.
                Working...