Revize 609
Přidáno uživatelem harryhk před více než 14 roky(ů)
freenetis/trunk/kohana/media/download/smokeping_general | ||
---|---|---|
# Note that all IP addresses in this file are false, to prevent some
|
||
# machine falling under a deadly DOS storm because all users keep
|
||
# the same addresses in their config.
|
||
|
||
*** General ***
|
||
|
||
################################################
|
||
# DON'T TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING
|
||
# BETWEEN THESE MARKS!
|
||
################################################
|
||
sendmail = /usr/sbin/sendmail
|
||
imgcache = /var/www/smokeping
|
||
imgurl = ../smokeping
|
||
datadir = /var/lib/smokeping
|
||
piddir = /var/run/smokeping
|
||
smokemail = /etc/smokeping/smokemail
|
||
tmail = /etc/smokeping/tmail
|
||
################################################
|
||
# END OF DON'T TOUCH SECTION
|
||
################################################
|
||
|
||
|
||
# Please edit this to suit your installation
|
||
owner = monitor admins
|
||
contact = monitor@hkfree.org
|
||
cgiurl = http://sojka.hkfree.org/cgi-bin/smokeping.cgi
|
||
mailhost = smtp.hkfree.org
|
||
# specify this to get syslog logging
|
||
syslogfacility = local0
|
||
# each probe is now run in its own process
|
||
# disable this to revert to the old behaviour
|
||
# concurrentprobes = no
|
||
|
||
*** Alerts ***
|
||
to = monitor@hkfree.org
|
||
from = monitor@hkfree.org
|
||
|
||
+bigloss
|
||
type = loss
|
||
# in percent
|
||
pattern = ==0%,==0%,==0%,==0%,>0%,>0%,>0%
|
||
comment = suddenly there is packet loss
|
||
|
||
+someloss
|
||
type = loss
|
||
# in percent
|
||
pattern = >0%,*12*,>0%,*12*,>0%
|
||
comment = loss 3 times in a row
|
||
|
||
+startloss
|
||
type = loss
|
||
# in percent
|
||
pattern = ==S,>0%,>0%,>0%
|
||
comment = loss at startup
|
||
|
||
+rttdetect
|
||
type = rtt
|
||
# in milli seconds
|
||
pattern = <10,<10,<10,<10,<10,<100,>100,>100,>100
|
||
comment = routing mesed up again ?
|
||
|
||
*** Database ***
|
||
|
||
step = 300
|
||
pings = 20
|
||
|
||
# consfn mrhb steps total
|
||
|
||
AVERAGE 0.5 1 1008
|
||
AVERAGE 0.5 12 4320
|
||
MIN 0.5 12 4320
|
||
MAX 0.5 12 4320
|
||
AVERAGE 0.5 144 720
|
||
MAX 0.5 144 720
|
||
MIN 0.5 144 720
|
||
|
||
*** Presentation ***
|
||
|
||
template = /etc/smokeping/basepage.html
|
||
|
||
+ overview
|
||
|
||
width = 600
|
||
height = 50
|
||
range = 10h
|
||
|
||
+ detail
|
||
|
||
width = 600
|
||
height = 200
|
||
unison_tolerance = 2
|
||
|
||
"Last 3 Hours" 3h
|
||
"Last 30 Hours" 30h
|
||
"Last 10 Days" 10d
|
||
"Last 400 Days" 400d
|
||
|
||
*** Probes ***
|
||
|
||
+ FPing
|
||
|
||
binary = /usr/bin/fping
|
||
|
||
*** Targets ***
|
||
|
||
probe = FPing
|
||
|
||
## You have to edit and uncomment all what you want below this.
|
||
# Please, refer to smokeping_config man page for more info
|
||
# The given adresses aren't real to avoid DoS.
|
||
|
||
menu = Top
|
||
title = Network Latency Grapher
|
||
remark = HKFREE.ORG smokeping
|
||
|
||
freenetis/trunk/kohana/media/download/smokeping_freenetis | ||
---|---|---|
+ HKFree
|
||
|
||
menu = HKFree
|
||
title = HKFree
|
||
|
||
++ Kocourkov
|
||
|
||
menu = Kocourkov
|
||
title = Kocourkov
|
||
|
||
+++ Andre
|
||
|
||
menu = Andre
|
||
title = Andre
|
||
|
||
++++ Andre-router
|
||
|
||
menu = Andre-router
|
||
title = Andre-router
|
||
host = 10.107.137.1
|
||
|
||
++++ Andre-router2
|
||
|
||
menu = Andre-router2
|
||
title = Andre-router2
|
||
host = 10.107.137.129
|
||
|
||
+++ Hrubinova
|
||
|
||
menu = Hrubinova
|
||
title = Hrubinova
|
||
|
||
++++ Hrubinova-router
|
||
|
||
menu = Hrubinova-router
|
||
title = Hrubinova-router
|
||
host = 10.107.237.1
|
||
|
||
++++ Hrubínova hotspot
|
||
|
||
menu = Hrubínova hotspot
|
||
title = Hrubínova hotspot
|
||
host = 10.107.237.4
|
||
|
||
+++ Kocourkov-router
|
||
|
||
menu = Kocourkov-router
|
||
title = Kocourkov-router
|
||
host = 10.107.37.1
|
||
|
||
+++ Smokeping test 2
|
||
|
||
menu = Smokeping test 2
|
||
title = Smokeping test 2
|
||
host = 10.107.37.156
|
||
|
||
++ Kukleny
|
||
|
||
menu = Kukleny
|
||
title = Kukleny
|
||
|
||
++ Spar
|
||
|
||
menu = Spar
|
||
title = Spar
|
||
|
||
+ Internet
|
||
|
||
menu = Internet
|
||
title = Internet
|
||
|
||
+ KLFree
|
||
|
||
menu = KLFree
|
||
title = KLFree
|
||
|
||
freenetis/trunk/kohana/media/download/smokeping | ||
---|---|---|
# Note that all IP addresses in this file are false, to prevent some
|
||
# machine falling under a deadly DOS storm because all users keep
|
||
# the same addresses in their config.
|
||
|
||
*** General ***
|
||
|
||
################################################
|
||
# DON'T TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING
|
||
# BETWEEN THESE MARKS!
|
||
################################################
|
||
sendmail = /usr/sbin/sendmail
|
||
imgcache = /var/www/smokeping
|
||
imgurl = ../smokeping
|
||
datadir = /var/lib/smokeping
|
||
piddir = /var/run/smokeping
|
||
smokemail = /etc/smokeping/smokemail
|
||
tmail = /etc/smokeping/tmail
|
||
################################################
|
||
# END OF DON'T TOUCH SECTION
|
||
################################################
|
||
|
||
|
||
# Please edit this to suit your installation
|
||
owner = monitor admins
|
||
contact = monitor@hkfree.org
|
||
cgiurl = http://sojka.hkfree.org/cgi-bin/smokeping.cgi
|
||
mailhost = smtp.hkfree.org
|
||
# specify this to get syslog logging
|
||
syslogfacility = local0
|
||
# each probe is now run in its own process
|
||
# disable this to revert to the old behaviour
|
||
# concurrentprobes = no
|
||
|
||
*** Alerts ***
|
||
to = monitor@hkfree.org
|
||
from = monitor@hkfree.org
|
||
|
||
+bigloss
|
||
type = loss
|
||
# in percent
|
||
pattern = ==0%,==0%,==0%,==0%,>0%,>0%,>0%
|
||
comment = suddenly there is packet loss
|
||
|
||
+someloss
|
||
type = loss
|
||
# in percent
|
||
pattern = >0%,*12*,>0%,*12*,>0%
|
||
comment = loss 3 times in a row
|
||
|
||
+startloss
|
||
type = loss
|
||
# in percent
|
||
pattern = ==S,>0%,>0%,>0%
|
||
comment = loss at startup
|
||
|
||
+rttdetect
|
||
type = rtt
|
||
# in milli seconds
|
||
pattern = <10,<10,<10,<10,<10,<100,>100,>100,>100
|
||
comment = routing mesed up again ?
|
||
|
||
*** Database ***
|
||
|
||
step = 300
|
||
pings = 20
|
||
|
||
# consfn mrhb steps total
|
||
|
||
AVERAGE 0.5 1 1008
|
||
AVERAGE 0.5 12 4320
|
||
MIN 0.5 12 4320
|
||
MAX 0.5 12 4320
|
||
AVERAGE 0.5 144 720
|
||
MAX 0.5 144 720
|
||
MIN 0.5 144 720
|
||
|
||
*** Presentation ***
|
||
|
||
template = /etc/smokeping/basepage.html
|
||
|
||
+ overview
|
||
|
||
width = 600
|
||
height = 50
|
||
range = 10h
|
||
|
||
+ detail
|
||
|
||
width = 600
|
||
height = 200
|
||
unison_tolerance = 2
|
||
|
||
"Last 3 Hours" 3h
|
||
"Last 30 Hours" 30h
|
||
"Last 10 Days" 10d
|
||
"Last 400 Days" 400d
|
||
|
||
*** Probes ***
|
||
|
||
+ FPing
|
||
|
||
binary = /usr/bin/fping
|
||
|
||
*** Targets ***
|
||
|
||
probe = FPing
|
||
|
||
## You have to edit and uncomment all what you want below this.
|
||
# Please, refer to smokeping_config man page for more info
|
||
# The given adresses aren't real to avoid DoS.
|
||
|
||
menu = Top
|
||
title = Network Latency Grapher
|
||
remark = HKFREE.ORG smokeping
|
||
|
||
+ HKFree
|
||
|
||
menu = HKFree
|
||
title = HKFree
|
||
|
||
++ Kocourkov
|
||
|
||
menu = Kocourkov
|
||
title = Kocourkov
|
||
|
||
+++ Andre
|
||
|
||
menu = Andre
|
||
title = Andre
|
||
|
||
++++ Andre-router
|
||
|
||
menu = Andre-router
|
||
title = Andre-router
|
||
host = 10.107.137.1
|
||
|
||
++++ Andre-router2
|
||
|
||
menu = Andre-router2
|
||
title = Andre-router2
|
||
host = 10.107.137.129
|
||
|
||
+++ Hrubinova
|
||
|
||
menu = Hrubinova
|
||
title = Hrubinova
|
||
|
||
++++ Hrubinova-router
|
||
|
||
menu = Hrubinova-router
|
||
title = Hrubinova-router
|
||
host = 10.107.237.1
|
||
|
||
++++ Hrubínova hotspot
|
||
|
||
menu = Hrubínova hotspot
|
||
title = Hrubínova hotspot
|
||
host = 10.107.237.4
|
||
|
||
+++ Kocourkov-router
|
||
|
||
menu = Kocourkov-router
|
||
title = Kocourkov-router
|
||
host = 10.107.37.1
|
||
|
||
+++ Smokeping test 2
|
||
|
||
menu = Smokeping test 2
|
||
title = Smokeping test 2
|
||
host = 10.107.37.156
|
||
|
||
++ Kukleny
|
||
|
||
menu = Kukleny
|
||
title = Kukleny
|
||
|
||
++ Spar
|
||
|
||
menu = Spar
|
||
title = Spar
|
||
|
||
+ Internet
|
||
|
||
menu = Internet
|
||
title = Internet
|
||
|
||
+ KLFree
|
||
|
||
menu = KLFree
|
||
title = KLFree
|
||
|
||
freenetis/trunk/kohana/application/models/smokeping.php | ||
---|---|---|
}
|
||
|
||
return self::$db->query("SELECT
|
||
s.id, s.ip_address, s.title, s.menu, s.parent, s.level,
|
||
IF(strcmp(s.device,0),'●','-') AS device
|
||
s.id, s.title, s.menu, s.parent,
|
||
IF(strcmp(s.device,0),'●','-') AS device,
|
||
ip.ip_address, oa.host
|
||
FROM smokepings s
|
||
LEFT JOIN ip_addresses ip ON s.ip_address_id = ip.id
|
||
LEFT JOIN outter_addresses oa ON s.outter_address_id = oa.id
|
||
$where
|
||
ORDER BY $order_by $order_by_direction
|
||
LIMIT $limit_from, $limit_results"
|
||
... | ... | |
|
||
public function get_record($record_id){
|
||
return self::$db->query("SELECT
|
||
s.id, s.ip_address, s.title, s.menu, s.parent, s.level
|
||
s.id, s.ip_address, s.title, s.menu, s.parent, ip.ip_address, oa.host
|
||
FROM smokepings s
|
||
LEFT JOIN ip_addresses ip ON s.ip_address_id = ip.id
|
||
LEFT JOIN outter_addresses oa ON s.outter_address_id = oa.id
|
||
WHERE
|
||
s.id = $record_id
|
||
"
|
||
... | ... | |
|
||
public function get_parents(){
|
||
return self::$db->query("SELECT
|
||
s.id, s.menu, s.title, s.level
|
||
s.id, s.menu, s.title
|
||
FROM smokepings s
|
||
WHERE
|
||
s.device=0
|
||
... | ... | |
);
|
||
return count($parents);
|
||
}
|
||
|
||
public function get_root(){
|
||
return self::$db->query("SELECT
|
||
s.id
|
||
FROM smokepings s
|
||
WHERE
|
||
s.level=0
|
||
LIMIT 1
|
||
"
|
||
);
|
||
}
|
||
|
||
public function find_successor($parent_id){
|
||
return self::$db->query("SELECT
|
||
s.id, s.device, s.menu, s.title, s.level
|
||
s.id, s.device, s.menu, s.title, s.ip_address_id, s.outter_address_id, ip.ip_address, oa.host
|
||
FROM smokepings s
|
||
LEFT JOIN ip_addresses ip ON s.ip_address_id = ip.id
|
||
LEFT JOIN outter_addresses oa ON s.outter_address_id = oa.id
|
||
WHERE
|
||
s.parent=$parent_id
|
||
ORDER BY s.device DESC
|
||
"
|
||
);
|
||
}
|
||
... | ... | |
return count($successors);
|
||
}
|
||
|
||
public function count_deleted_records($filters=array())
|
||
{
|
||
$where = 'WHERE ';
|
||
$ip=$filters[0];
|
||
$admin=$filters[1];
|
||
$dur=$filters[2];
|
||
$dest=$filters[3];
|
||
$and = 0;
|
||
if($ip!=0){
|
||
$where .= 'ip_address LIKE \'%'.$ip.'%\' ';
|
||
$and = 1;
|
||
}
|
||
if($admin!=0){
|
||
if ($and) $where.= 'AND ';
|
||
$where .= 'admin = \''.$admin.'\'';
|
||
$and = 1;
|
||
}
|
||
if($dur!=0){
|
||
if ($and) $where.= 'AND ';
|
||
$where .= 'duration = \''.$dur.'\'';
|
||
$and = 1;
|
||
}
|
||
if($dest!=0){
|
||
if ($and) $where.= 'AND ';
|
||
$where .= 'destination = \''.$dest.'\'';
|
||
}
|
||
|
||
$redirections = self::$db->query("SELECT id FROM redirections $where"
|
||
);
|
||
|
||
return count($redirections);
|
||
}
|
||
|
||
|
||
}
|
||
?>
|
freenetis/trunk/kohana/application/models/ip_address.php | ||
---|---|---|
}
|
||
|
||
|
||
/**
|
||
* @author Lubomir Buben
|
||
* Function tries to find IP adress in database
|
||
* @param $ip_address
|
||
* @return unknown_type
|
||
*/
|
||
public function find_ip_address($ip_address){
|
||
return self::$db->query("SELECT
|
||
ip.id
|
||
FROM ip_addresses ip
|
||
WHERE
|
||
ip.ip_address = '$ip_address'
|
||
");
|
||
}
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/controllers/monitoring.php | ||
---|---|---|
*/
|
||
class Monitoring_Controller extends Controller{
|
||
private $links;
|
||
protected $ip_address_id;
|
||
|
||
function __construct(){
|
||
parent::__construct();
|
||
... | ... | |
$grid->order_field('id')->label('ID')->class('center');
|
||
$grid->order_field('title')->label(url_lang::lang('texts.Title'))->class('center');
|
||
$grid->order_field('menu')->label(url_lang::lang('texts.Menu'))->class('center');
|
||
$grid->order_field('level')->label(url_lang::lang('texts.Level'))->class('center');
|
||
$grid->order_field('parent')->label(url_lang::lang('texts.Parent'))->class('center');
|
||
$grid->order_field('device')->label(url_lang::lang('texts.Device'))->class('center');
|
||
$grid->order_field('ip_address')->label(url_lang::lang('texts.IP address'));
|
||
$grid->order_field('host')->label(url_lang::lang('texts.Host'));
|
||
//if ($this->acl_check_view('Devices_Controller','vlan'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'monitoring/show_smokeping') ->action(url_lang::lang('texts.Show'))->class('center');
|
||
//if ($this->acl_check_edit('Devices_Controller','vlan'))
|
||
... | ... | |
$view->render(TRUE);
|
||
}
|
||
|
||
function add_smokeping(){
|
||
function add_smokeping($ip_address_id = null){
|
||
//if (!$this->acl_check_new(get_class($this),'monitoring'))
|
||
// Controller::error(ACCESS);
|
||
|
||
if($ip_address_id != null){
|
||
$ip_address_model = new Ip_address_Model($ip_address_id);
|
||
}
|
||
|
||
//parents
|
||
$smokeping = new Smokeping_Model();
|
||
$total_parents = $smokeping->count_parents();
|
||
$all_parents = $smokeping->get_parents();
|
||
|
||
$parent_level[0] = '----- '.url_lang::lang('texts.Select parent').' -----';
|
||
foreach ($all_parents as $row){
|
||
$parent_level[$row->id]=$row->title;
|
||
}
|
||
|
||
//username + email
|
||
$user_id=$this->session->get('member_id');
|
||
$user_model = new User_Model();
|
||
$user_model->find($user_id);
|
||
if ($user_model->id == 0)
|
||
Controller::error(RECORD);
|
||
|
||
$this->form = new Forge(url_lang::base()."monitoring/add_smokeping", '', 'POST', array('id' => 'article_form'));
|
||
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$this->form->group('')->label(url_lang::lang('texts.Basic information'));
|
||
$this->form->input('ip_address')->label(url_lang::lang('texts.IP address').':')->rules('required');
|
||
if($ip_address_id!=null)
|
||
$this->form->input('ip_address')->label(url_lang::lang('texts.IP address').':')->rules('required')->value($ip_address_model->ip_address);
|
||
else
|
||
$this->form->input('ip_address')->label(url_lang::lang('texts.IP address').':')->rules('required');
|
||
$this->form->input('menu')->label(url_lang::lang('texts.Menu').':')->rules('required');
|
||
$this->form->input('title')->label(url_lang::lang('texts.Title').':')->rules('required');
|
||
$this->form->dropdown('parent')->label(url_lang::lang('texts.Parent').':')->options($parent_level)->rules('required');
|
||
... | ... | |
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
|
||
$smokeping = new Smokeping_Model();
|
||
$smokeping->ip_address = $form_data['ip_address'];
|
||
//looking for ip adress record in database
|
||
$ip_address_model2 = new Ip_address_Model();
|
||
$result = $ip_address_model2->find_ip_address($form_data['ip_address']);
|
||
if(count($result)>0){
|
||
foreach ($result as $row){
|
||
$ip_address_id = $row->id;
|
||
}
|
||
}
|
||
|
||
$smokeping = new Smokeping_Model();
|
||
if($ip_address_id==null){
|
||
$outter_address_model = new Outter_address_Model();
|
||
$outter_address_model->host = $form_data['ip_address'];
|
||
$outter_address_model->save();
|
||
$outter_address_model = new Outter_address_Model();
|
||
$result = $outter_address_model->find_host($form_data['ip_address']);
|
||
foreach($result as $row){
|
||
$smokeping->outter_address_id = $row->id;
|
||
}
|
||
} else {
|
||
$smokeping->ip_address_id = $ip_address_id;
|
||
}
|
||
$smokeping->menu = $form_data['menu'];
|
||
$smokeping->title = $form_data['title'];
|
||
$smokeping->device = 1;
|
||
//$smokeping_parent = new Smokeping_Model($form_data['parent']);
|
||
$smokeping->parent = $form_data['parent'];
|
||
|
||
$smokeping_parent = new Smokeping_Model($form_data['parent']);
|
||
$smokeping->parent = $form_data['parent'];
|
||
$smokeping->level = ($smokeping_parent->level)+1;
|
||
|
||
unset($form_data);
|
||
if ($smokeping->save()) {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Smokeping record has been successfully added.'));
|
||
... | ... | |
|
||
if($form_data['parent']==0){
|
||
$smokeping->parent = 0;
|
||
$smokeping->level = 0;
|
||
}else{
|
||
$smokeping_parent = new Smokeping_Model($form_data['parent']);
|
||
$smokeping->parent = $form_data['parent'];
|
||
$smokeping->level = ($smokeping_parent->level)+1;
|
||
}
|
||
|
||
unset($form_data);
|
||
... | ... | |
Controller::error(RECORD);
|
||
url::redirect(url_lang::base().'monitoring/smokeping');
|
||
}
|
||
|
||
|
||
//getting ip address or host of record
|
||
if($smokeping->ip_address_id != NULL){
|
||
$ip_address_model = new Ip_address_Model($smokeping->ip_address_id);
|
||
$ip_address = $ip_address_model->ip_address;
|
||
}else if($smokeping->outter_address_id != NULL){
|
||
$outter_address_model = new Outter_address_Model($smokeping->outter_address_id);
|
||
$ip_address = $outter_address_model->host;
|
||
}else{
|
||
$ip_address = "";
|
||
}
|
||
|
||
//getting parent of record
|
||
$smokeping2 = new Smokeping_Model($smokeping->parent);
|
||
$parent = $smokeping2->title;
|
||
if ($parent=="")
|
||
$parent = "(root)";
|
||
|
||
$link_back = html::anchor(url_lang::base().'monitoring/smokeping', url_lang::lang('texts.Back to the smokeping list'));
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Show smokeping record');
|
||
$view->content = new View('monitoring/show');
|
||
$view->content->smokeping = $smokeping;
|
||
$view->content->ip_address = $ip_address;
|
||
$view->content->parent = $parent;
|
||
$view->content->link_back = $link_back;
|
||
$view->render(TRUE);
|
||
}
|
||
... | ... | |
if ($smokeping->id == 0)
|
||
Controller::error(RECORD);
|
||
|
||
//parents
|
||
//getting parents
|
||
$smokeping_parent = new Smokeping_Model();
|
||
$total_parents = $smokeping_parent->count_parents();
|
||
$all_parents = $smokeping_parent->get_parents();
|
||
|
||
if($smokeping->device)
|
||
$parent_level[0] = '----- '.url_lang::lang('texts.Select parent').' -----';
|
||
else
|
||
$parent_level[0] = '----- '.url_lang::lang('texts.Root (level 0)').' -----';
|
||
foreach ($all_parents as $row){
|
||
$parent_level[$row->id]=$row->title.' ('.$row->level.')';
|
||
}
|
||
$parent_level[$row->id]=$row->title;
|
||
}
|
||
|
||
//getting ip address
|
||
if($smokeping->ip_address_id != NULL){
|
||
$ip_address_model = new Ip_address_Model($smokeping->ip_address_id);
|
||
$ip_address = $ip_address_model->ip_address;
|
||
$this->ip_address_id=$smokeping->ip_address_id;//save global parameter
|
||
}
|
||
if($smokeping->outter_address_id != NULL){
|
||
$outter_address_model = new Outter_address_Model($smokeping->outter_address_id);
|
||
$ip_address = $outter_address_model->host;
|
||
}
|
||
|
||
$this->form = new Forge(url_lang::base()."monitoring/edit_smokeping/".$smokeping_id, '', 'POST', array('id' => 'article_form'));
|
||
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$this->form->group('')->label(url_lang::lang('texts.Basic information'));
|
||
if($smokeping->device)
|
||
$this->form->input('ip_address')->label(url_lang::lang('texts.IP address').':')->rules('required')->value($smokeping->ip_address);
|
||
if($smokeping->device && $smokeping->ip_address_id!=NULL)
|
||
$this->form->input('ip_address')->label(url_lang::lang('texts.IP address').':')->rules('required')->value($ip_address)->callback(array($this, 'valid_ip'));
|
||
if($smokeping->device && $smokeping->outter_address_id!=NULL)
|
||
$this->form->input('ip_address')->label(url_lang::lang('texts.IP address').':')->rules('required')->value($ip_address);
|
||
$this->form->input('menu')->label(url_lang::lang('texts.Menu').':')->rules('required')->value($smokeping->menu);
|
||
$this->form->input('title')->label(url_lang::lang('texts.Title').':')->rules('required')->value($smokeping->title);
|
||
if($smokeping->device)
|
||
... | ... | |
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
|
||
$smokeping = new Smokeping_Model($smokeping_id);
|
||
if($smokeping->device){
|
||
$smokeping->ip_address = $form_data['ip_address'];
|
||
$smokeping->device = 1;
|
||
$smokeping_model = new Smokeping_Model($smokeping_id);
|
||
if($smokeping_model->device){
|
||
$smokeping_model->device = 1;
|
||
//saving ip address
|
||
if ($smokeping->ip_address_id != NULL){
|
||
$ip_address_model = new Ip_address_Model($smokeping->ip_address_id);
|
||
$ip_address_model->ip_address = $form_data['ip_address'];
|
||
$ip_address_model->save();
|
||
} else {
|
||
$outter_address_model = new Outter_address_Model($smokeping->outter_address_id);
|
||
$outter_address_model->host = $form_data['ip_address'];
|
||
$outter_address_model->save();
|
||
}
|
||
}else{
|
||
$smokeping->ip_address = "";
|
||
$smokeping->device = 0;
|
||
$smokeping_model->device = 0;
|
||
}
|
||
$smokeping->menu = $form_data['menu'];
|
||
$smokeping->title = $form_data['title'];
|
||
$smokeping_model->menu = $form_data['menu'];
|
||
$smokeping_model->title = $form_data['title'];
|
||
|
||
if($form_data['parent']==0){
|
||
$smokeping->parent = 0;
|
||
$smokeping->level = 0;
|
||
$smokeping_model->parent = 0; //parent = root
|
||
}else{
|
||
$smokeping_parent = new Smokeping_Model($form_data['parent']);
|
||
$smokeping->parent = $form_data['parent'];
|
||
$smokeping->level = ($smokeping_parent->level)+1;
|
||
$smokeping_model->parent = $form_data['parent'];
|
||
}
|
||
|
||
unset($form_data);
|
||
if ($smokeping->save()) {
|
||
if ($smokeping_model->save()) {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Smokeping record has been successfully updated.'));
|
||
url::redirect(url_lang::base().'monitoring/smokeping/');
|
||
exit;
|
||
... | ... | |
$smokeping_model = new Smokeping_Model($smokeping_id);
|
||
$linkback = url_lang::base()."monitoring/smokeping/";
|
||
|
||
//neni to menu, na kterem by byly zavisle dalsi zaznamy?
|
||
$smokeping_test = new Smokeping_Model();
|
||
$successors = $smokeping_test->count_successors($smokeping_id);
|
||
if ($successors>0){
|
||
$this->session->set_flash('message', url_lang::lang('texts.Cannot delete, there are other records depending on this one.'));
|
||
url::redirect($linkback);
|
||
//There are dependent records for this menu item
|
||
if($smokeping_model->device==0){
|
||
$smokeping_test = new Smokeping_Model();
|
||
$successors = $smokeping_test->count_successors($smokeping_id);
|
||
if ($successors>0){
|
||
$this->session->set_flash('message', url_lang::lang('texts.Cannot delete, there are other records depending on this one.'));
|
||
url::redirect($linkback);
|
||
}
|
||
}
|
||
|
||
|
||
//Deleting of outter address record
|
||
if($smokeping_model->outter_address_id != NULL){
|
||
$outter_address = new Outter_address_Model($smokeping_model->outter_address_id);
|
||
$outter_address->delete();
|
||
}
|
||
|
||
|
||
if ($smokeping_model->delete()){
|
||
$this->session->set_flash('message', url_lang::lang('texts.Smokeping record has been successfully deleted.'));
|
||
} else {
|
||
... | ... | |
}
|
||
|
||
function generate_smokeping(){
|
||
$smokeping = new Smokeping_Model();
|
||
$total_records = $smokeping->count_all_records();
|
||
|
||
$text = $this->find_successor(0);
|
||
$result = $this->find_successor(0, 0); //predecessor's id, level
|
||
|
||
$fp = FOpen ('media/download/smokeping_freenetis',"w");
|
||
if ($fp){
|
||
FWrite ($fp, $text);
|
||
FClose ($fp);
|
||
}
|
||
system ('cat media/download/smokeping_general media/download/smokeping_freenetis > media/download/smokeping');
|
||
url::redirect(url_lang::base().'../media/download/download.php?file=smokeping');
|
||
//url::redirect(url_lang::base().'monitoring/smokeping');
|
||
return;
|
||
// set content header
|
||
header('Content-type: application/force-download');
|
||
header('Content-Disposition: attachment; filename="smokeping.cfg"');
|
||
|
||
echo ''.$result.'';
|
||
exit;
|
||
}
|
||
|
||
function find_successor($id=null){
|
||
function find_successor($id = NULL, $level = 0){
|
||
$smokeping = new Smokeping_Model();
|
||
$successor = $smokeping->find_successor($id);
|
||
$text = "";
|
||
foreach ($successor as $row){
|
||
for($i=0; $i<$row->level+1; $i++){
|
||
for($i=0; $i<$level+1; $i++){
|
||
$text .= "+";
|
||
}
|
||
$text .= " $row->menu\n\nmenu = $row->menu\ntitle = $row->title\n";
|
||
if($row->device){ //narazili jsme na uzel, ktery je NODem (IP adresa atd.)
|
||
$smokeping_node = new Smokeping_Model($row->id);
|
||
$text .= "host = $smokeping_node->ip_address\n\n";
|
||
if($row->ip_address_id != NULL){
|
||
//$smokeping_node = new Ip_address_Model($row->ip_address_id);
|
||
$text .= "host = $row->ip_address\n\n";
|
||
} else if ($row->outter_address_id != NULL){
|
||
//$smokeping_node = new Outter_address_Model($row->outter_address_id);
|
||
$text .= "host = $row->host\n\n";
|
||
}
|
||
} else { //narazili jsme pouze na polozku menu
|
||
$text .= "\n";
|
||
$text .= $this->find_successor($row->id);
|
||
$text .= $this->find_successor($row->id, $level+1);
|
||
}
|
||
}
|
||
return $text;
|
||
... | ... | |
$view->render(TRUE);
|
||
|
||
}
|
||
|
||
/**
|
||
* Checks validity of ip address (used in monitoring/edit_smokeping function)
|
||
* @param $input
|
||
* @return unknown_type
|
||
*/
|
||
function valid_ip($input){
|
||
$method=$this->form->ip_address->method; // <FORM> method = POST, GET, ...
|
||
$ip=ip2long($this->input->$method('ip_address')); // Submitted values;
|
||
|
||
|
||
if ($ip === FALSE || $ip == -1){ // invalid IP adress
|
||
$input->add_error('required', url_lang::lang('texts.Invalid IP address'));
|
||
return false;
|
||
}
|
||
|
||
$ip_address_model = new Ip_address_Model($this->ip_address_id);
|
||
$subnet_id = $ip_address_model->subnet_id;
|
||
$subnet_model = new Subnet_Model();
|
||
$subnet = $subnet_model->
|
||
select("inet_aton(network_address) as net", "32-log2((~inet_aton(netmask) & 0xffffffff) + 1) as mask")->
|
||
where('id',$subnet_id)->
|
||
find();
|
||
|
||
$this->check_ip($ip, 0+$subnet->net, $subnet->mask, $input);
|
||
|
||
|
||
// checks if exists this ip
|
||
$ip_model = new ip_address_Model();
|
||
|
||
$ips = $ip_model->where('ip_address',$input->value)->find_all();
|
||
|
||
foreach ($ips as $ip)
|
||
{
|
||
if ($this->ip_address_id != $ip->id) // only for edit: check if ip_address is not still same
|
||
$input->add_error('required', url_lang::lang('texts.IP address already exists.'));
|
||
}
|
||
} // end of valid_ip
|
||
|
||
/**
|
||
* Checks ip address if matches subnet and mask.
|
||
* @param $ip
|
||
* @param $net
|
||
* @param $mask
|
||
* @param $input
|
||
* @return unknown_type
|
||
*/
|
||
function check_ip($ip, $net, $mask, $input)
|
||
{
|
||
$mask=0xffffffff<<(32-$mask) & 0xffffffff;
|
||
// printf(" ip=%lx, net=%lx, mask=%lx, AND=%lx", $ip, 0+$net, $mask, $ip & $mask);
|
||
if (($ip & $mask) != (int)$net ){
|
||
$input->add_error('required', url_lang::lang('texts.IP address does not match the subnet/mask.'));
|
||
}
|
||
else if ($ip==$net || $ip==($net | ~$mask))
|
||
$input->add_error('required', url_lang::lang('texts.Invalid IP address'));
|
||
}
|
||
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/controllers/ip_addresses.php | ||
---|---|---|
{
|
||
|
||
if (!$this->acl_check_view('Devices_Controller','ip_address'))
|
||
Controller::error(ACCESS);
|
||
Controller::error(1);
|
||
|
||
$ip_model = new Ip_address_Model();
|
||
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page'))) $limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
// creates fields for filtering
|
||
// creates fields for filtering members
|
||
$filter=new Table_Form(url_lang::base()."ip_addresses/show_all", "get", array(
|
||
new Table_Form_Item('text','ip_address','IP address'),
|
||
new Table_Form_Item('text','subnet_name','Subnet'),
|
||
... | ... | |
{
|
||
if (!isset($ip_address_id))
|
||
Controller::warning(PARAMETER);
|
||
$ip_address = new ip_address_Model($ip_address_id);
|
||
$ip_address = new ip_address_Model($ip_address_id);
|
||
if ($ip_address->iface_id)
|
||
{
|
||
$member_id = $ip_address->iface->device->user->member_id;
|
||
$device_id = $ip_address->iface->device_id;
|
||
$iface_id = $ip_address->iface_id;
|
||
}
|
||
else
|
||
{
|
||
$member_id = $ip_address->vlan_iface->iface->device->user->member_id;
|
||
$device_id = $ip_address->vlan_iface->iface->device_id;
|
||
$iface_id = $ip_address->vlan_iface->iface_id;
|
||
}
|
||
if ($ip_address->id == 0)
|
||
Controller::warning(RECORD);
|
||
if (!$this->acl_check_view('Devices_Controller','ip_address',$member_id))
|
||
Controller::error(ACCESS);
|
||
$member = new Member_Model($member_id);
|
||
$device = new Device_Model($device_id);
|
||
$iface = new Iface_Model($iface_id);
|
||
Controller::error(ACCESS);
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.IP address detail').' - '.$ip_address->ip_address;
|
||
$view->content = new View('ip_addresses_show');
|
||
$view->content->ip_address = $ip_address;
|
||
$view->content->member = $member;
|
||
$view->content->device = $device;
|
||
$view->content->iface = $iface;
|
||
$view->content->headline = url_lang::lang('texts.IP address detail').' - '.$ip_address->ip_address;
|
||
$view->render(TRUE);
|
||
} // end of show function
|
freenetis/trunk/kohana/application/controllers/config_files.php | ||
---|---|---|
$form_data['minimum'],$form_data['time_to_live'],$form_data['name_server'],
|
||
$form_data['name_server2'],$form_data['mail_exchange'],$form_data['soa_record'],$form_data['dns_admin']);
|
||
|
||
if($result=="EMPTY"){
|
||
$this->session->set_flash('message', url_lang::lang('texts.There are no relevant ip addresses for this cloud prefix.'));
|
||
url::redirect(url_lang::base().'config_files/dns_reverse/');
|
||
}
|
||
|
||
$filename = $form_data['ip_prefix'];
|
||
|
||
// set content header
|
||
... | ... | |
//getting all ip addresses of subnet
|
||
$ip_address_model = new Ip_address_Model();
|
||
$result2 = $ip_address_model->get_ip_addresses_of_subnet($row->id);
|
||
foreach ($result2 as $row2){
|
||
List ($ip1, $ip2, $ip3, $ip4) = Explode (".", $row2->ip_address);
|
||
$ip_addresses[]=$ip4;
|
||
if ($row2->gateway)
|
||
$users[]="";
|
||
else {
|
||
//getting user of ip address
|
||
$ip = new Ip_address_Model($row->id);
|
||
$user = $ip->iface->device->user->login;
|
||
//$user = $ip->vlan_iface->iface->device->user->login;
|
||
$users[]=strtolower($user).".";
|
||
if(count($result2)!=0){
|
||
foreach ($result2 as $row2){
|
||
List ($ip1, $ip2, $ip3, $ip4) = Explode (".", $row2->ip_address);
|
||
$ip_addresses[]=$ip4;
|
||
if ($row2->gateway)
|
||
$users[]="";
|
||
else {
|
||
//getting user of ip address
|
||
$ip = new Ip_address_Model($row->id);
|
||
$user = $ip->iface->device->user->login;
|
||
//$user = $ip->vlan_iface->iface->device->user->login;
|
||
$users[]=strtolower($user).".";
|
||
}
|
||
$total_records++;
|
||
}
|
||
$total_records++;
|
||
}
|
||
}
|
||
|
||
if($total_records==0){
|
||
return "EMPTY";
|
||
}
|
||
|
||
$arpa = "$ip3.$ip2.$ip1.in-addr.arpa";
|
||
$serial = $today = date("Ymd")."00";
|
||
|
||
... | ... | |
$text .= "\$ORIGIN $arpa.\n\$TTL $time_to_live\n\n";
|
||
|
||
for ($i=0; $i<$total_records; $i++){
|
||
$text .= "$ip_addresses[$i] PTR $users[$i]$cloud_name.$settings->domain_name.\n";
|
||
if($cloud_name!="")
|
||
$text .= "$ip_addresses[$i] PTR $users[$i]$cloud_name.$settings->domain_name.\n";
|
||
else
|
||
$text .= "$ip_addresses[$i] PTR $users[$i]$settings->domain_name.\n";
|
||
}
|
||
$text .= "\n\n";
|
||
return $text;
|
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php | ||
---|---|---|
|
||
// array of sql queries that upgrade database
|
||
$upgrade_sql[get_SVN_rev()] = array(
|
||
"UPDATE `aro_groups` SET `lft` = 1, `rgt` = '40' WHERE `aro_groups`.`id` = 21;",
|
||
"CREATE TABLE `outter_addresses` (
|
||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||
`host` VARCHAR(60) NOT NULL,
|
||
PRIMARY KEY (`id`)
|
||
)
|
||
ENGINE = InnoDB
|
||
CHARACTER SET utf8 COLLATE utf8_general_ci;",
|
||
|
||
"UPDATE `aro_groups` SET `lft` = 2, `rgt` = '37' WHERE `aro_groups`.`id` = 22;",
|
||
"DROP TABLE IF EXISTS `areas`",
|
||
|
||
"UPDATE `aro_groups` SET `lft` = 38, `rgt` = '39' WHERE `aro_groups`.`id` = 23;",
|
||
"DROP TABLE IF EXISTS `area_prefix`",
|
||
|
||
"UPDATE `aro_groups` SET `lft` = 9, `rgt` = '32' WHERE `aro_groups`.`id` = 26;",
|
||
"DROP TABLE IF EXISTS `smokepings`",
|
||
|
||
"UPDATE `aro_groups` SET `lft` = 10, `rgt` = '31', `name` = 'First-degree certified engineers',
|
||
`value` = 'first_degree_certified_engineers' WHERE `aro_groups`.`id` = 29;",
|
||
|
||
"UPDATE `aro_groups` SET `lft` = 33, `rgt` = '34' WHERE `aro_groups`.`id` = 32;",
|
||
|
||
"UPDATE `aro_groups` SET `lft` = 35, `rgt` = '36' WHERE `aro_groups`.`id` = 33;",
|
||
|
||
"UPDATE `aro_groups` SET `lft` = 29, `rgt` = '30' WHERE `aro_groups`.`id` = 34;",
|
||
|
||
"INSERT INTO `aro_groups` (`id`, `parent_id`, `lft`, `rgt`, `name`, `value`) VALUES
|
||
(35, 29, 11, 28, 'Second-degree certified engineers', 'second_degree_certified_engineers'),
|
||
(36, 35, 12, 27, 'Third-degree certified engineers', 'third_degree_certified_engineers'),
|
||
(37, 36, 13, 26, 'Fourth-degree certified engineers', 'fourth_degree_certified_engineers'),
|
||
(38, 37, 14, 25, 'Fifth-degree certified engineers', 'fifth_degree_certified_engineers'),
|
||
(39, 38, 15, 24, 'Sixth-degree certified engineers', 'sixth_degree_certified_engineers'),
|
||
(40, 39, 16, 23, 'Seventh-degree certified engineers', 'seventh_degree_certified_engineers'),
|
||
(41, 40, 17, 22, 'Eighth-degree certified engineers', 'eighth_degree_certified_engineers'),
|
||
(42, 41, 18, 21, 'Nineth-degree certified engineers', 'nineth_degree_certified_engineers'),
|
||
(43, 42, 19, 20, 'Tenth-degree certified engineers', 'tenth_degree_certified_engineers');",
|
||
|
||
"DELETE FROM `axo_map` WHERE `axo_map`.`acl_id` = 49 AND CONVERT(`axo_map`.`section_value` USING utf8) = 'Devices_Controller' AND CONVERT(`axo_map`.`value` USING utf8) = 'admin' LIMIT 1;",
|
||
|
||
"INSERT INTO `acl` (`id`, `section_value`, `allow`, `enabled`, `return_value`, `note`, `updated_date`) VALUES ('68', 'user', '1', '1', '', 'First-degree certified engineers can only view admins of devices; they cannot edit them.', UNIX_TIMESTAMP());",
|
||
|
||
"INSERT INTO `aco_map` (`acl_id`, `section_value`, `value`) VALUES ('68', 'freenetis', 'view_all');",
|
||
|
||
"INSERT INTO `aro_groups_map` (`acl_id`, `group_id`) VALUES ('68', '29');",
|
||
|
||
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES ('68', 'Devices_Controller', 'admin');",
|
||
|
||
"INSERT INTO `acl` (`id`, `section_value`, `allow`, `enabled`, `return_value`, `note`, `updated_date`) VALUES ('69', 'user', '1', '1', '', 'Fourth-degree certified engineers can edit admins od devices.', UNIX_TIMESTAMP());",
|
||
|
||
"INSERT INTO `aco_map` (`acl_id`, `section_value`, `value`) VALUES
|
||
(69, 'freenetis', 'delete_all'),
|
||
(69, 'freenetis', 'edit_all'),
|
||
(69, 'freenetis', 'new_all'),
|
||
(69, 'freenetis', 'view_all');",
|
||
|
||
"INSERT INTO `aro_groups_map` (`acl_id`, `group_id`) VALUES ('69', '37');",
|
||
|
||
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES ('69', 'Devices_Controller', 'admin');",
|
||
|
||
"INSERT INTO `acl` (`id`, `section_value`, `allow`, `enabled`, `return_value`, `note`, `updated_date`) VALUES ('70', 'user', '1', '1', '', 'Fifth-degress certified engineers can view logins and passwords of devices.', UNIX_TIMESTAMP());",
|
||
|
||
"INSERT INTO `aco_map` (`acl_id`, `section_value`, `value`) VALUES ('70', 'freenetis', 'view_all');",
|
||
|
||
"INSERT INTO `aro_groups_map` (`acl_id`, `group_id`) VALUES ('70', '38');",
|
||
|
||
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES
|
||
(70, 'Devices_Controller', 'login'),
|
||
(70, 'Devices_Controller', 'password');",
|
||
|
||
"INSERT INTO `acl` (`id`, `section_value`, `allow`, `enabled`, `return_value`, `note`, `updated_date`) VALUES ('71', 'user', '1', '1', '', 'Sixth-degrees certified engineers can add and edit logins and passwords of devices.', UNIX_TIMESTAMP('0'));",
|
||
|
||
"INSERT INTO `aco_map` (`acl_id`, `section_value`, `value`) VALUES
|
||
(71, 'freenetis', 'delete_all'),
|
||
(71, 'freenetis', 'edit_all'),
|
||
(71, 'freenetis', 'new_all'),
|
||
(71, 'freenetis', 'view_all');",
|
||
|
||
"INSERT INTO `aro_groups_map` (`acl_id`, `group_id`) VALUES ('71', '39');",
|
||
|
||
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES
|
||
(71, 'Devices_Controller', 'login'),
|
||
(71, 'Devices_Controller', 'password');",
|
||
|
||
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES
|
||
(38, 'Devices_Controller', 'login'),
|
||
(38, 'Devices_Controller', 'password');"
|
||
"CREATE TABLE `smokepings` (
|
||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||
`menu` VARCHAR(50) NOT NULL,
|
||
`title` VARCHAR(50) NOT NULL,
|
||
`parent` INTEGER UNSIGNED NOT NULL,
|
||
`device` BOOLEAN NOT NULL,
|
||
`ip_address_id` INTEGER UNSIGNED,
|
||
`outter_address_id` INTEGER UNSIGNED,
|
||
PRIMARY KEY (`id`)
|
||
)
|
||
ENGINE = InnoDB
|
||
CHARACTER SET utf8 COLLATE utf8_general_ci;"
|
||
);
|
||
?>
|
Také k dispozici: Unified diff
Opraveno generovani DHCP, DNS a MAC restrikce
Opraveno generovani konfiguracniho souboru pro smokeping
Uprava databaze - po pridani zaznamu pro smokeping se zkontroluje DB ip adres a v pripade shody se prideli do DB smokepingu pouze ID zaznamu ip adresy,
lze ale pridavat i externi adresy, ktere se ukladaji v outter_addresses table
Jeste zbyva opravit vkladani zaznamu pro smokeping primo z menu ip adresy.