tuto:ipasserelle:divers:scripts_dokuwiki

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
Prochaine révision Les deux révisions suivantes
tuto:ipasserelle:divers:scripts_dokuwiki [06/06/2017 19:09]
dani
tuto:ipasserelle:divers:scripts_dokuwiki [25/01/2019 16:30]
heuzef
Ligne 16: Ligne 16:
  
 my $main_dom = $c->get('DomainName')->value; my $main_dom = $c->get('DomainName')->value;
 +
 +my @fws_accounts = qw(
 +  fws
 +  maillog
 +  backup
 +  mails-partages
 +  scanner
 +  deploiement
 +  auth
 +);
  
 print '^ Identifiant ^ Nom ^ Prénom ^ Adresse email principale ^' . "\n"; print '^ Identifiant ^ Nom ^ Prénom ^ Adresse email principale ^' . "\n";
  
-print '|' . $_->key . ' |' . $_->prop('LastName') .+foreach ($a->users){ 
 +  my $name = $_->key; 
 +  if (grep { $name eq $_ } @fws_accounts){ 
 +    $name = '<color blue>' . $_->key . '</color>'; 
 +  } elsif (($_->prop('PasswordSet') |'no') ne 'yes'){ 
 +    $name = '<color red>' . $_->key . '</color>'; 
 +  } 
 +  print '|' . $name . ' |' . $_->prop('LastName') .
      ' |' . $_->prop('FirstName') . ' |' . ($_->prop('PreferredMail') || $_->key . '@' . $main_dom) .      ' |' . $_->prop('FirstName') . ' |' . ($_->prop('PreferredMail') || $_->key . '@' . $main_dom) .
-      "|\n" +      "|\n"; 
-  foreach ($a->users);+}
 </file> </file>
  
Ligne 195: Ligne 212:
 } }
 </file> </file>
 +
 +  * Rapports de sauvegardes BackupPC
 +
 +<file perl backups.pl>
 +#!/usr/bin/perl
 +
 +use lib "/usr/share/BackupPC/lib";
 +use BackupPC::Lib;
 +use BackupPC::CGI::Lib;
 +use POSIX;
 +use List::Util qw(min);
 +use Data::Dumper;
 +
 +# We need to switch to backuppc UID/GID
 +my $uid = getuid();
 +my $gid = getgid();
 +my (undef,undef,$bkpuid,$bkpgid) = getpwnam('backuppc');
 +setuid($bkpuid) if ($uid ne $bkpuid);
 +setgid($bkpgid) if ($gid ne $bkpgid);
 +
 +my $bpc = BackupPC::Lib->new();
 +my $hosts = $bpc->HostInfoRead();
 +my $mainConf = $bpc->ConfigDataRead();
 +
 +print '^ Jeux de sauvegarde ^ Description ^ Fréquence (jours) ^ volume complète (Go) ^ Volume incrémental (Go) ^ Durée moyenne (minutes) ^' . "\n";
 +
 +foreach my $host (sort keys %$hosts){
 +  my $hostConf = $bpc->ConfigDataRead($host);
 +  my $conf = { %$mainConf, %$hostConf };
 +  my @backups = $bpc->BackupInfoRead($host);
 +  my ($nb_bkp,$nb_full,$nb_incr,$size_full,$size_incr,$duration) = 0;
 +
 +  foreach my $backup (@backups){
 +    $nb_bkp += 1;
 +    $duration += $backup->{endTime} - $backup->{startTime};
 +    if ($backup->{type} eq 'full'){
 +      $nb_full += 1;
 +      $size_full = $backup->{size};
 +    } else {
 +      $nb_incr += 1;
 +    }
 +    # The size of new files can be computed for full or incr
 +    $size_incr += $backup->{sizeNew};
 +  }
 +
 +  if ($nb_bkp > 0){
 +    $duration = sprintf('%.0f', ($duration / 60) / $nb_bkp);
 +    $size_incr = sprintf('%.3f', ($size_incr / (1024 * 1024 * 1024)) / $nb_bkp);
 +  }
 +  $size_full = sprintf('%.3f', $size_full / (1024 * 1024 * 1024));
 +  my $freq = ($conf->{BackupsDisable} == 0 ) ? ceil(min(($conf->{IncrPeriod}, $conf->{FullPeriod}))) : 'N/A';
 +
 +  print "|$host | | $freq | $size_full | $size_incr | $duration |\n";
 +}
 +</file>
 +
 +
 +----
 +
 +Exporter le résultats de tous les scripts : ''for i in *.pl;do perl $i > ${i%}txt;done''
  • tuto/ipasserelle/divers/scripts_dokuwiki.txt
  • Dernière modification: 17/06/2020 14:53
  • de heuzef