public function index() { if (!$this->isAuthorizedFor('pages')) { throw new Kohana_Exception('error.auth-pages'); } $this->page = pnp::clean($this->input->get('page')); if ($this->page == "") { $this->page = $this->data->getFirstPage(); } if ($this->page == "") { throw new Kohana_Exception('error.page-config-dir', $this->config->conf['page_dir']); } if ($this->view == "") { $this->view = $this->config->conf['overview-range']; } $this->data->buildPageStruct($this->page, $this->view); $this->template->page->header->title = Kohana::lang('common.page', $this->data->PAGE_DEF['page_name']); $this->url = "?page&page={$this->page}"; // Timerange Box Vars $this->template->page->timerange_box = $this->add_view('timerange_box'); $this->template->page->timerange_box->timeranges = $this->data->TIMERANGE; // Pages Box $this->pages = $this->data->getPages(); $this->template->page->pages_box = $this->add_view('pages_box'); $this->template->page->pages_box->pages = $this->pages; // Basket Box $this->template->page->basket_box = $this->add_view('basket_box'); // Icon Box $this->template->page->icon_box = $this->add_view('icon_box'); $this->template->page->icon_box->position = "page"; }
public function index() { $start = $this->input->get('start'); $end = $this->input->get('end'); $source = $this->input->get('source'); $view = ""; if (isset($_GET['view']) && $_GET['view'] != "") { $view = pnp::clean($_GET['view']); } else { $view = $this->config->conf['overview-range']; } if (isset($this->config->conf['popup-width']) && $this->config->conf['popup-width'] != "") { $this->imgwidth = $this->config->conf['popup-width']; } else { $this->imgwidth = FALSE; } $this->data->getTimeRange($start, $end, $view); if (isset($this->host) && isset($this->service)) { $this->data->buildDataStruct($this->host, $this->service, $view); $this->template->host = $this->host; $this->template->srv = $this->service; $this->template->view = $view; $this->template->source = $source; $this->template->end = $end; $this->template->start = $start; $this->template->imgwidth = $this->imgwidth; } else { url::redirect("/graph"); } }
public function __construct() { parent::__construct(); $this->data = new Data_Model(); $this->config = new Config_Model(); $this->rrdtool = new Rrdtool_Model(); $this->config->read_config(); Kohana::config_set('locale.language', $this->config->conf['lang']); Kohana::config_set('core.site_domain', $this->config->conf['base_url']); // Check for mod_rewrite $this->check_mod_rewrite(); $this->start = $this->input->get('start', FALSE); $this->end = $this->input->get('end', FALSE); $this->theme = $this->input->get('theme', FALSE); $this->view = ""; $this->controller = Router::$controller; if (isset($_GET['view']) && $_GET['view'] != "") { $this->view = pnp::clean($_GET['view']); } $this->data->getTimeRange($this->start, $this->end, $this->view); if (Router::$controller != "image" && Router::$controller != "image_special") { $this->session = Session::instance(); if ($this->theme) { $this->session->set('theme', $this->theme); } # New session if ($this->session->get("theme", "new") == "new") { $this->theme = $this->config->conf['ui-theme']; $this->session->set("theme", $this->theme); } else { $this->theme = $this->session->get('theme'); } if ($this->start && $this->end) { if ($this->session->get('timerange-reset', 0) == 0) { $this->session->set("start", $this->start); $this->session->set("end", $this->end); } else { $this->session->set('timerange-reset', 0); } } if ($this->start && !$this->end) { if ($this->session->get('timerange-reset', 0) == 0) { $this->session->set("start", $this->start); $this->session->set("end", ""); } else { $this->session->set('timerange-reset', 0); } } if ($this->end && !$this->start) { if ($this->session->get('timerange-reset', 0) == 0) { $this->session->set("end", $this->end); $this->session->set("start", ""); } else { $this->session->set('timerange-reset', 0); } } } $this->template = $this->add_view('template'); }
public function index() { // Disable auto-rendering $this->auto_render = FALSE; if ($this->view == "") { $this->view = $this->config->conf['overview-range']; } // Service Details if ($this->host != "" && $this->service != "") { $this->service = pnp::clean($this->service); $this->host = pnp::clean($this->host); $services = $this->data->getServices($this->host); $this->data->buildDataStruct($this->host, $this->service, $this->view); $i = 0; $json = array(); foreach ($this->data->STRUCT as $struct) { $json[$i]['image_url'] = "host=" . $struct['MACRO']['HOSTNAME'] . "&srv=" . $struct['MACRO']['SERVICEDESC'] . "&source=" . $struct['SOURCE'] . "&view=" . $struct['VIEW']; $json[$i]['ds_name'] = $struct['ds_name']; $json[$i]['start'] = $struct['TIMERANGE']['start']; $json[$i]['end'] = $struct['TIMERANGE']['end']; $json[$i]['title'] = $struct['TIMERANGE']['title']; $i++; } print json_encode($json); // Host Overview } elseif ($this->host != "") { $this->host = pnp::clean($this->host); $services = $this->data->getServices($this->host); foreach ($services as $service) { if ($service['state'] == 'active') { $this->data->buildDataStruct($this->host, $service['name'], $this->view); } } $i = 0; $json = array(); foreach ($this->data->STRUCT as $struct) { $json[$i]['image_url'] = "host=" . $struct['MACRO']['HOSTNAME'] . "&srv=" . $struct['MACRO']['SERVICEDESC'] . "&source=" . $struct['SOURCE'] . "&view=" . $struct['VIEW']; $json[$i]['servicedesc'] = $struct['MACRO']['SERVICEDESC']; $json[$i]['ds_name'] = $struct['ds_name']; $json[$i]['start'] = $struct['TIMERANGE']['start']; $json[$i]['end'] = $struct['TIMERANGE']['end']; $json[$i]['title'] = $struct['TIMERANGE']['title']; $i++; } print json_encode($json); } else { $this->hosts = $this->data->getHosts(); $i = 0; $json = array(); foreach ($this->hosts as $host) { if ($host['state'] == "active") { $json[$i]['hostname'] = $host['name']; $i++; } } print json_encode($json); } }
public function index() { $this->source = $this->input->get('source'); $this->view = ""; if (isset($_GET['view']) && $_GET['view'] != "") { $this->view = pnp::clean($_GET['view']); } else { $this->view = $this->config->conf['overview-range']; } # # Limit startto 2000/01/01 # $start_limit = strtotime("2000/01/01"); $this->start = abs((int) $this->start); if ($this->start < $start_limit) { $this->start = $start_limit; } # # Limit end to now + one hour # $end_limit = time() + 3600; $this->end = abs((int) $this->end); if ($this->end > $end_limit) { $this->end = $end_limit; } $this->data->getTimeRange($this->start, $this->end, $this->view); if (isset($this->tpl) && $this->tpl != 'undefined') { if ($this->start && $this->end) { $this->session->set("start", $this->start); $this->session->set("end", $this->end); } $this->template->tpl = $this->tpl; $this->template->view = $this->view; $this->template->source = $this->source; $this->template->end = $this->end; $this->template->start = $this->start; $this->url = "?tpl=" . $this->tpl; $this->template->graph_height = $this->graph_height; $this->template->graph_width = $this->graph_width; } elseif (isset($this->host) && isset($this->service)) { if ($this->start && $this->end) { $this->session->set("start", $this->start); $this->session->set("end", $this->end); } $this->template->host = $this->host; $this->template->srv = $this->service; $this->template->view = $this->view; $this->template->source = $this->source; $this->template->end = $this->end; $this->template->start = $this->start; $this->url = "?host=" . $this->host . "&srv=" . $this->service; $this->template->graph_height = $this->graph_height; $this->template->graph_width = $this->graph_width; } else { url::redirect("/graph"); } }
public function index() { $this->view = ""; if (isset($_GET['view']) && $_GET['view'] != "") { $this->view = pnp::clean($_GET['view']); } $this->data->getTimeRange($this->start, $this->end, $this->view); if (isset($this->host) && isset($this->service)) { $this->service = pnp::clean($this->service); $this->host = pnp::clean($this->host); $this->url = "?host=" . $this->host . "&srv=" . $this->service; if ($this->start) { $this->url .= "&start=" . $this->start; $this->session->set("start", $this->start); } if ($this->end) { $this->url .= "&end=" . $this->end; $this->session->set("end", $this->end); } $services = $this->data->getServices($this->host); $this->data->buildDataStruct($this->host, $this->service, $this->view); $this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']); $this->title = "Service Details " . $this->host . " -> " . $this->data->MACRO['DISP_SERVICEDESC']; } elseif (isset($this->host)) { $this->host = pnp::clean($this->host); $this->is_authorized = $this->auth->is_authorized($this->host); if ($this->view == "") { $this->view = $this->config->conf['overview-range']; } if ($this->start) { $this->url .= "&start=" . $this->start; $this->session->set("start", $this->start); } if ($this->end) { $this->url .= "&end=" . $this->end; $this->session->set("end", $this->end); } $this->title = "Start {$this->host}"; $services = $this->data->getServices($this->host); $this->title = "Service Overview for {$this->host}"; foreach ($services as $service) { if ($service['state'] == 'active') { $this->data->buildDataStruct($this->host, $service['name'], $this->view); } } } else { if (isset($this->host)) { url::redirect("/graph"); } else { throw new Kohana_Exception('error.get-first-host'); } } }
public function index() { // Disable auto-rendering $this->auto_render = FALSE; $this->tpl = $this->input->get('tpl'); $this->start = $this->input->get('start'); $this->end = $this->input->get('end'); $this->view = $this->config->conf['overview-range']; //default value $this->source = NULL; if ($this->input->get('view') != "") { $this->view = $this->input->get('view'); } if ($this->input->get('source')) { $this->source = intval($this->input->get('source')); } if ($this->input->get('w') != "") { $this->rrdtool->config->conf['graph_width'] = intval($this->input->get('w')); } if ($this->input->get('graph_width') != "") { $this->rrdtool->config->conf['graph_width'] = intval($this->input->get('graph_width')); } if ($this->input->get('h') != "") { $this->rrdtool->config->conf['graph_height'] = intval($this->input->get('h')); } if ($this->input->get('graph_height') != "") { $this->rrdtool->config->conf['graph_height'] = intval($this->input->get('graph_height')); } $this->data->getTimeRange($this->start, $this->end, $this->view); if (isset($this->tpl)) { $this->tpl = pnp::clean($this->tpl); $this->data->buildDataStruct('__special', $this->tpl, $this->view, $this->source); #print Kohana::debug($this->data->STRUCT); $image = $this->rrdtool->doImage($this->data->STRUCT[0]['RRD_CALL']); $this->rrdtool->streamImage($image); } elseif (isset($this->host) && isset($this->service)) { $this->service = pnp::clean($this->service); $this->host = pnp::clean($this->host); $this->data->buildDataStruct($this->host, $this->service, $this->view, $this->source); if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE) { $this->rrdtool->streamImage("ERROR: NOT_AUTHORIZED"); } #print Kohana::debug($this->data->STRUCT); if (sizeof($this->data->STRUCT) > 0) { $image = $this->rrdtool->doImage($this->data->STRUCT[0]['RRD_CALL']); } else { $image = FALSE; } $this->rrdtool->streamImage($image); } else { url::redirect("start", 302); } }
public function search() { $query = pnp::clean($this->input->get('term')); $result = array(); if (strlen($query) >= 1) { $hosts = $this->data->getHosts(); foreach ($hosts as $host) { if (preg_match("/{$query}/i", $host['name'])) { array_push($result, $host['name']); } } echo json_encode($result); } }
public function csv() { if (isset($this->host) && isset($this->service)) { $this->service = pnp::clean($this->service); $this->host = pnp::clean($this->host); $this->data->buildXport($this->host, $this->service); $data = $this->rrdtool->doXport($this->data->XPORT); $csv = $this->data->xml2csv($data); header("Content-Type: text/plain; charset=UTF-8"); print $csv; } else { throw new Kohana_Exception('error.xport-host-service'); } }
public function search() { $this->template->query = $this->add_view('mobile_search'); $query = pnp::clean($this->input->post('term')); $result = array(); if (strlen($query) >= 1) { $hosts = $this->data->getHosts(); foreach ($hosts as $host) { if (preg_match("/{$query}/i", $host['name'])) { array_push($result, $host['name']); } } } $this->result = $result; }
public function csv() { if (isset($this->host) && isset($this->service)) { $this->service = pnp::clean($this->service); $this->host = pnp::clean($this->host); $this->data->buildXport($this->host, $this->service); if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE) { header("Content-Type: text/plain; charset=UTF-8"); print "not authorized"; exit; } $data = $this->rrdtool->doXport($this->data->XPORT); $csv = $this->data->xml2csv($data); header("Content-Type: text/plain; charset=UTF-8"); print $csv; } else { throw new Kohana_Exception('error.xport-host-service'); } }
public function index() { if ($this->view == "") { $this->view = $this->config->conf['overview-range']; } $this->imgwidth = pnp::clean($this->input->get('width', $this->config->conf['popup-width'])); $this->data->getTimeRange($this->start, $this->end, $this->view); if (isset($this->host) && isset($this->service)) { $this->data->buildDataStruct($this->host, $this->service, $this->view, $this->source); $this->template->host = $this->host; $this->template->srv = $this->service; $this->template->view = $this->view; $this->template->source = $this->source; $this->template->end = $this->end; $this->template->start = $this->start; $this->template->imgwidth = $this->imgwidth; } else { url::redirect("/graph"); } }
public function index() { $this->start = $this->input->get('start'); $this->end = $this->input->get('end'); $this->source = $this->input->get('source'); $this->view = ""; if (isset($_GET['view']) && $_GET['view'] != "") { $this->view = pnp::clean($_GET['view']); } else { $this->view = $this->config->conf['overview-range']; } $this->data->getTimeRange($this->start, $this->end, $this->view); if (isset($this->tpl) && $this->tpl != 'undefined') { if ($this->start && $this->end) { $this->session->set("start", $this->start); $this->session->set("end", $this->end); } $this->template->tpl = $this->tpl; $this->template->view = $this->view; $this->template->source = $this->source; $this->template->end = $this->end; $this->template->start = $this->start; $this->template->graph_height = $this->config->conf['graph_height']; $this->template->graph_width = $this->config->conf['graph_width']; } elseif (isset($this->host) && isset($this->service)) { if ($this->start && $this->end) { $this->session->set("start", $this->start); $this->session->set("end", $this->end); } $this->template->host = $this->host; $this->template->srv = $this->service; $this->template->view = $this->view; $this->template->source = $this->source; $this->template->end = $this->end; $this->template->start = $this->start; $this->template->graph_height = $this->config->conf['graph_height']; $this->template->graph_width = $this->config->conf['graph_width']; } else { url::redirect("/graph"); } }
public function index() { // Disable auto-rendering $this->auto_render = FALSE; $tpl = $this->input->get('tpl'); $host = $this->input->get('host'); $service = $this->input->get('srv'); $start = $this->input->get('start'); $end = $this->input->get('end'); $view = $this->config->conf['overview-range']; //default value $source = ""; if ($this->input->get('view') != "") { $view = $this->input->get('view'); } if ($this->input->get('source')) { $source = $this->input->get('source'); } $this->data->getTimeRange($start, $end, $view); if (isset($tpl)) { $tpl = pnp::clean($tpl); $this->data->buildDataStruct('__special', $tpl, $view, $source); #print Kohana::debug($this->data->STRUCT); $image = $this->rrdtool->doImage($this->data->STRUCT[0]['RRD_CALL']); $this->rrdtool->streamImage($image); } elseif (isset($host) && isset($service)) { $service = pnp::clean($service); $host = pnp::clean($host); $this->data->buildDataStruct($host, $service, $view, $source); #print Kohana::debug($this->data->STRUCT); if (sizeof($this->data->STRUCT) > 0) { $image = $this->rrdtool->doImage($this->data->STRUCT[0]['RRD_CALL']); } else { $image = FALSE; } $this->rrdtool->streamImage($image); } else { print "ERROR"; } }
public function index() { $this->auto_render = FALSE; if (isset($this->host) && isset($this->service)) { $this->service = pnp::clean($this->service); $this->host = pnp::clean($this->host); } elseif (isset($this->host)) { $this->host = pnp::clean($this->host); $this->service = "_HOST_"; } else { throw new Kohana_User_Exception('No Options', "RTFM my Friend, RTFM!"); } $xmlfile = $this->config->conf['rrdbase'] . $this->host . "/" . $this->service . ".xml"; if (is_readable($xmlfile)) { $fh = fopen($xmlfile, 'r'); header('Content-Type: application/xml'); fpassthru($fh); fclose($fh); exit; } throw new Kohana_User_Exception('File Not found', "File {$xmlfile} not found"); }
public function index() { $this->auto_render = FALSE; if (isset($this->host) && isset($this->service)) { $this->service = pnp::clean($this->service); $this->host = pnp::clean($this->host); } elseif (isset($this->host)) { $this->host = pnp::clean($this->host); $this->service = "_HOST_"; } else { throw new Kohana_User_Exception('No Options', "RTFM my Friend, RTFM!"); } $this->data->readXML($this->host, $this->service); if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE) { header('Content-Type: application/xml'); print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; print "<NAGIOS>\n"; print "<ERROR>not authorized</ERROR>\n"; print "</NAGIOS>\n"; exit; } else { $xmlfile = $this->config->conf['rrdbase'] . $this->host . "/" . $this->service . ".xml"; if (is_readable($xmlfile)) { $fh = fopen($xmlfile, 'r'); header('Content-Type: application/xml'); fpassthru($fh); fclose($fh); exit; } else { header('Content-Type: application/xml'); print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; print "<NAGIOS>\n"; print "<ERROR>file not found</ERROR>\n"; print "</NAGIOS>\n"; } } }
public function basket() { $this->start = $this->input->get('start'); $this->end = $this->input->get('end'); $this->view = ""; if (isset($_GET['view']) && $_GET['view'] != "") { $this->view = pnp::clean($_GET['view']); } $this->data->getTimeRange($this->start, $this->end, $this->view); $basket = $this->session->get("basket"); if (is_array($basket) && sizeof($basket) > 0) { foreach ($basket as $item) { # explode host::service::source $slices = explode("::", $item); if (sizeof($slices) == 2) { $this->data->buildDataStruct($slices[0], $slices[1], $this->view); } if (sizeof($slices) == 3) { $this->data->buildDataStruct($slices[0], $slices[1], $this->view, $slices[2]); } } } //echo Kohana::debug($this->data->STRUCT); /* * PDF Output */ $pdf = new PDF(); $pdf->AliasNbPages(); $pdf->SetAutoPageBreak('off'); $pdf->SetMargins(17.5, 30, 10); $pdf->AddPage(); if ($this->use_bg) { $pdf->setSourceFile($this->config->conf['background_pdf']); $tplIdx = $pdf->importPage(1, '/MediaBox'); $pdf->useTemplate($tplIdx); } $pdf->SetCreator('Created with PNP'); $pdf->SetFont('Arial', '', 10); // Title foreach ($this->data->STRUCT as $data) { if ($pdf->GetY() > 200) { $pdf->AddPage(); if ($this->use_bg) { $pdf->useTemplate($tplIdx); } } if ($data['LEVEL'] == 0) { $pdf->SetFont('Arial', '', 12); $pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME'] . " -- " . $data['MACRO']['DISP_SERVICEDESC'], 0, 1); $pdf->SetFont('Arial', '', 10); $pdf->CELL(120, 5, $data['TIMERANGE']['title'] . " (" . $data['TIMERANGE']['f_start'] . " - " . $data['TIMERANGE']['f_end'] . ")", 0, 1); $pdf->SetFont('Arial', '', 8); $pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1); } else { $pdf->SetFont('Arial', '', 8); $pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1); } $image = $this->rrdtool->doImage($data['RRD_CALL'], $out = 'PDF'); $img = $this->rrdtool->saveImage($image); $Y = $pdf->GetY(); $cell_height = $img['height'] * 0.23; $cell_width = $img['width'] * 0.23; $pdf->Image($img['file'], 17.5, $Y, $cell_width, $cell_height, 'PNG'); $pdf->CELL(120, $cell_height, '', 0, 1); unlink($img['file']); } $pdf->Output("pnp4nagios.pdf", "I"); }
public function getTimeRange($start = FALSE, $end = FALSE, $view = "") { if ($end != FALSE) { // we are in a custom timerange if (!is_numeric($end)) { $timestamp = strtotime($end); if (!$timestamp) { throw new Kohana_User_Exception('Wrong Format', "End -> {$end}"); } else { $end = $timestamp; } } } else { $end = time(); } if ($start != FALSE) { // we are in a custom timerange if (!is_numeric($start)) { $timestamp = strtotime($start); if (!$timestamp) { throw new Kohana_User_Exception('Wrong Format', "Start -> {$start}"); } else { $start = $timestamp; } } } if ($start && $end) { $timerange['title'] = Kohana::lang('common.timerange-selector-link'); $timerange['start'] = $start; $timerange['f_start'] = date($this->config->conf['date_fmt'], $start); $timerange['end'] = $end; $timerange['f_end'] = date($this->config->conf['date_fmt'], $end); $timerange['cmd'] = " --start {$start} --end {$end} "; $timerange['type'] = "start-end"; $this->TIMERANGE = $timerange; return; } $view = intval(pnp::clean($view)); if ($view >= sizeof($this->config->views)) { $view = 1; } if (!$end) { $end = time(); } elseif (!is_numeric($end)) { $timestamp = strtotime($end); if (!$timestamp) { throw new Kohana_User_Exception('Wrong Format', "{$end}"); } else { $end = $timestamp; } } else { $end = $end; } if (!$start) { $start = $end - $this->config->views[$view]['start']; } elseif (!is_numeric($start)) { $timestamp = strtotime($start); if (!$timestamp) { throw new Kohana_User_Exception('Wrong Format', "{$start}"); } else { $start = $timestamp; } } else { $start = pnp::clean($start); } if ($start >= $end) { //Fixme i18n throw new Kohana_User_Exception('Wrong Timerange', "start >= end"); } $timerange['title'] = $this->config->views[$view]['title']; $timerange['start'] = $start; $timerange['f_start'] = date($this->config->conf['date_fmt'], $start); $timerange['end'] = $end; $timerange['f_end'] = date($this->config->conf['date_fmt'], $end); $timerange['cmd'] = " --start {$start} --end {$end} "; $timerange['type'] = "views"; for ($i = 0; $i < sizeof($this->config->views); $i++) { $timerange[$i]['title'] = $this->config->views[$i]['title']; $timerange[$i]['start'] = $end - $this->config->views[$i]['start']; $timerange[$i]['f_start'] = date($this->config->conf['date_fmt'], $end - $this->config->views[$i]['start']); $timerange[$i]['end'] = $end; $timerange[$i]['f_end'] = date($this->config->conf['date_fmt'], $end); $timerange[$i]['cmd'] = " --start " . ($end - $this->config->views[$i]['start']) . " --end {$end}"; } $this->TIMERANGE = $timerange; }
public function index() { $this->template->graph->graph_content = $this->add_view('graph_content'); $this->template->graph->graph_content->graph_width = $this->config->conf['graph_width'] + 85; $this->template->graph->graph_content->timerange_select = $this->add_view('timerange_select'); $this->template->graph->header = $this->add_view('header'); $this->template->graph->search_box = $this->add_view('search_box'); $this->template->graph->service_box = $this->add_view('service_box'); $this->template->graph->basket_box = $this->add_view('basket_box'); $this->template->graph->widget_menu = $this->add_view('widget_menu'); $this->template->graph->graph_content->widget_graph = $this->add_view('widget_graph'); // Change the status box while multisite theme is in use if ($this->theme == "multisite") { $this->template->graph->status_box = $this->add_view('multisite_box'); $this->template->graph->status_box->base_url = $this->config->conf['multisite_base_url']; $this->template->graph->status_box->site = $this->config->conf['multisite_site']; } else { $this->template->graph->status_box = $this->add_view('status_box'); } // Service Details if ($this->host != "" && $this->service != "") { $this->service = pnp::clean($this->service); $this->host = pnp::clean($this->host); $this->url = "?host=" . $this->host . "&srv=" . $this->service; $services = $this->data->getServices($this->host); #print Kohana::debug($services); $this->data->buildDataStruct($this->host, $this->service, $this->view); $this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']); $this->title = Kohana::lang('common.service-details') . " " . $this->host . " -> " . $this->data->MACRO['DISP_SERVICEDESC']; $this->template->graph->graph_content->graph_width = $this->data->STRUCT[0]['GRAPH_WIDTH'] + 85; $this->template->zoom_header->graph_width = $this->data->STRUCT[0]['GRAPH_WIDTH'] + 140; $this->template->zoom_header->graph_height = $this->data->STRUCT[0]['GRAPH_HEIGHT'] + 230; // Status Box Vars $this->template->graph->status_box->host = $this->data->MACRO['DISP_HOSTNAME']; $this->template->graph->status_box->lhost = $this->data->MACRO['HOSTNAME']; $this->template->graph->status_box->service = $this->data->MACRO['DISP_SERVICEDESC']; $this->template->graph->status_box->lservice = $this->data->MACRO['SERVICEDESC']; $this->template->graph->status_box->timet = date($this->config->conf['date_fmt'], intval($this->data->MACRO['TIMET'])); // Service Box Vars $this->template->graph->service_box->services = $services; $this->template->graph->service_box->host = $this->host; // Timerange Box Vars $this->template->graph->timerange_box = $this->add_view('timerange_box'); $this->template->graph->timerange_box->timeranges = $this->data->TIMERANGE; // // Host Overview } elseif ($this->host != "") { $this->is_authorized = $this->auth->is_authorized($this->host); $this->host = pnp::clean($this->host); if ($this->view == "") { $this->view = $this->config->conf['overview-range']; } $this->url = "?host=" . $this->host; $this->title = Kohana::lang('common.start') . " " . $this->host; $services = $this->data->getServices($this->host); // Status Box Vars $this->template->graph->status_box->host = $this->data->MACRO['DISP_HOSTNAME']; $this->template->graph->status_box->lhost = $this->data->MACRO['HOSTNAME']; $this->template->graph->status_box->shost = pnp::shorten($this->data->MACRO['DISP_HOSTNAME']); $this->template->graph->status_box->timet = date($this->config->conf['date_fmt'], intval($this->data->MACRO['TIMET'])); // Service Box Vars $this->template->graph->service_box->services = $services; $this->template->graph->service_box->host = $this->host; // Timerange Box Vars $this->template->graph->timerange_box = $this->add_view('timerange_box'); $this->template->graph->timerange_box->timeranges = $this->data->TIMERANGE; $this->template->graph->icon_box->xml_icon = FALSE; $this->title = Kohana::lang('common.service-overview', $this->host); foreach ($services as $service) { if ($service['state'] == 'active') { $this->data->buildDataStruct($this->host, $service['name'], $this->view); } } } else { if ($this->isAuthorizedFor('host_overview')) { $this->host = $this->data->getFirstHost(); if (isset($this->host)) { url::redirect("graph?host=" . $this->host); } else { throw new Kohana_Exception('error.get-first-host'); } } else { throw new Kohana_Exception('error.not_authorized_for_host_overview'); } } $this->template->graph->logo_box = $this->add_view('logo_box'); $this->template->graph->header->title = $this->title; }
public function __construct() { parent::__construct(); $this->data = new Data_Model(); $this->config = new Config_Model(); $this->rrdtool = new Rrdtool_Model(); $this->auth = new Auth_Model(); #$this->system = new System_Model(); $this->config->read_config(); Kohana::config_set('locale.language', $this->config->conf['lang']); // Check for mod_rewrite $this->check_mod_rewrite(); $this->start = $this->input->get('start', FALSE); $this->end = $this->input->get('end', FALSE); $this->theme = $this->input->get('theme', FALSE); $this->view = ""; $this->host = $this->input->get('host', NULL); $this->service = $this->input->get('srv', NULL); $this->controller = Router::$controller; if ($this->host != NULL) { $this->host = urldecode($this->host); } if ($this->service != NULL) { $this->service = urldecode($this->service); } if (isset($_GET['view']) && $_GET['view'] != "") { $this->view = pnp::clean($_GET['view']); } $this->data->getTimeRange($this->start, $this->end, $this->view); if (Router::$controller != "image" && Router::$controller != "image_special") { $this->session = Session::instance(); # Session withou theme info if ($this->session->get("theme", "new") == "new") { if ($this->theme) { # store $this->theme if available Kohana::config_set('core.theme', $this->theme); $this->session->set('theme', $this->theme); } else { # set $this->theme to default value $this->theme = $this->config->conf['ui-theme']; Kohana::config_set('core.theme', $this->theme); } # Sesion with theme info } else { if ($this->theme && $this->theme != 'default') { # store $this->theme if available $this->session->set('theme', $this->theme); Kohana::config_set('core.theme', $this->theme); } elseif ($this->theme == 'default') { # reset to default theme $this->theme = $this->config->conf['ui-theme']; $this->session->set('theme', $this->theme); Kohana::config_set('core.theme', $this->theme); } else { # set $this->theme with session infos $this->theme = $this->session->get('theme'); Kohana::config_set('core.theme', $this->theme); } } if ($this->start && $this->end) { if ($this->session->get('timerange-reset', 0) == 0) { $this->session->set("start", $this->start); $this->session->set("end", $this->end); } else { $this->session->set('timerange-reset', 0); } } if ($this->start && !$this->end) { if ($this->session->get('timerange-reset', 0) == 0) { $this->session->set("start", $this->start); $this->session->set("end", ""); } else { $this->session->set('timerange-reset', 0); } } if ($this->end && !$this->start) { if ($this->session->get('timerange-reset', 0) == 0) { $this->session->set("end", $this->end); $this->session->set("start", ""); } else { $this->session->set('timerange-reset', 0); } } } }