Subversion Repositories computer_asset_manager_v1

Rev

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

Rev 25 Rev 28
Line 11... Line 11...
11
 * truncate table backups_run
11
 * truncate table backups_run
12
 * 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;
13
 * 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;
14
 * alter table backups_run add added_date datetime not null;
15
 * 
15
 * 
-
 
16
 * Version 0.1.1 20160713 RWR
-
 
17
 * Fixed issue where report had no transfers. In that case, header lines
-
 
18
 * are terminated by two blank lines, not the constant 'sending incremental file
-
 
19
 * list'. Simply modified to terminate on an empty line OR the constant
-
 
20
 * 
-
 
21
 * Also set it up to only report on one file at a time, ie accept
-
 
22
 * only one parameter, and that is assumed to be a file name
16
*/
23
*/
17
 
24
 
18
   /*
25
   /*
19
    * This will return error codes
26
    * This will return error codes
20
    * 1 - Invalid Data File Name
27
    * 1 - Invalid Data File Name
Line 34... Line 41...
34
                     'server_name' => '',
41
                     'server_name' => '',
35
                     'report_date' => '',
42
                     'report_date' => '',
36
                     'start_time' => '',
43
                     'start_time' => '',
37
                     'version' => '',
44
                     'version' => '',
38
                     'end_time' => '',
45
                     'end_time' => '',
39
                     'files_count' => '',
46
                     'files_count' => 0,
40
                     'files_size' => '',
47
                     'files_size' => 0,
41
                     'transferred_count' => 0,
48
                     'transferred_count' => 0,
42
                     'transferred_size' => '',
49
                     'transferred_size' => 0,
43
                     'files_deleted' => 0,
50
                     'files_deleted' => 0,
44
                     'skipped' => 0,
51
                     'skipped' => 0,
45
                     'data_sent' => '',
52
                     'data_sent' => 0,
46
                     'data_received' => '',
53
                     'data_received' => 0,
47
                     'disk_used' => '',
54
                     'disk_used' => '',
48
                     'notes' => '',
55
                     'notes' => '',
49
   );
56
   );
50
 
57
 
51
 
58
 
Line 65... Line 72...
65
      return $data;
72
      return $data;
66
   }
73
   }
67
 
74
 
68
   $log = fopen ( $path . '/' . $filename , 'rb' );
75
   $log = fopen ( $path . '/' . $filename , 'rb' );
69
   if ( $log ) {
76
   if ( $log ) {
70
      // get through the header lines
77
      // get through the header lines, ended by either a blank line
-
 
78
      // or the constant 'sending incremental file list'
71
      while (( $line = fgets( $log, $maxLineLength )) !== false ) {
79
      while (( $line = fgets( $log, $maxLineLength )) !== false ) {
-
 
80
         $line = rtrim( $line );
-
 
81
         if ( $line ) {
72
         if ( preg_match( '/^backup\s+v?([\d.]+)$/', $line, $matches ) ) {
82
            if ( preg_match( '/^backup\s+v?([\d.]+)$/', $line, $matches ) ) {
73
            $data['version'] = $matches[1];
83
               $data['version'] = $matches[1];
74
         }
84
            }
75
         // this line is the end of the header lines
85
            // this line is the end of the header lines
76
         if ( preg_match( '/sending incremental file list/', $line, $matches ) ) {
86
            if ( preg_match( '/sending incremental file list/', $line, $matches ) ) {
-
 
87
               break;
-
 
88
            }
-
 
89
         } else {
77
            break;
90
            break;
78
         }
91
         }
79
      }
92
      }
80
      
93
      
81
      // count line by line processing information. These are the actual lines
94
      // count line by line processing information. These are the actual lines
Line 233... Line 246...
233
mysql_connect( $configuration['database']['databaseServer'], $configuration['database']['databaseUsername'], $configuration['database']['databasePassword'] ) or die(mysql_error());
246
mysql_connect( $configuration['database']['databaseServer'], $configuration['database']['databaseUsername'], $configuration['database']['databasePassword'] ) or die(mysql_error());
234
mysql_select_db( $configuration['database']['database'] ) or die(mysql_error());
247
mysql_select_db( $configuration['database']['database'] ) or die(mysql_error());
235
 
248
 
236
 
249
 
237
 
250
 
238
for ( $i = 1 ; $i < count( $argv ); $i++ ) {
-
 
239
   $filename = $argv[$i];
251
$filename = $argv[1];
240
   $report = parseFile( $filename, $configuration['datapath'] . '/' . $configuration['unprocessed_path'] );
252
$report = parseFile( $filename, $configuration['datapath'] . '/' . $configuration['unprocessed_path'] );
-
 
253
// print_r( $report ); print "\n";
-
 
254
 
241
   if ( isset( $report['error'] ) ) { // we had an error processing the report
255
if ( isset( $report['error'] ) ) { // we had an error processing the report
242
      $result[] = "$filename\t" . $report['error']; 
256
   $result[] = "$filename\t" . $report['error']; 
243
   } else {
257
} else {
244
      $result[] = recordReport( $report );
258
   $result[] = recordReport( $report );
245
   }
-
 
246
}
259
}
247
 
260
 
248
print implode( "\n", $result );
261
print implode( "\n", $result );
249
 
262
 
250
?>
263
?>