]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - modules/role/manifests/cryptoportfolio/bot.pp
Merge branch 'dev'
[perso/Immae/Projets/Puppet.git] / modules / role / manifests / cryptoportfolio / bot.pp
index 2f01c98ab6735b59bdaa0267cadf6781c017b747..e4e3e6e350e598861f45e2107da58151caf4cc3a 100644 (file)
@@ -18,7 +18,7 @@ class role::cryptoportfolio::bot inherits role::cryptoportfolio {
 
   archive { "${home}/trader_${trader_version}.tar.gz":
     path          => "${home}/trader_${trader_version}.tar.gz",
-    source        => "https://git.immae.eu/releases/cryptoportfolio/trader/trader_${trader_version}.tar.gz",
+    source        => "https://release.immae.eu/cryptoportfolio/trader/trader_${trader_version}.tar.gz",
     checksum_type => "sha256",
     checksum      => $trader_sha256,
     cleanup       => false,
@@ -61,24 +61,25 @@ class role::cryptoportfolio::bot inherits role::cryptoportfolio {
       File[$cf_bot_app_conf],
       Archive["${home}/trader_${trader_version}.tar.gz"]
     ],
-    jobs        => [
-      {
-        command     => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --before",
-        user        => $user,
-        weekday     => 7, # Sunday
-        hour        => 22,
-        minute      => 30,
-        description => "Run before the cryptoportfolio update",
-      },
-      {
-        command     => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --after",
-        user        => $user,
-        weekday     => 1, # Monday
-        hour        => 0,
-        minute      => 0,
-        description => "Run after the cryptoportfolio update",
+    jobs        => [],
+  }
+
+  if ($environment == "production") {
+    $monitored_key = 3
+    @profile::monitoring::local_service { "Last redis report is less than 2 hours old":
+      local => {
+        check_command => "check_date!redis-cli -s $redis_host GET /cryptoportfolio/$monitored_key/latest/date!2"
       }
-    ],
+    }
+
+    @profile::monitoring::local_service { "Last bot report is less than one week old":
+      sudos => {
+        "naemon-cryptoportfolio-bot" => "naemon  ALL=($user) NOPASSWD: /usr/bin/find $cf_bot_app_reports -mindepth 1 -maxdepth 1 -printf %T@?n",
+      },
+      local => {
+        check_command => "check_last_file_date!$cf_bot_app_reports!168!$user",
+      },
+    }
   }
 
   if versioncmp($trader_version, "v1.3") >= 0 {