Commit 1bd736ddde793d4c89d44c1c53fd8f3fe43da86a
1 parent
a1227fb6
Exists in
master
and in
9 other branches
add cleanRemote
Showing
4 changed files
with
101 additions
and
0 deletions
Show diff stats
CMakeLists.txt
... | ... | @@ -77,6 +77,7 @@ install(FILES "scripts/AddLocalVI.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER |
77 | 77 | install(FILES "scripts/UpdateInfoVI.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
78 | 78 | install(FILES "scripts/RemoveVI.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
79 | 79 | install(FILES "scripts/MakeRemoteProxy.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
80 | +install(FILES "scripts/CleanRemote.sh" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) | |
80 | 81 | |
81 | 82 | install(DIRECTORY "src/CALLEXT/" DESTINATION bin/CALLEXT) |
82 | 83 | install(DIRECTORY "src/DATA/MANAGER/" DESTINATION bin/DATAMANAGER) |
... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | +* @file CleanRemote.php | |
5 | +* @brief DD Server Tools: | |
6 | +*/ | |
7 | + if (!function_exists('__autoload')) | |
8 | + { | |
9 | + function __autoload($class_name) { | |
10 | + require_once $class_name . '.php'; | |
11 | + } | |
12 | + } | |
13 | + | |
14 | + putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH")); | |
15 | + putenv("PATH=./:".getenv("DDBASEBIN").":/bin:/usr/bin"); | |
16 | + set_include_path("./:".getenv("DATAMANAGER")); | |
17 | + | |
18 | + $baseMgr = new DDBaseMgr(); | |
19 | + $baseMgr->cleanRemote(); | |
20 | + | |
21 | +?> | |
... | ... |
src/DATA/MANAGER/DDBaseMgr.php
... | ... | @@ -290,6 +290,75 @@ class DDBaseMgr |
290 | 290 | system("infoLocal2nc ".$this->info_xml." ".$this->info); |
291 | 291 | chdir($currDir); |
292 | 292 | } |
293 | + | |
294 | + public function cleanRemote($opt = NULL) | |
295 | + { | |
296 | + $res_before = disk_free_space(getenv("DDBASE")); | |
297 | + $Days = 10; // default | |
298 | + $SecDay = 3600*24; | |
299 | + $nodata = false; | |
300 | + | |
301 | + if (isset($opt)) { | |
302 | + if ($opt == "NODATA") | |
303 | + $nodata = true; | |
304 | + else { | |
305 | + $Days = is_numeric($opt) ? $opt : 10; | |
306 | + settype($Days, "int"); | |
307 | + echo "!!!!!!!!!!!!!!!! Days ".$Days.PHP_EOL; | |
308 | + } | |
309 | + } | |
310 | + | |
311 | + $GlobalDelta = $Days*$SecDay; | |
312 | + | |
313 | + $xp = new domxpath($this->DDsysDoc); | |
314 | + $dataSets = $xp->query("//NAME[attribute::base!='LOCAL']"); | |
315 | + | |
316 | + for ($i = 0; $i < $dataSets->length; $i++) | |
317 | + { | |
318 | + $parent = $dataSets->item($i)->parentNode; | |
319 | + $location = $parent->getElementsByTagName("LOCATION")->item(0)->nodeValue; | |
320 | + | |
321 | + if (!is_dir($location)) { | |
322 | + $parent->parentNode->removeChild($parent); | |
323 | + } | |
324 | + else { | |
325 | + $time_info = $parent->getElementsByTagName("TIMES")->item(0)->nodeValue; | |
326 | + chdir($location); | |
327 | + system("./clean"); | |
328 | + touch($location."/LOCK"); | |
329 | + | |
330 | + fprintf(STDERR,"In the ".$location."\n"); | |
331 | + | |
332 | + /* Delete No Data Intervals */ | |
333 | + if ($nodata) { | |
334 | + system("CleanNoData ".$time_info); | |
335 | + } | |
336 | + /* Delete Old Files */ | |
337 | + else { | |
338 | + foreach (glob("*.gz") as $filename) { | |
339 | + $info = stat($filename); | |
340 | + if ((time() - $info['atime']) > $GlobalDelta) { | |
341 | + //fprintf(STDERR, $filename."\n"); | |
342 | + system("TimesUpdate -d ".$time_info." ".$filename); | |
343 | + } | |
344 | + //fprintf(STDERR, date("Y-m-d",$info['atime'])." - ".date("Y-m-d",$info['mtime'])."\n"); | |
345 | + } | |
346 | + } | |
347 | + | |
348 | + system("DDClearTimes ".$time_info); | |
349 | + unlink($location."/LOCK"); | |
350 | + } | |
351 | + } | |
352 | + /* | |
353 | + $res_after = disk_free_space(getenv("DDBASE")); | |
354 | + $difference = ($res_after - $res_before)/1024.0; | |
355 | + $res_after /= 1024.0; | |
356 | + fprintf(STDERR,"+ Free Space ".$difference." kB\n"); | |
357 | + fprintf(STDERR," Free Space ".$res_after." kB\n");*/ | |
358 | + | |
359 | + $this->DDsysDoc->save($this->DDsys); | |
360 | + system("makeDDsys"); | |
361 | + } | |
293 | 362 | } |
294 | 363 | ?> |
295 | 364 | |
... | ... |