[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/tests/ -> test_services.php (source)

   1  <?php
   2  
   3  
   4     /**
   5     
   6     * Test les services qui tournent :onduleur, samba ... 
   7     * @Version $Id: test_services.php 4764 2009-11-08 17:31:37Z crob $ 
   8     * @Projet LCS / SambaEdu 
   9     * @auteurs Philippe Chadefaux  MrT
  10     * @Licence Distribue selon les termes de la licence GPL
  11     * @note
  12     * Modifications proposées par Sébastien Tack (MrT)
  13     * Optimisation du lancement des scripts bash par la technologie asynchrone Ajax.
  14   
  15     
  16     */
  17  
  18     /**
  19  
  20     * @Repertoire: /tests/
  21     * file: test_services.php
  22     */
  23  
  24  
  25  
  26  require_once ('entete_ajax.inc.php');
  27  
  28  
  29  //######################## CONTROLE LES SERVICES ##################################//
  30  // Controle le temps de la machine
  31  $la=date("G:i:s d/m/Y");
  32  // Controle si le fichier ssmtp a ete configure
  33  $ssmtp = exec("dpkg -l | grep ssmtp > /dev/null && echo 1");
  34  if ($ssmtp == "1") {
  35      if(file_exists("/etc/ssmtp/ssmtp.conf")) {
  36          $okmail ="1";
  37      } else {
  38          $okmail="0";
  39      }
  40  }
  41  // Test le serveur smb
  42    $domaine = exec('cat /etc/samba/smb.conf | grep workgroup | cut -d" " -f 3');
  43    $smb = exec("smbclient -L localhost -N | grep -i $domaine >/dev/null && echo 1");
  44    
  45     if ($smb == "1") {
  46        $oksmb="1";
  47    } else {
  48      $oksmb="0";
  49  }
  50   
  51    
  52  // Test le sid samba et la presence d'un eventuel doublon de sid
  53    $testsid = exec('sudo /usr/share/se3/scripts/testSID.sh');
  54    
  55     if ($testsid == "") {
  56        $oksid="1";
  57    } else {
  58       $oksid="0";
  59    }
  60  
  61  // Test la base MySQL
  62    $mysql = exec('sudo /usr/share/se3/sbin/testMySQL.sh',$out,$err);
  63   
  64    if ($err == "0") {
  65        $okmysql="1";
  66    } else {
  67        $okmysql="0";
  68    }
  69  
  70  // Controle si le dhcp tourne si celui-ci a ete installe
  71  $dhcp_install = exec("dpkg -l | grep dhcp3 > /dev/null && echo 1");
  72  
  73  if (($dhcp_install == "1") && ($dhcp =="1")) {
  74      
  75        $dhcp_state=exec("sudo /usr/share/se3/scripts/makedhcpdconf state");
  76      if($dhcp_state==1) {
  77          $okdhcp="1";
  78      } else {
  79          $okdhcp="0";
  80      }
  81  }
  82  else {
  83      $okdhcp = "-1";
  84  }
  85  
  86  // Test la presence d'un onduleur
  87    $ups = exec("upsc myups@localhost");
  88    $ups_charge = exec("upsc myups@localhost battery.charge");
  89   
  90    if ($ups_charge != "") {
  91        $ups_mfr = exec("upsc myups@localhost ups.mfr");
  92      $ups_model = exec("upsc myups@localhost ups.model");
  93      //echo " <I> ( $ups_mfr $ups_model )</I>";
  94    }
  95    
  96    if ($ups_charge != "") {  
  97          $okondul="1";
  98         
  99    } else {
 100            $okondul="0";
 101  
 102    }
 103  
 104  die("var arr_services=new Array('$okmail','$oksmb','$oksid','$okmysql','$okdhcp','$okondul');");
 105  
 106  
 107  ?>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1