From 8b190227446b53dc4bf4ded763ee4e0c51160f26 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 6 Apr 2015 09:23:13 +0100 Subject: [PATCH 01/10] Initial setup of callback --- callback.php | 101 +++++++++++++++++++++++++++++++++++++++++++++ sql-schema/046.sql | 1 + 2 files changed, 102 insertions(+) create mode 100644 callback.php create mode 100644 sql-schema/046.sql diff --git a/callback.php b/callback.php new file mode 100644 index 0000000000..27bc2b0358 --- /dev/null +++ b/callback.php @@ -0,0 +1,101 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +include_once("includes/defaults.inc.php"); +include_once("config.php"); +include_once($config['install_dir']."/includes/definitions.inc.php"); +include_once($config['install_dir']."/includes/functions.php"); +include_once($config['install_dir']."/includes/alerts.inc.php"); + +if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'") == '') { + dbInsert(array('name'=>'uuid','value'=>uniqid()),'callback'); +} + +$uuid = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'"); + +if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'") == 1) { + + $queries = array( + 'alert_rules'=>'SELECT COUNT(`severity`) AS `total`,`severity` FROM `alert_rules` WHERE `disabled`=0 GROUP BY `severity`', + 'alert_templates'=>'SELECT COUNT(`id`) AS `total` FROM `alert_templates`', + 'api_tokens'=>'SELECT COUNT(`id`) AS `total` FROM `api_tokens` WHERE `disabled`=0', + 'applications'=>'SELECT COUNT(`app_type`) AS `total`,`app_type` FROM `applications` GROUP BY `app_type`', + 'bgppeer_state'=>'SELECT COUNT(`bgpPeerState`) AS `total`,`bgpPeerState` FROM `bgpPeers` GROUP BY `bgpPeerState`', + 'bgppeer_status'=>'SELECT COUNT(`bgpPeerAdminStatus`) AS `total`,`bgpPeerAdminStatus` FROM `bgpPeers` GROUP BY `bgpPeerAdminStatus`', + 'bills'=>'SELECT COUNT(`bill_type`) AS `total`,`bill_type` FROM `bills` GROUP BY `bill_type`', + 'bill_ports'=>'SELECT COUNT(`bill_id`) AS `total`,`bill_id`,COUNT(`port_id`) AS `total` FROM `bill_ports` GROUP BY `bill_id`', + 'cef'=>'SELECT COUNT(`device_id`) AS `total` FROM `cef_switching`', + 'cisco_asa'=>'SELECT COUNT(`oid`) AS `total`,`oid` FROM `ciscoASA` WHERE `disabled` = 0 GROUP BY `oid`', + 'mempool'=>'SELECT COUNT(`cmpName`) AS `total`,`cmpName` FROM `cmpMemPool` GROUP BY `cmpName`', + 'current'=>'SELECT COUNT(`current_type`) AS `total`,`current_type` FROM `current` GROUP BY `current_type`', + 'dbschema'=>'SELECT `version` FROM `dbSchema`', + 'graph_types'=>'SELECT COUNT(`device_id`) AS `total`,`graph` FROM `device_graphs` GROUP BY `graph`', + 'snmp_version'=>'SELECT COUNT(`snmpver`) AS `total`,`snmpver` FROM `devices` GROUP BY `snmpver`', + 'os'=>'SELECT COUNT(`os`) AS `total`,`os` FROM `devices` GROUP BY `os`', + 'type'=>'SELECT COUNT(`type`) AS `total`,`type` FROM `devices` GROUP BY `type`', + 'full_type'=>'SELECT COUNT(`device_id`) AS `total`, CONCAT_WS(', ', `os`,`hardware`,`type`) FROM `devices` GROUP BY `os`,`hardware`,`type`', + 'device_attribs'=>'SELECT COUNT(`attrib_type`) AS `total`,`attrib_type` FROM `devices_attribs` GROUP BY `attrib_type`', + 'inventory'=>'SELECT COUNT(`device_id`) AS `total`,`entPhysicalClass` FROM `entPhysical` GROUP BY `entPhysicalClass`', + 'hrdevice'=>'SELECT COUNT(`device_id`) AS `total`,`hrDeviceType` FROM hrDevice GROUP BY `hrDeviceType`', + 'ipsec'=>'SELECT COUNT(`device_id`) AS `total` FROM `ipsec_tunnels`', + 'ipv4_addresses'=>'SELECT COUNT(`ipv4_address_id`) AS `total` FROM `ipv4_addresses`', + 'ipv4_macaddress'=>'SELECT COUNT(`port_id`) AS `total` FROM ipv4_mac', + 'ipv4_networks'=>'SELECT COUNT(`ipv4_network_id`) AS `total` FROM ipv4_networks', + 'ipv6_addresses'=>'SELECT COUNT(`ipv6_address_id`) AS `total` FROM `ipv6_addresses`', + 'ipv6_networks'=>'SELECT COUNT(`ipv6_network_id`) AS `total` FROM `ipv6_networks`', + 'xdp'=>'SELECT COUNT(`id`) AS `total`,`protocol` FROM `links` GROUP BY `protocol`', + 'mempools'=>'SELECT COUNT(`mempool_id`) AS `total`,`mempool_descr` FROM `mempools` GROUP BY `mempool_descr`', + 'ospf'=>'SELECT COUNT(`device_id`) AS `total`,`ospfVersionNumber` FROM `ospf_instances` GROUP BY `ospfVersionNumber`', + 'ospf_links'=>'SELECT COUNT(`device_id`) AS `total`,`ospfIfType` FROM `ospf_ports` GROUP BY `ospfIfType`', + 'arch'=>'SELECT COUNT(`pkg_id`) AS `total`,`arch` FROM `packages` GROUP BY `arch`', + 'pollers'=>'SELECT COUNT(`id`) AS `total` FROM `pollers`', + 'port_type'=>'SELECT COUNT(`port_id`) AS `total`,`ifType` FROM `ports` GROUP BY `ifType`', + 'port_ifspeed'=>'SELECT COUNT(`ifSpeed`) AS `total`,`ifSpeed` FROM `ports` GROUP BY `ifSpeed`', + 'port_vlans'=>'SELECT COUNT(`device_id`) AS `total`,`state` FROM `ports_vlans` GROUP BY `state`', + 'processes'=>'SELECT COUNT(`device_id`) AS `total` FROM `processes`', + 'processors'=>'SELECT COUNT(`processor_id`) AS `total`,`processor_type` FROM `processors` GROUP BY `processor_type`', + 'pseudowires'=>'SELECT COUNT(`pseudowire_id`) AS `total` FROM `pseudowires`', + 'sensors'=>'SELECT COUNT(`sensor_id`) AS `total`,`sensor_class` FROM `sensors` GROUP BY `sensor_class`', + 'services'=>'SELECT COUNT(`service_id`) AS `total`,`service_type` FROM `services` GROUP BY `service_type`', + 'storage'=>'SELECT COUNT(`storage_id`) AS `total`,`storage_type` FROM `storage` GROUP BY `storage_type`', + 'toner'=>'SELECT COUNT(`toner_id`) AS `total`,`toner_type` FROM `toner` GROUP BY `toner_type`', + 'vlans'=>'SELECT COUNT(`vlan_id`) AS `total`,`vlan_type` FROM `vlans` GROUP BY `vlan_type`', + 'vminfo'=>'SELECT COUNT(`id`) AS `total`,`vm_type` FROM `vminfo` GROUP BY `vm_type`', + 'vmware'=>'SELECT COUNT(`id`) AS `total` FROM `vmware_vminfo`', + 'vrfs'=>'SELECT COUNT(`vrf_id`) AS `total` FROM `vrfs`'); + + + foreach ($queries as $name => $query) { + $data = dbFetchRows($query); + $response[$name] = $data; + } + $output = array('uuid'=>$uuid,'data'=>$response); + $data = json_encode($output); + $submit = array('data'=>$data); + + $fields = ''; + foreach($submit as $key => $value) { + $fields .= $key . '=' . $value . '&'; + } + rtrim($fields, '&'); + + $post = curl_init(); + curl_setopt($post, CURLOPT_URL, 'http://lathwood.co.uk/log/log.php'); + curl_setopt($post, CURLOPT_POST, count($submit)); + curl_setopt($post, CURLOPT_POSTFIELDS, $fields); + curl_setopt($post, CURLOPT_RETURNTRANSFER, 1); + $result = curl_exec($post); +} + +?> diff --git a/sql-schema/046.sql b/sql-schema/046.sql new file mode 100644 index 0000000000..9e7aaa2d76 --- /dev/null +++ b/sql-schema/046.sql @@ -0,0 +1 @@ +CREATE TABLE `librenms`.`callback` ( `callback_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` CHAR( 64 ) NOT NULL , `value` CHAR( 64 ) NOT NULL ) ENGINE = INNODB; From 1d608dbdb6a09f31f01a9b9925b73a103f3391a8 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 6 Apr 2015 20:41:50 +0100 Subject: [PATCH 02/10] Callback system done - hopefully --- callback.php | 34 ++++++++++------- html/forms/callback-clear.inc.php | 15 ++++++++ html/forms/callback-statistics.inc.php | 23 ++++++++++++ html/pages/about.inc.php | 52 ++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 html/forms/callback-clear.inc.php create mode 100644 html/forms/callback-statistics.inc.php diff --git a/callback.php b/callback.php index 27bc2b0358..b2c11f4664 100644 --- a/callback.php +++ b/callback.php @@ -18,13 +18,13 @@ include_once($config['install_dir']."/includes/definitions.inc.php"); include_once($config['install_dir']."/includes/functions.php"); include_once($config['install_dir']."/includes/alerts.inc.php"); -if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'") == '') { - dbInsert(array('name'=>'uuid','value'=>uniqid()),'callback'); -} +$enabled = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'"); +if ($enabled == 1) { -$uuid = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'"); - -if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'") == 1) { + if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'") == '') { + dbInsert(array('name'=>'uuid','value'=>uniqid()),'callback'); + } + $uuid = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'"); $queries = array( 'alert_rules'=>'SELECT COUNT(`severity`) AS `total`,`severity` FROM `alert_rules` WHERE `disabled`=0 GROUP BY `severity`', @@ -34,20 +34,15 @@ if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'") == 1) 'bgppeer_state'=>'SELECT COUNT(`bgpPeerState`) AS `total`,`bgpPeerState` FROM `bgpPeers` GROUP BY `bgpPeerState`', 'bgppeer_status'=>'SELECT COUNT(`bgpPeerAdminStatus`) AS `total`,`bgpPeerAdminStatus` FROM `bgpPeers` GROUP BY `bgpPeerAdminStatus`', 'bills'=>'SELECT COUNT(`bill_type`) AS `total`,`bill_type` FROM `bills` GROUP BY `bill_type`', - 'bill_ports'=>'SELECT COUNT(`bill_id`) AS `total`,`bill_id`,COUNT(`port_id`) AS `total` FROM `bill_ports` GROUP BY `bill_id`', 'cef'=>'SELECT COUNT(`device_id`) AS `total` FROM `cef_switching`', 'cisco_asa'=>'SELECT COUNT(`oid`) AS `total`,`oid` FROM `ciscoASA` WHERE `disabled` = 0 GROUP BY `oid`', 'mempool'=>'SELECT COUNT(`cmpName`) AS `total`,`cmpName` FROM `cmpMemPool` GROUP BY `cmpName`', 'current'=>'SELECT COUNT(`current_type`) AS `total`,`current_type` FROM `current` GROUP BY `current_type`', - 'dbschema'=>'SELECT `version` FROM `dbSchema`', - 'graph_types'=>'SELECT COUNT(`device_id`) AS `total`,`graph` FROM `device_graphs` GROUP BY `graph`', + 'dbschema'=>'SELECT COUNT(`version`) AS `total`, `version` FROM `dbSchema`', 'snmp_version'=>'SELECT COUNT(`snmpver`) AS `total`,`snmpver` FROM `devices` GROUP BY `snmpver`', 'os'=>'SELECT COUNT(`os`) AS `total`,`os` FROM `devices` GROUP BY `os`', 'type'=>'SELECT COUNT(`type`) AS `total`,`type` FROM `devices` GROUP BY `type`', 'full_type'=>'SELECT COUNT(`device_id`) AS `total`, CONCAT_WS(', ', `os`,`hardware`,`type`) FROM `devices` GROUP BY `os`,`hardware`,`type`', - 'device_attribs'=>'SELECT COUNT(`attrib_type`) AS `total`,`attrib_type` FROM `devices_attribs` GROUP BY `attrib_type`', - 'inventory'=>'SELECT COUNT(`device_id`) AS `total`,`entPhysicalClass` FROM `entPhysical` GROUP BY `entPhysicalClass`', - 'hrdevice'=>'SELECT COUNT(`device_id`) AS `total`,`hrDeviceType` FROM hrDevice GROUP BY `hrDeviceType`', 'ipsec'=>'SELECT COUNT(`device_id`) AS `total` FROM `ipsec_tunnels`', 'ipv4_addresses'=>'SELECT COUNT(`ipv4_address_id`) AS `total` FROM `ipv4_addresses`', 'ipv4_macaddress'=>'SELECT COUNT(`port_id`) AS `total` FROM ipv4_mac', @@ -55,7 +50,6 @@ if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'") == 1) 'ipv6_addresses'=>'SELECT COUNT(`ipv6_address_id`) AS `total` FROM `ipv6_addresses`', 'ipv6_networks'=>'SELECT COUNT(`ipv6_network_id`) AS `total` FROM `ipv6_networks`', 'xdp'=>'SELECT COUNT(`id`) AS `total`,`protocol` FROM `links` GROUP BY `protocol`', - 'mempools'=>'SELECT COUNT(`mempool_id`) AS `total`,`mempool_descr` FROM `mempools` GROUP BY `mempool_descr`', 'ospf'=>'SELECT COUNT(`device_id`) AS `total`,`ospfVersionNumber` FROM `ospf_instances` GROUP BY `ospfVersionNumber`', 'ospf_links'=>'SELECT COUNT(`device_id`) AS `total`,`ospfIfType` FROM `ospf_ports` GROUP BY `ospfIfType`', 'arch'=>'SELECT COUNT(`pkg_id`) AS `total`,`arch` FROM `packages` GROUP BY `arch`', @@ -67,7 +61,6 @@ if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'") == 1) 'processors'=>'SELECT COUNT(`processor_id`) AS `total`,`processor_type` FROM `processors` GROUP BY `processor_type`', 'pseudowires'=>'SELECT COUNT(`pseudowire_id`) AS `total` FROM `pseudowires`', 'sensors'=>'SELECT COUNT(`sensor_id`) AS `total`,`sensor_class` FROM `sensors` GROUP BY `sensor_class`', - 'services'=>'SELECT COUNT(`service_id`) AS `total`,`service_type` FROM `services` GROUP BY `service_type`', 'storage'=>'SELECT COUNT(`storage_id`) AS `total`,`storage_type` FROM `storage` GROUP BY `storage_type`', 'toner'=>'SELECT COUNT(`toner_id`) AS `total`,`toner_type` FROM `toner` GROUP BY `toner_type`', 'vlans'=>'SELECT COUNT(`vlan_id`) AS `total`,`vlan_type` FROM `vlans` GROUP BY `vlan_type`', @@ -96,6 +89,19 @@ if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'") == 1) curl_setopt($post, CURLOPT_POSTFIELDS, $fields); curl_setopt($post, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($post); +} elseif ($enabled == 2) { + + $uuid = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'"); + $fields = "uuid=$uuid"; + + $clear = curl_init(); + curl_setopt($clear, CURLOPT_URL, 'http://lathwood.co.uk/log/clear.php'); + curl_setopt($clear, CURLOPT_POST, count($clear)); + curl_setopt($clear, CURLOPT_POSTFIELDS, $fields); + curl_setopt($clear, CURLOPT_RETURNTRANSFER, 1); + $result = curl_exec($clear); + dbDelete('callback','`name`="uuid"',array()); + dbUpdate(array('value' => '0'), 'callback', '`name` = "enabled"', array()); } ?> diff --git a/html/forms/callback-clear.inc.php b/html/forms/callback-clear.inc.php new file mode 100644 index 0000000000..236c28c90d --- /dev/null +++ b/html/forms/callback-clear.inc.php @@ -0,0 +1,15 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +dbUpdate(array('value' => '2'), 'callback', '`name` = "enabled"', array()); diff --git a/html/forms/callback-statistics.inc.php b/html/forms/callback-statistics.inc.php new file mode 100644 index 0000000000..fb01583573 --- /dev/null +++ b/html/forms/callback-statistics.inc.php @@ -0,0 +1,23 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($_POST['state'] == 'true') { + $state = 1; +} elseif ($_POST['state'] == 'false') { + $state = 0; +} else { + $state = 0; +} + +dbUpdate(array('value' => $state), 'callback', '`name` = "enabled"', array()); diff --git a/html/pages/about.inc.php b/html/pages/about.inc.php index 5bd15bbf4f..994e436d34 100644 --- a/html/pages/about.inc.php +++ b/html/pages/about.inc.php @@ -67,10 +67,30 @@ $stat_pw = dbFetchCell("SELECT COUNT(pseudowire_id) FROM `pseudowires`"); $stat_vrf = dbFetchCell("SELECT COUNT(vrf_id) FROM `vrfs`"); $stat_vlans = dbFetchCell("SELECT COUNT(vlan_id) FROM `vlans`"); +$callback_status = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'"); +if ($callback_status == 1) { + $stats_checked = 'checked'; +} else { + $stats_checked = ''; +} +$callback = 'Opt in to send anonymous usage statistics to LibreNMS? '; + echo("
+ + "); + +if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'") != '' && $callback_status != 2) { + echo(" + + + + "); +} + +echo(" @@ -175,3 +195,35 @@ echo(" + + From 7a302c2763229a06041934e9dd51c0ac8a58eb7a Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 6 Apr 2015 20:47:28 +0100 Subject: [PATCH 03/10] Some last minute changes --- callback.php | 10 ++-------- daily.php | 3 +++ daily.sh | 1 + includes/defaults.inc.php | 4 ++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/callback.php b/callback.php index b2c11f4664..20e2c60ee7 100644 --- a/callback.php +++ b/callback.php @@ -12,12 +12,6 @@ * the source code distribution for details. */ -include_once("includes/defaults.inc.php"); -include_once("config.php"); -include_once($config['install_dir']."/includes/definitions.inc.php"); -include_once($config['install_dir']."/includes/functions.php"); -include_once($config['install_dir']."/includes/alerts.inc.php"); - $enabled = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'"); if ($enabled == 1) { @@ -84,7 +78,7 @@ if ($enabled == 1) { rtrim($fields, '&'); $post = curl_init(); - curl_setopt($post, CURLOPT_URL, 'http://lathwood.co.uk/log/log.php'); + curl_setopt($post, CURLOPT_URL, $config['callback_post']); curl_setopt($post, CURLOPT_POST, count($submit)); curl_setopt($post, CURLOPT_POSTFIELDS, $fields); curl_setopt($post, CURLOPT_RETURNTRANSFER, 1); @@ -95,7 +89,7 @@ if ($enabled == 1) { $fields = "uuid=$uuid"; $clear = curl_init(); - curl_setopt($clear, CURLOPT_URL, 'http://lathwood.co.uk/log/clear.php'); + curl_setopt($clear, CURLOPT_URL, $config['callback_clear']); curl_setopt($clear, CURLOPT_POST, count($clear)); curl_setopt($clear, CURLOPT_POSTFIELDS, $fields); curl_setopt($clear, CURLOPT_RETURNTRANSFER, 1); diff --git a/daily.php b/daily.php index 38ac1584ef..03176a47d3 100644 --- a/daily.php +++ b/daily.php @@ -55,5 +55,8 @@ if ($options['f'] === 'perf_times') { } } } +if ($options['f'] === 'callback') { + require_once "callback.php"; +} ?> diff --git a/daily.sh b/daily.sh index ca8c87077a..4168d73448 100644 --- a/daily.sh +++ b/daily.sh @@ -11,3 +11,4 @@ php daily.php -f syslog php daily.php -f eventlog php daily.php -f authlog php daily.php -f perf_times +php daily.php -f callback diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 796c15a8da..ed0b2569af 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -599,4 +599,8 @@ $config['distributed_poller_group'] = 0; $config['distributed_poller_memcached_host'] = 'example.net'; $config['distributed_poller_memcached_port'] = '11211'; +// Stats callback system +$config['callback_post'] = 'http://lathwood.co.uk/log/log.php'; +$config['callback_clear'] = 'http://lathwood.co.uk/log/clear.php'; + ?> From cb2b782824a7e059499eef86b00e5cf5665a2dfe Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 8 Apr 2015 11:10:06 +0100 Subject: [PATCH 04/10] Updated sql statements --- html/forms/callback-statistics.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/html/forms/callback-statistics.inc.php b/html/forms/callback-statistics.inc.php index fb01583573..22f65e71d1 100644 --- a/html/forms/callback-statistics.inc.php +++ b/html/forms/callback-statistics.inc.php @@ -20,4 +20,6 @@ if ($_POST['state'] == 'true') { $state = 0; } -dbUpdate(array('value' => $state), 'callback', '`name` = "enabled"', array()); +if( dbUpdate(array('value' => $state), 'callback', '`name` = "enabled"', array()) == 0) { + dbInsert(array('value' => $state,'name' => 'enabled'), 'callback'); +} From bd10fd7c7d298aca42f1c904970cf7a7146c3711 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 8 Apr 2015 11:12:08 +0100 Subject: [PATCH 05/10] Updated install docs --- doc/Installation/Installation-(Debian-Ubuntu).md | 2 +- doc/Installation/Installation-(RHEL-CentOS).md | 2 +- doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/Installation/Installation-(Debian-Ubuntu).md b/doc/Installation/Installation-(Debian-Ubuntu).md index f4789c68f7..e05bd87d7a 100644 --- a/doc/Installation/Installation-(Debian-Ubuntu).md +++ b/doc/Installation/Installation-(Debian-Ubuntu).md @@ -42,7 +42,7 @@ This host is where the web server and SNMP poller run. It could be the same mac Install the required software: - apt-get install libapache2-mod-php5 php5-cli php5-mysql php5-gd php5-snmp php-pear snmp graphviz php5-mcrypt php5-json apache2 fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd mysql-client php-net-ipv4 php-net-ipv6 rrdtool git + apt-get install libapache2-mod-php5 php5-cli php5-mysql php5-gd php5-snmp php5-pear php5-curl snmp graphviz php5-mcrypt php5-json apache2 fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd mysql-client php-net-ipv4 php-net-ipv6 rrdtool git The packages listed above are an all-inclusive list of packages that were necessary on a clean install of Ubuntu 12.04/14.04. diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index 2f1db49af6..7dd8d26a06 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -47,7 +47,7 @@ Install necessary software. The packages listed below are an all-inclusive list Note if not using HTTPd (Apache): RHEL requires `httpd` to be installed regardless of of `nginx`'s (or any other web-server's) presence. rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm - yum install php php-cli php-gd php-mysql php-snmp php-pear httpd net-snmp graphviz graphviz-php mysql ImageMagick jwhois nmap mtr rrdtool MySQL-python net-snmp-utils vixie-cron php-mcrypt fping git + yum install php php-cli php-gd php-mysql php-snmp php-pear php-curl httpd net-snmp graphviz graphviz-php mysql ImageMagick jwhois nmap mtr rrdtool MySQL-python net-snmp-utils vixie-cron php-mcrypt fping git pear install Net_IPv4-1.3.4 pear install Net_IPv6-1.2.2b2 diff --git a/doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md b/doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md index 6fb61aacfd..fb338cb2ee 100644 --- a/doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md +++ b/doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md @@ -37,7 +37,7 @@ Change `127.0.0.1` to the IP address that your MySQL server should listen on. R Install necessary software. The packages listed below are an all-inclusive list of packages that were necessary on a clean install of Debian 7. - apt-get install lighttpd php5-cli php5-mysql php5-gd php5-snmp php5-cgi php-pear snmp graphviz mysql-server mysql-client rrdtool sendmail fping imagemagick whois mtr-tiny nmap ipmitool php5-mcrypt php5-json python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git + apt-get install lighttpd php5-cli php5-mysql php5-gd php5-snmp php5-cgi php5-pear php5-curl snmp graphviz mysql-server mysql-client rrdtool sendmail fping imagemagick whois mtr-tiny nmap ipmitool php5-mcrypt php5-json python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git ### Cloning ### From 44fb0c16f93b4c0d3025b4c98812a5ed603d8d84 Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 9 Apr 2015 20:32:31 +0100 Subject: [PATCH 06/10] Updated ifSpeed --- callback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callback.php b/callback.php index 20e2c60ee7..aaf56f089f 100644 --- a/callback.php +++ b/callback.php @@ -49,7 +49,7 @@ if ($enabled == 1) { 'arch'=>'SELECT COUNT(`pkg_id`) AS `total`,`arch` FROM `packages` GROUP BY `arch`', 'pollers'=>'SELECT COUNT(`id`) AS `total` FROM `pollers`', 'port_type'=>'SELECT COUNT(`port_id`) AS `total`,`ifType` FROM `ports` GROUP BY `ifType`', - 'port_ifspeed'=>'SELECT COUNT(`ifSpeed`) AS `total`,`ifSpeed` FROM `ports` GROUP BY `ifSpeed`', + 'port_ifspeed'=>'SELECT COUNT(`ifSpeed`) AS `total`,ROUND(`ifSpeed`/1000/1000) FROM `ports` GROUP BY `ifSpeed`', 'port_vlans'=>'SELECT COUNT(`device_id`) AS `total`,`state` FROM `ports_vlans` GROUP BY `state`', 'processes'=>'SELECT COUNT(`device_id`) AS `total` FROM `processes`', 'processors'=>'SELECT COUNT(`processor_id`) AS `total`,`processor_type` FROM `processors` GROUP BY `processor_type`', From c268bc733e456b22bf093867fe115c8dd9ba0e15 Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 9 Apr 2015 22:59:17 +0100 Subject: [PATCH 07/10] Added doc on stats use and privacy --- doc/General/Callback-Stats-and-Privacy.md | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 doc/General/Callback-Stats-and-Privacy.md diff --git a/doc/General/Callback-Stats-and-Privacy.md b/doc/General/Callback-Stats-and-Privacy.md new file mode 100644 index 0000000000..ef3b88435e --- /dev/null +++ b/doc/General/Callback-Stats-and-Privacy.md @@ -0,0 +1,30 @@ +## Stats data and your privacy ## + +This document has been put together to explain what LibreNMS does when it calls back home to report some anonymous statistics. + +Let's start off by saying, all of the code that processes the data and submits it is included in the standard LibreNMS branch you've installed, the code that accepts this data and in turn generates some pretty graphs is all open source and available on Git Hub. Please feel free to review the code, comment on it and suggest changes / improvements. Also, don't forget - by default installations DO NOT call back home, you need to opt into this. + +Now onto the bit you're interested in, what is submitted and what we do with that data. + +#### What is submitted #### +- All data is anonymous. +- Generic statistics are taken from the database, these include things like device total, type and os, port types, speeds and total, total bgp peers. Take a look at the code for full details. +- A random UUID is generated on your own install. +- That's it! +- Your IP isn't logged, even via our web service accepting the data. We don't need to know who you are so don't ask. + +#### What we do with the data #### +- We store it, not for long - 3 months at the moment although this could change. +- We use it to generate pretty graphs for people to see. +- We use it to help prioritise issues and features that need to be worked on. + +#### Questions? #### +- Q. How often is data submitted? A. We submit the data once a day according to running daily.sh via cron. If you disable this then opting in will not have any affect. +- Q. Where can I see the data I submitted? A. You can't see the data raw, but we collate all of the data together and provide a dynamic site so you can see the results of all contributed stats [here](https://stats.librenms.org) +- Q. I want my data removed. A. That's easy, simply press 'Clear remote stats' in the About LibreNMS page of your control panel, the next time the call back script is run it will remove all the data we have. +- Q. I clicked the 'Clear remote stats' button by accident. A. No problem, before daily.sh runs again - just opt back in, all of your existing data will stay. + +Hopefully this answers the questions you might have on why and what we are doing here, if not, please pop into our irc channel or google mailing list and ask any questions you like. + +If you're happy with all of this - please consider switching the call back system on, you can do this within the About LibreNMS page within your control panel. In the Statistics section you will find a toggle switch to enable / disable the feature. If you've previously had it switched on and want to opt out and remove your data, click the 'Clear remote stats' button and on the next submission all the data you've sent us will be removed! + From 3dd23e378120897e5a33d5cafb2092e6bbfe707b Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 9 Apr 2015 22:59:52 +0100 Subject: [PATCH 08/10] Small update --- doc/General/Callback-Stats-and-Privacy.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/General/Callback-Stats-and-Privacy.md b/doc/General/Callback-Stats-and-Privacy.md index ef3b88435e..e0d32c7a78 100644 --- a/doc/General/Callback-Stats-and-Privacy.md +++ b/doc/General/Callback-Stats-and-Privacy.md @@ -4,6 +4,8 @@ This document has been put together to explain what LibreNMS does when it calls Let's start off by saying, all of the code that processes the data and submits it is included in the standard LibreNMS branch you've installed, the code that accepts this data and in turn generates some pretty graphs is all open source and available on Git Hub. Please feel free to review the code, comment on it and suggest changes / improvements. Also, don't forget - by default installations DO NOT call back home, you need to opt into this. +Above all we respect users privacy which is why this system has been designed like it has. + Now onto the bit you're interested in, what is submitted and what we do with that data. #### What is submitted #### From 162775f3f438403a996a25a3ae9b5e975820516f Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 10 Apr 2015 17:00:32 +0100 Subject: [PATCH 09/10] Updated docs, updated callback to use new guidv4 function and links to stats url --- callback.php | 2 +- doc/Installation/Installation-(Debian-Ubuntu).md | 2 +- .../Installation-Lighttpd-(Debian-Ubuntu).md | 2 +- includes/defaults.inc.php | 4 ++-- includes/functions.php | 11 +++++++++++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/callback.php b/callback.php index aaf56f089f..939ec93835 100644 --- a/callback.php +++ b/callback.php @@ -16,7 +16,7 @@ $enabled = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'" if ($enabled == 1) { if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'") == '') { - dbInsert(array('name'=>'uuid','value'=>uniqid()),'callback'); + dbInsert(array('name'=>'uuid','value'=>guidv4()),'callback'); } $uuid = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'"); diff --git a/doc/Installation/Installation-(Debian-Ubuntu).md b/doc/Installation/Installation-(Debian-Ubuntu).md index e05bd87d7a..5810b271ea 100644 --- a/doc/Installation/Installation-(Debian-Ubuntu).md +++ b/doc/Installation/Installation-(Debian-Ubuntu).md @@ -42,7 +42,7 @@ This host is where the web server and SNMP poller run. It could be the same mac Install the required software: - apt-get install libapache2-mod-php5 php5-cli php5-mysql php5-gd php5-snmp php5-pear php5-curl snmp graphviz php5-mcrypt php5-json apache2 fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd mysql-client php-net-ipv4 php-net-ipv6 rrdtool git + apt-get install libapache2-mod-php5 php5-cli php5-mysql php5-gd php5-snmp php-pear php5-curl snmp graphviz php5-mcrypt php5-json apache2 fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd mysql-client php-net-ipv4 php-net-ipv6 rrdtool git The packages listed above are an all-inclusive list of packages that were necessary on a clean install of Ubuntu 12.04/14.04. diff --git a/doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md b/doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md index fb338cb2ee..a39f6d43b6 100644 --- a/doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md +++ b/doc/Installation/Installation-Lighttpd-(Debian-Ubuntu).md @@ -37,7 +37,7 @@ Change `127.0.0.1` to the IP address that your MySQL server should listen on. R Install necessary software. The packages listed below are an all-inclusive list of packages that were necessary on a clean install of Debian 7. - apt-get install lighttpd php5-cli php5-mysql php5-gd php5-snmp php5-cgi php5-pear php5-curl snmp graphviz mysql-server mysql-client rrdtool sendmail fping imagemagick whois mtr-tiny nmap ipmitool php5-mcrypt php5-json python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git + apt-get install lighttpd php5-cli php5-mysql php5-gd php5-snmp php5-cgi php-pear php5-curl snmp graphviz mysql-server mysql-client rrdtool sendmail fping imagemagick whois mtr-tiny nmap ipmitool php5-mcrypt php5-json python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git ### Cloning ### diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index ed0b2569af..7cee0e712b 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -600,7 +600,7 @@ $config['distributed_poller_memcached_host'] = 'example.net'; $config['distributed_poller_memcached_port'] = '11211'; // Stats callback system -$config['callback_post'] = 'http://lathwood.co.uk/log/log.php'; -$config['callback_clear'] = 'http://lathwood.co.uk/log/clear.php'; +$config['callback_post'] = 'https://stats.librenms.org/log.php'; +$config['callback_clear'] = 'https://stats.librenms.org/clear.php'; ?> diff --git a/includes/functions.php b/includes/functions.php index e3905e3119..5865dc3a79 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -1129,4 +1129,15 @@ function convert_delay($delay) { return($delay_sec); } +function guidv4($data) { + // http://stackoverflow.com/questions/2040240/php-function-to-generate-v4-uuid#15875555 + // From: Jack http://stackoverflow.com/users/1338292/ja%CD%A2ck + assert(strlen($data) == 16); + + $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 + $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 + + return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); +} + ?> From 0db0dd3cdb625be0cd485e9bfe3ec9b11cfa42cb Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 10 Apr 2015 21:27:40 +0100 Subject: [PATCH 10/10] Enabled guidv4! --- callback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callback.php b/callback.php index 939ec93835..bbfe57260b 100644 --- a/callback.php +++ b/callback.php @@ -16,7 +16,7 @@ $enabled = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'" if ($enabled == 1) { if (dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'") == '') { - dbInsert(array('name'=>'uuid','value'=>guidv4()),'callback'); + dbInsert(array('name'=>'uuid','value'=>guidv4(openssl_random_pseudo_bytes(16))),'callback'); } $uuid = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'uuid'");
$callback
Devices$stat_devices Ports$stat_ports