fix #8131 - chinese translations
[Pman.Core] / Heartbeat.php
1 <?php
2
3 // check if database is workign - used by nagios checking - to see if server is really up.
4
5 require_once 'Pman.php';
6
7 class Pman_Core_Heartbeat extends Pman
8 {
9     function getAuth()
10     {
11         return true;
12     }
13     
14     function get($req, $opts = array())
15     {
16         $this->post($req);
17         die("POST only");
18     }
19     
20     function post($req)
21     {
22         $this->initErrorHandling();
23         
24         if ($this->database_is_locked()) {
25             die("FAILED");
26         }
27         
28         
29         $cd = DB_DataObject::Factory('core_enum');
30         $cd->setFrom(array(
31             'etype' => 'heartbeat',
32             'name' => 'last_update'
33         ));
34         if (!$cd->count()) {
35             $cd->display_name = date("Y-m-d H:i:s");
36             $cd->insert();
37             die("OK - HEARTBEAT WORKING");
38         }
39         $cd->find(true);
40         $cc = clone($cd);
41         if ( (time() - strtotime($cc->display_name)) < 30) {
42             die("OK - HEARTBEAT WORKING");
43         }
44         
45         $cd->display_name = date("Y-m-d H:i:s");
46         $cd->update($cc);
47         die("OK - HEARTBEAT WORKING");
48     }
49     
50      
51     function onPearError($err)
52     {
53       //  print_r($err);
54         die("FAILED");
55     }
56     function onException($err)
57     {
58       //  print_r($err);
59         die("FAILED");
60     }
61     
62    
63 }