Subversion Repositories computer_asset_manager_v1

Rev

Rev 24 | Rev 28 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24 Rev 25
Line 6... Line 6...
6
 * apt-get install php-pear php5-dev libyaml-dev libyaml-0-2 libyaml-0-2-dbg
6
 * apt-get install php-pear php5-dev libyaml-dev libyaml-0-2 libyaml-0-2-dbg
7
 * pecl install yaml
7
 * pecl install yaml
8
 * echo 'extension=yaml.so' >> /etc/php5/cli/php.ini
8
 * echo 'extension=yaml.so' >> /etc/php5/cli/php.ini
9
 * echo 'extension=yaml.so' >> /etc/apache2/cli/php.ini
9
 * echo 'extension=yaml.so' >> /etc/apache2/cli/php.ini
10
 * 
10
 * 
-
 
11
 * truncate table backups_run
11
 * alter table backups_run add skipped bigint(20),add file_name varchar(60),add notes text;
12
 * alter table backups_run add skipped bigint(20),add file_name varchar(60),add notes text;
12
 * alter table backups_run modify end_time  datetime null, modify start_time datetime null;
13
 * alter table backups_run modify end_time  datetime null, modify start_time datetime null;
-
 
14
 * alter table backups_run add added_date datetime not null;
13
 * 
15
 * 
14
*/
16
*/
15
 
17
 
-
 
18
   /*
-
 
19
    * This will return error codes
-
 
20
    * 1 - Invalid Data File Name
-
 
21
    * 2 - Could not open the file
-
 
22
    * 3 - Duplicate Report
-
 
23
    * 4 - Server Not Found
-
 
24
    */
-
 
25
 
-
 
26
 
16
require 'library.php';
27
require 'library.php';
17
$VERSION='0.1.0';
28
$VERSION='0.1.0';
18
 
29
 
19
$results = array();
30
$results = array();
20
 
31
 
Line 35... Line 46...
35
                     'data_received' => '',
46
                     'data_received' => '',
36
                     'disk_used' => '',
47
                     'disk_used' => '',
37
                     'notes' => '',
48
                     'notes' => '',
38
   );
49
   );
39
 
50
 
40
   /*
-
 
41
    * This will return error codes
-
 
42
    * 1 - Invalid Data File Name
-
 
43
    * 2 - Could not open the file
-
 
44
    */
-
 
45
 
51
 
46
   $matches = array();
52
   $matches = array();
47
 
53
 
48
   $line;
54
   $line;
49
 
55
 
50
   $data['file_name'] = $filename;
56
   $data['file_name'] = $filename;
51
   # get server name from the file name, which should be
57
   # get server name from the file name, which should be
52
   # datetime_servername.backup.log
58
   # datetime_servername.backup.log
53
   if ( preg_match( '/(\d+)_([a-z0-9-.]+)\.backup\.log/', $filename, $matches ) ) {
59
   if ( preg_match( '/(\d+)_([a-z0-9_.-]+)\.backup\.log/', $filename, $matches ) ) {
54
      $data['report_date'] = $matches[1];
60
      $data['report_date'] = $matches[1];
55
      $data['server_name'] = $matches[2];
61
      $data['server_name'] = $matches[2];
56
   } else {
62
   } else {
57
      # ensure only three parts returned
63
      # ensure only three parts returned
58
      $data['error'] = "1\tInvalid Data File Name";
64
      $data['error'] = "1\tInvalid Data File Name";
Line 196... Line 202...
196
      } else {
202
      } else {
197
         $keys[] = $keyfield;
203
         $keys[] = $keyfield;
198
         $values[] = makeSafeSQLValue( $value );
204
         $values[] = makeSafeSQLValue( $value );
199
      }
205
      }
200
   }
206
   }
-
 
207
   $keys[] = 'added_date'; $values[] = 'now()';
201
   $sql = 'insert into backups_run (' . implode( ',', $keys ) . ') values (' . implode( ',', $values ) . ')';
208
   $sql = 'insert into backups_run (' . implode( ',', $keys ) . ') values (' . implode( ',', $values ) . ')';
202
   // if we made it this far, we are ok, so just add the report id
209
   // if we made it this far, we are ok, so just add the report id
203
   $result = queryDatabaseExtended( $sql );
210
   $result = queryDatabaseExtended( $sql );
204
   return $report['file_name'] . "\t0\tok";
211
   return $report['file_name'] . "\t0\tok";
205
} // recordReport
212
} // recordReport
Line 230... Line 237...
230
 
237
 
231
for ( $i = 1 ; $i < count( $argv ); $i++ ) {
238
for ( $i = 1 ; $i < count( $argv ); $i++ ) {
232
   $filename = $argv[$i];
239
   $filename = $argv[$i];
233
   $report = parseFile( $filename, $configuration['datapath'] . '/' . $configuration['unprocessed_path'] );
240
   $report = parseFile( $filename, $configuration['datapath'] . '/' . $configuration['unprocessed_path'] );
234
   if ( isset( $report['error'] ) ) { // we had an error processing the report
241
   if ( isset( $report['error'] ) ) { // we had an error processing the report
235
      $result[] = "$filename\t" . $report['error'];
242
      $result[] = "$filename\t" . $report['error']; 
236
   } else {
243
   } else {
237
      $result[] = recordReport( $report );
244
      $result[] = recordReport( $report );
238
   }
245
   }
239
}
246
}
240
 
247