Ver código fonte

display local fillevel

Markus Spring 1 ano atrás
pai
commit
7f974a0716
2 arquivos alterados com 22 adições e 15 exclusões
  1. 2 1
      app/templates/table.html
  2. 20 14
      helpers/update_backup_copy_stats.py

+ 2 - 1
app/templates/table.html

@@ -37,7 +37,7 @@
           </th>
           <th class="{{ lastbackup.last_backup_color }}">
             <span title="{{ lastbackup.last_localfilllevel }} free ({{ gigabytes(lastbackup.last_localfreebytes) }}">
-              Letzte Backup-Kopie:&nbsp;&nbsp;{{ lastbackup.last_backup_copy }}
+              Letzte Backup-Kopie:&nbsp;&nbsp;{{ lastbackup.last_backup_copy }} {{ lastbackup.last_localfilllevel }}
             </span>
           </th>
           <th class="{{ lastbackup.next_backup_color }}">
@@ -78,6 +78,7 @@
         {% endfor %}
       </tbody>
     </table>
+    <p style="align: right">git-version: {{COMMIT_HASH}}</p>
   </div>
 <!--    <script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
     <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

+ 20 - 14
helpers/update_backup_copy_stats.py

@@ -30,7 +30,7 @@ müssen für springm beschreibbar sein
 remotehost      = 'hermes'
 ssh_username    = 'root'
 remoterepo      = '/backupdisk/backupdisk/restic-repo'
-json_remotefile = '/var/lib/restic/backupcopies.json'
+#json_remotefile = '/var/lib/restic/backupcopies.json'
 json_localfile  = '/tmp/backupcopies.json'
 
 # UUID ermitteln mit blkid 
@@ -54,22 +54,27 @@ jso = {}
 
 def load_jsonfile( ):
     try:
-        with SCPClient(ssh.get_transport()) as scp:
-            scp.get(json_remotefile, local_path=json_localfile)
         with open(json_localfile, 'r') as openfile:
             jso = json.load(openfile)
     except:
-        print(f"Warning: could not get {json_remotefile} from {remotehost}")
+        print(f"Warning: could not open {json_localfile}. Exiting.")
+        sys.exit(1)
+    # try:
+    #     with SCPClient(ssh.get_transport()) as scp:
+    #         scp.get(json_remotefile, local_path=json_localfile)
+    #     with open(json_localfile, 'r') as openfile:
+    #         jso = json.load(openfile)
+    # except:
+    #     print(f"Warning: could not get {json_remotefile} from {remotehost}")
 
 def disc_free ( mountpoint, host ):
-    if host != False:
-#        cmd = [ 'ssh', host, 'bash', '-c', f"df | grep {mountpoint} | cut -b 57-68,70-72" ]
+    if host != False:           # remote host
         cmd = [ 'ssh', host, 'bash', '-c', f"df | grep {mountpoint} | cut -b 52-61,64-68" ]
         s = subprocess.check_output( cmd ).decode('utf-8').strip().split(' ')
-        print("-".join(s))
-    else:
-        cmd = [ 'bash', '-c', f"df | grep {mountpoint} | cut -b 51-61,64-66" ]
+    else:                       # local host
+        cmd = [ 'bash', '-c', f"df | grep {mountpoint} | cut -b 57-66,69-72" ]
         s = subprocess.check_output( cmd ).decode('utf-8').strip().split(' ')
+        print("#".join(s))
     return( { 'fill_level' : s[1], 'bytes_free' : s[0] } )
 
 def disc_blkid ( mapperdev, host ):
@@ -103,6 +108,7 @@ def update_json ():
     jso[now][blkid] = {}
     jso[now][blkid]['bytes_free'] = disc_free(args.localrepobasedir, False)['bytes_free'] 
     jso[now][blkid]['fill_level'] = disc_free(args.localrepobasedir, False)['fill_level']
+    print(jso[now][blkid]['fill_level'])
     jso[now][blkid]['color'] = snapcolors[blkid]
 
     jso['__summary'] = { 'last_backup_copy'       : now,
@@ -117,11 +123,11 @@ def update_json ():
 def write_json():
     with open(json_localfile, 'w', encoding='utf-8') as f:
         json.dump(jso, f, ensure_ascii=False, indent=4)
-    try:
-        with SCPClient(ssh.get_transport()) as scp:
-            scp.put(json_localfile, json_remotefile)
-    except:
-        print(f"Error: could not copy {json_localfile} to {remotehost}:{json_remotefile}")
+    # try:
+    #     with SCPClient(ssh.get_transport()) as scp:
+    #         scp.put(json_localfile, json_remotefile)
+    # except:
+    #     print(f"Error: could not copy {json_localfile} to {remotehost}:{json_remotefile}")
 
 def rewrite_snapshots_json(host):
     cmd = [ 'ssh', f"""{ssh_username}@{host}""", 'bash', '-c', "/usr/local/sbin/restic_json.sh" ]