Ad Widget

Collapse

How can get current date to check file exist or not by zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bab
    Senior Member
    • Aug 2020
    • 176

    #1

    How can get current date to check file exist or not by zabbix

    I have a job on my server that can create dump files everyday with current date of day such as follow name in /home path
    dump-20230212.tar.gz
    It will create this dump file every day . Now I want to create an item that can check the file has created or not . in some forums they said at the first step we need to create a discovery rule type script that returns [{"{#DATE}":"YYMMDD"}] (with YYYY,MM,DD calculated in javascript from the current date) . Would you please help me how can do it ?

    I know first step we have to get current date and in the next step I think have to use vfs.dir.count
    Last edited by bab; 15-02-2023, 12:35.
  • Semiadmin
    Senior Member
    • Oct 2014
    • 1625

    #2
    Just use <max_age> prarmeter of vfs.dir.count

    Comment

    • bab
      Senior Member
      • Aug 2020
      • 176

      #3
      Originally posted by Semiadmin
      Just use <max_age> prarmeter of vfs.dir.count

      Thanks. But for example today 20230215 it generates dump-20200215.tar.gz and now it should checks dump-20200215.tar.gz exist or not
      for tmorrow 20230216 it should checks dump-20200215.tar.gz exist or not actually at the first step I want to get current date . If we can get current date with that method also we can use it for other things.

      Comment

      • Semiadmin
        Senior Member
        • Oct 2014
        • 1625

        #4
        You can check once a day, on a schedule, if there is a fresh file with a name that fits a regular expression. If the file is yesterday, it will not be counted due to age.

        Comment

        • bab
          Senior Member
          • Aug 2020
          • 176

          #5
          Originally posted by Semiadmin
          You can check once a day, on a schedule, if there is a fresh file with a name that fits a regular expression. If the file is yesterday, it will not be counted due to age.
          As my filename is like dump20230215.tar.gz in /home directory
          Does it correct :

          vfs.dir.count[/home,dump,,,,,1000000000,,,86400,]

          Comment

          • Semiadmin
            Senior Member
            • Oct 2014
            • 1625

            #6
            maybe vfs.dir.count[/home,"dump\d+\.tar\.gz",,,,,,,,1d]

            Comment

            • bab
              Senior Member
              • Aug 2020
              • 176

              #7
              Originally posted by Semiadmin
              maybe vfs.dir.count[/home,"dump\d+\.tar\.gz",,,,,,,,1d]

              Does \d in dump\d relates to 1d ?

              Comment

              • cyber
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Dec 2006
                • 4807

                #8
                Originally posted by bab


                Does \d in dump\d relates to 1d ?
                no \d in regex means "any digit" and + after that means "one or more of previous"... making it "dump followed by as many digits as there is"

                Comment

                Working...