2013-05-02 06:41:59 +08:00
|
|
|
<?php
|
|
|
|
class MonitorsController extends AppController {
|
|
|
|
|
|
|
|
public function index() {
|
2013-05-05 07:22:09 +08:00
|
|
|
$monitoroptions['fields'] = array('Name', 'Id', 'Function', 'Host');
|
|
|
|
$this->set('monitors', $this->Monitor->find('all', $monitoroptions));
|
2013-05-05 07:42:37 +08:00
|
|
|
$this->set('eventsLastHour', $this->Monitor->getEventsLastHour());
|
|
|
|
$this->set('eventsLastDay', $this->Monitor->getEventsLastDay());
|
|
|
|
$this->set('eventsLastWeek', $this->Monitor->getEventsLastWeek());
|
|
|
|
$this->set('eventsLastMonth', $this->Monitor->getEventsLastMonth());
|
2013-05-05 10:45:59 +08:00
|
|
|
$this->set('eventsArchived', $this->Monitor->getEventsArchived());
|
2013-05-02 06:41:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function view($id = null) {
|
|
|
|
if (!$id) {
|
|
|
|
throw new NotFoundException(__('Invalid monitor'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$monitor = $this->Monitor->findById($id);
|
|
|
|
if (!$monitor) {
|
|
|
|
throw new NotFoundException(__('Invalid monitor'));
|
|
|
|
}
|
|
|
|
$this->set('monitor', $monitor);
|
|
|
|
}
|
2013-05-02 09:03:25 +08:00
|
|
|
|
2013-05-03 09:31:05 +08:00
|
|
|
public function edit($id = null) {
|
|
|
|
if (!$id) {
|
|
|
|
throw new NotFoundException(__('Invalid monitor'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$monitor = $this->Monitor->findById($id);
|
|
|
|
if (!$monitor) {
|
|
|
|
throw new NotFoundException(__('Invalid monitor'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->request->is('put') || $this->request->is('post')) {
|
|
|
|
$this->Monitor->id = $id;
|
|
|
|
if ($this->Monitor->save($this->request->data)) {
|
|
|
|
$this->Session->setFlash('Your monitor has been updated.');
|
|
|
|
$this->redirect(array('action' => 'index'));
|
|
|
|
} else {
|
|
|
|
$this->Session->setFlash('Unable to update your monitor.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$this->request->data) {
|
|
|
|
$this->request->data = $monitor;
|
|
|
|
}
|
|
|
|
}
|
2013-05-02 09:03:25 +08:00
|
|
|
|
2013-05-02 06:41:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|