mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
added 'Opt-in' for statistics
git-svn-id: https://svn.fhem.de/fhem/trunk@2574 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7b4a45da7b
commit
4366a677b2
@ -68,7 +68,10 @@ CommandFheminfo($$)
|
||||
return $err;
|
||||
}
|
||||
|
||||
return "Unknown argument $args[0], usage: fheminfo [send]" if(@args && lc($args[0]) ne "send");
|
||||
return "Unknown argument $args[0], usage: fheminfo [send]"
|
||||
if(@args && lc($args[0]) ne "send");
|
||||
return "Argument 'send' is not useful, if global attribute 'sendStatistics' is set to 'never'."
|
||||
if(@args && lc($args[0]) eq "send" && lc(AttrVal("global","sendStatistics",undef)) eq "never");
|
||||
|
||||
my $branch = $DISTRIB_BRANCH;
|
||||
my $release = $DISTRIB_RELEASE;
|
||||
@ -76,7 +79,7 @@ CommandFheminfo($$)
|
||||
my $arch = $Config{"archname"};
|
||||
my $perl = $^V;
|
||||
my $uniqueID = AttrVal("global","uniqueID",undef);
|
||||
my $sendStatistics = AttrVal("global","sendStatistics",1);
|
||||
my $sendStatistics = AttrVal("global","sendStatistics",undef);
|
||||
my $moddir = $attr{global}{modpath}."/FHEM";
|
||||
my $uidFile = $moddir."/FhemUtils/uniqueID";
|
||||
|
||||
@ -119,7 +122,6 @@ CommandFheminfo($$)
|
||||
}
|
||||
|
||||
$attr{global}{uniqueID} = $uidFile;
|
||||
$attr{global}{sendStatistics} = $sendStatistics;
|
||||
|
||||
my $ret = checkConfigFile($uidFile);
|
||||
|
||||
@ -202,6 +204,11 @@ CommandFheminfo($$)
|
||||
$str .= $modStr;
|
||||
}
|
||||
|
||||
my $transmitData = ($attr{global}{sendStatistics}) ? $attr{global}{sendStatistics} : "not set";
|
||||
$str .= "\n";
|
||||
$str .= "Transmitting this information during an update:\n";
|
||||
$str .= " $transmitData (Note: You can change this via the global attribute sendStatistics)\n";
|
||||
|
||||
$ret = $str;
|
||||
|
||||
if(@args != 0 && $args[0] eq "send") {
|
||||
@ -221,7 +228,7 @@ CommandFheminfo($$)
|
||||
chop($contModels);
|
||||
$req->content("uniqueID=$uniqueID&system=$contInfo&modules=$contModules&models=$contModels");
|
||||
}
|
||||
|
||||
|
||||
my $ua = LWP::UserAgent->new(
|
||||
agent => "Fhem/$release",
|
||||
timeout => 60);
|
||||
@ -328,7 +335,6 @@ sub checkConfigFile($) {
|
||||
push(@newConfig,$line);
|
||||
if($line =~ /modpath/ && $done == 0) {
|
||||
push(@newConfig,"attr global uniqueID $uidFile\n");
|
||||
push(@newConfig,"attr global sendStatistics 1\n");
|
||||
$done = 1;
|
||||
}
|
||||
}
|
||||
@ -343,7 +349,7 @@ sub checkConfigFile($) {
|
||||
print $fh $_;
|
||||
}
|
||||
close $fh;
|
||||
Log 1, "$name global attributes 'uniqueID' and 'sendStatistics' added to configfile $configFile";
|
||||
Log 1, "$name global attributes 'uniqueID' added to configfile $configFile";
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,9 +479,11 @@ sub checkModule($) {
|
||||
<li>sendStatistics<br>
|
||||
This attribute is used in conjunction with the <code>update</code> command.
|
||||
<br>
|
||||
<code>0</code>: prevents transmission of data during an update.
|
||||
<code>onUpdate</code>: transfer of data on every update (recommended setting).
|
||||
<br>
|
||||
<code>1</code>: transfer of data on every update. This is the default.
|
||||
<code>manually</code>: manually transfer of data via the <code>fheminfo send</code> command.
|
||||
<br>
|
||||
<code>never</code>: prevents transmission of data at anytime.
|
||||
</li>
|
||||
<br>
|
||||
</ul>
|
||||
@ -591,9 +599,11 @@ sub checkModule($) {
|
||||
<li>sendStatistics<br>
|
||||
Dieses Attribut wird in Verbindung mit dem <code>update</code> Befehl verwendet.
|
||||
<br>
|
||||
<code>0</code>: verhindert die Übertragung der Daten während eines Updates.
|
||||
<code>onUpdate</code>: Überträgt die Daten bei jedem Update (empfohlene Einstellung).
|
||||
<br>
|
||||
<code>1</code>: überträgt die Daten bei jedem Update. Dies ist die Standardeinstellung.
|
||||
<code>manually</code>: Manuelle Überträgung der Daten über <code>fheminfo send</code>.
|
||||
<br>
|
||||
<code>never</code>: Verhindert die Überträgung der Daten.
|
||||
</li>
|
||||
<br>
|
||||
</ul>
|
||||
|
@ -58,6 +58,19 @@ CommandUpdate($$)
|
||||
my $force = 0;
|
||||
my $ret = "";
|
||||
|
||||
# check for fheminfo settings
|
||||
my $sendStatistics = AttrVal("global","sendStatistics",undef);
|
||||
if(!defined($sendStatistics) ||
|
||||
( defined($sendStatistics) &&
|
||||
lc($sendStatistics) ne "onupdate" ||
|
||||
lc($sendStatistics) ne "manually" ||
|
||||
lc($sendStatistics) ne "never" )
|
||||
) {
|
||||
$ret = optInFhemInfo();
|
||||
Log 1,"update Action required: please run 'update viewAdvice'";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# split arguments
|
||||
my @args = split(/ +/,$param);
|
||||
|
||||
@ -83,6 +96,13 @@ CommandUpdate($$)
|
||||
$branch = "SVN" if ($BRANCH eq "DEVELOPMENT");
|
||||
$srcdir = $UPDATE{path}."/".lc($branch);
|
||||
|
||||
# check arguments for fheminfo advice
|
||||
if (defined($args[1]) && uc($args[1]) eq "VIEWADVICE") {
|
||||
$ret = optInFhemInfo();
|
||||
Log 1,"update Action required: please run 'update viewAdvice'";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# check arguments
|
||||
if (defined($args[1]) && $args[1] eq "?" ||
|
||||
(int(@args) > 3 && uc($args[1]) eq "HOUSEKEEPING") ||
|
||||
@ -124,6 +144,10 @@ CommandUpdate($$)
|
||||
$ret = "nothing to do..." if (!$ret);
|
||||
} else {
|
||||
$ret = update_DoUpdate($srcdir,$BRANCH,$update,$force,$cl);
|
||||
if(lc($sendStatistics) eq "onupdate") {
|
||||
$ret .= "\n\n";
|
||||
$ret .= CommandFheminfo(undef,"send");
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@ -881,6 +905,153 @@ update_MakeDirectory($)
|
||||
return $ret;
|
||||
}
|
||||
|
||||
########################################
|
||||
sub
|
||||
optInFhemInfo()
|
||||
{
|
||||
my $str;
|
||||
|
||||
my $str_DE=<<EndOfInfo;
|
||||
(English Translation: Please see below.)
|
||||
|
||||
HINWEIS:
|
||||
|
||||
Das FHEM-Projekt moechte Dich um Deine Unterstuetzung bitten!
|
||||
|
||||
Im Rahmen der Aktualisierung kann FHEM Informationen ueber diese Installation
|
||||
an einen zentralen Server uebertragen. Diese Daten beinhalten Angaben ueber
|
||||
die installierte FHEM-Version, das Betriebssystem und Rechner-Architektur,
|
||||
die aktuelle Perl-Version, sowie eine Liste der zur Laufzeit definierten
|
||||
Module (inkl. der Anzahl der Definitionen je Modultyp). Weiterhin werden die
|
||||
definierten Modelltypen ermittelt.
|
||||
|
||||
Die am FHEM-Projekt beteiligten Entwickler erhalten wertvolle Informationen zu
|
||||
der Umgebung, in der FHEM installiert ist, und eine Einschaetzung, wie haeufig
|
||||
die jeweiligen Module eingesetzt werden. Dies kann Auswirkungen auf die
|
||||
Weiterentwicklung aber auch auf die zeitnahe Bereitstellung von Erweiterungen
|
||||
und Korrekturen haben.
|
||||
|
||||
Es werden keine personenbezogenen Daten uebertragen und / oder gespeichert.
|
||||
Die Daten werden nicht an Dritte weitergegeben und nicht fuer kommerzielle
|
||||
Zwecke verwendet. Sie dienen einzig als Hilfestellung zur Entwicklung und
|
||||
zur Einschaetzung der Verbreitung von FHEM.
|
||||
|
||||
Eine weiterfuehrende Beschreibung ist der Dokumentation zu dem FHEM-Befehl
|
||||
'fheminfo' sowie dem globalen Paramater 'sendStatsistics' zu entnehmen. Eine
|
||||
Uebersicht der erhobenen Informationen kann jederzeit ueber den Aufruf von
|
||||
'fheminfo' abgerufen werden.
|
||||
|
||||
Wenn Du das FHEM-Projekt unterstuetzen moechtest, solltest Du jetzt ueber das
|
||||
globale Attribut 'sendStatsistics' die automatische Uebermittlung aktivieren:
|
||||
|
||||
attr global sendStatistics onUpdate
|
||||
|
||||
Im Anschluss solltest Du die aktuelle Konfiguration speichern, um diesen
|
||||
Hinweis nicht erneut angezeigt zu bekommen. Der Updatevorgang kann dann wie
|
||||
gewohnt fortgesetzt werden.
|
||||
|
||||
Moechtest Du keine automatische Uebermittlung der Daten waehrend der
|
||||
Aktualisierung, solltest Du nun das globale Attribut 'sendStatistics' auf
|
||||
'manually' setzen:
|
||||
|
||||
attr global sendStatistics manually
|
||||
|
||||
Die Uebermittlung der Daten muss manuell ueber den Befehl 'fheminfo send'
|
||||
erfolgen.
|
||||
|
||||
Moechtest Du niemals Daten ueber die vorhandene FHEM-Installation uebermitteln,
|
||||
so muss das globale Attribut auf 'never' gesetzt werden:
|
||||
|
||||
attr global sendStatistics never
|
||||
|
||||
Ein Aufruf von 'fheminfo send' ist damit wirkungslos.
|
||||
|
||||
Die obigen Einstellungen koennen jederzeit geaendert werden. Eine Uebersicht
|
||||
der bereits von anderen Installationen uebermittelten Informationen kann ueber
|
||||
|
||||
http://fhem.de/stats/statistics.cgi
|
||||
|
||||
eingesehen werden.
|
||||
|
||||
Das FHEM-Team freut sich, wenn auch Du durch die automatische Uebermittlung
|
||||
Deiner technischen Daten zum FHEM-Projekt beitraegst.
|
||||
|
||||
Dieser Hinweistext kann erneut durch den Aufruf von 'update viewAdvice'
|
||||
angezeigt werden.
|
||||
|
||||
Vielen Dank fuer Deine Unterstuetzung!
|
||||
EndOfInfo
|
||||
|
||||
my $str_EN=<<EndOfInfo;
|
||||
NOTICE:
|
||||
|
||||
The FHEM Project asks for your support!
|
||||
|
||||
During the update process FHEM is able to send statistical information
|
||||
regarding your installation to a central server. This may include data like
|
||||
your installed FHEM version, the operating system, Perl version, computer
|
||||
achitecture and the list of modules used during the update. Also the list of
|
||||
model types and number of definitions for each module may be collected.
|
||||
|
||||
The developers behind the FHEM project receive valuable information about the
|
||||
environment in which FHEM is installed and get an overview how often those
|
||||
modules are used. This may affect the further development of FHEM as well as
|
||||
the timely provision of extensions and corrections.
|
||||
|
||||
No personal information will be transferred or stored during this process. The
|
||||
data collected will neither be made available to a third party nor used for
|
||||
commercial purposes. The only purpose is to support further development of
|
||||
FHEM and to asses its distribution.
|
||||
|
||||
A more detailed explanation can be found in the documentation related to the
|
||||
command 'fheminfo' and the global parameter 'sendStatistics'. An overview
|
||||
about all information collected can be displayed at any time by using the
|
||||
command 'fheminfo'.
|
||||
|
||||
If you would like to support the FHEM project, you may set the global attribut
|
||||
'sendStatistics' to enable the automatic info transfer process.
|
||||
|
||||
attr global sendStatistics onUpdate
|
||||
|
||||
Thereafter you should save the current configuration to avoid this note beeing
|
||||
displayed again. The update process can be continued like before.
|
||||
|
||||
In case you do not whish an automatic transmission of the data collected
|
||||
during update, you should set the global attribute 'sendStatistics' to
|
||||
'manually':
|
||||
|
||||
attr global sendStatistics manually
|
||||
|
||||
Manual transfer of the data can then be performed by using the command
|
||||
'fheminfo send'.
|
||||
|
||||
If you never want to send information about your FHEM installation by all
|
||||
means, you need to set the global attribut 'sendStatistics' to 'never':
|
||||
|
||||
attr global sendStatistics never
|
||||
|
||||
Even the use of 'fheminfo send' will then not transfer any data.
|
||||
|
||||
All the settings mentioned above can be amended at any time. An overview of
|
||||
data sent from other installations can be obtained at
|
||||
|
||||
http://fhem.de/stats/statistics.cgi
|
||||
|
||||
The FHEM Project Team would be happy if you considered supporting the
|
||||
development of FHEM by transferring your technical data to the project.
|
||||
|
||||
This info text can be displayed again by using the command
|
||||
'update viewAdvice'.
|
||||
|
||||
Thanks a lot for your support!
|
||||
EndOfInfo
|
||||
|
||||
$str = "$str_DE\n";
|
||||
$str .= "-------------\n\n";
|
||||
$str .= $str_EN;
|
||||
return $str;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
@ -49,15 +49,18 @@ sub viewStatistics();
|
||||
my $css = "http://fhem.de/../css/style.css";
|
||||
|
||||
# exclude modules from top 10 graph
|
||||
my $excludeFromTop10modules = "at autocreate notify telnet weblink FileLog SUNRISE_EL";
|
||||
my $excludeFromTop10definitions = "at autocreate notify telnet weblink FileLog SUNRISE_EL";
|
||||
my $excludeFromTop10modules = "at autocreate notify telnet weblink FileLog FHEMWEB Global SUNRISE_EL";
|
||||
my $excludeFromTop10definitions = "at autocreate notify telnet weblink FileLog FHEMWEB Global SUNRISE_EL";
|
||||
|
||||
# directory cointains databases
|
||||
my $datadir = "./data";
|
||||
|
||||
# geo ip database file from http://www.maxmind.com/download/geoip/database/
|
||||
# should be updated once per month
|
||||
my $geoIPDat = "./data/GeoLiteCity.dat";
|
||||
my $geoIPDat = "$datadir/GeoLiteCity.dat";
|
||||
|
||||
# database
|
||||
my $dbf = "./data/fhem_statistics_db.sqlite";
|
||||
my $dbf = "$datadir/fhem_statistics_db.sqlite";
|
||||
my $dsn = "dbi:SQLite:dbname=$dbf";
|
||||
my $sth;
|
||||
|
||||
@ -605,7 +608,7 @@ sub insertDB() {
|
||||
$sth = $dbh->prepare(q{REPLACE INTO nodes (uniqueID,release,branch,os,arch,perl,lastSeen) VALUES(?,?,?,?,?,?,CURRENT_TIMESTAMP)});
|
||||
$sth->execute($uniqueID,$release,$branch,$os,$arch,$perl);
|
||||
|
||||
# insert or update goe location of fhem node
|
||||
# insert or update geo location of fhem node
|
||||
#### TODO: sprachcode 84.191.75.195
|
||||
my @geo = getLocation($ip);
|
||||
|
||||
@ -659,23 +662,15 @@ sub checkColumn($$) {
|
||||
my ($t,$k) = @_;
|
||||
|
||||
# get table info
|
||||
$sth = $dbh->prepare("PRAGMA table_info($t)");
|
||||
$sth->execute();
|
||||
my %column = %{ $dbh->column_info(undef, undef,$t, undef)->fetchall_hashref('COLUMN_NAME') };
|
||||
|
||||
# check if column exists
|
||||
my @row;
|
||||
my @match = ();
|
||||
while (@row = $sth->fetchrow_array()) {
|
||||
@match = grep { /\b$k\b/ } @row;
|
||||
last if(@match != 0);
|
||||
}
|
||||
|
||||
# create column if not exists
|
||||
if(@match == 0) {
|
||||
if(!exists $column{$k}) {
|
||||
$sth = $dbh->prepare("ALTER TABLE $t ADD COLUMN '$k' INTEGER DEFAULT 0");
|
||||
$sth->execute();
|
||||
$sth->finish;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1036,7 +1036,7 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
shutdown.
|
||||
</li><br>
|
||||
|
||||
<li><a href="#fheminfoattr">sendStatistics</a>
|
||||
<li><a href="#fheminfo">sendStatistics</a>
|
||||
|
||||
<a name="statefile"></a>
|
||||
<li>statefile<br>
|
||||
@ -1050,7 +1050,7 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
Used by the web frontend fhemweb.pl (webpgm2) as a Page title.
|
||||
</li><br>
|
||||
|
||||
<li><a href="#fheminfoattr">uniqueID</a>
|
||||
<li><a href="#fheminfo">uniqueID</a>
|
||||
|
||||
<a name="updatebranch"></a>
|
||||
<li>updatebranch<br>
|
||||
|
@ -1079,7 +1079,7 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
||||
gelöscht.
|
||||
</li><br>
|
||||
|
||||
<li><a href="#fheminfoattr">sendStatistics</a>
|
||||
<li><a href="#fheminfo">sendStatistics</a>
|
||||
|
||||
<a name="statefile"></a>
|
||||
<li>statefile<br>
|
||||
@ -1095,7 +1095,7 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
||||
Festlegung des Seitentitels benutzt..
|
||||
</li><br>
|
||||
|
||||
<li><a href="#fheminfoattr">uniqueID</a>
|
||||
<li><a href="#fheminfo">uniqueID</a>
|
||||
|
||||
<a name="updatebranch"></a>
|
||||
<li>updatebranch<br>
|
||||
|
@ -204,7 +204,7 @@ $modules{Global}{AttrList} =
|
||||
"verbose:1,2,3,4,5 mseclog:1,0 version nofork:1,0 logdir holiday2we " .
|
||||
"autoload_undefined_devices:1,0 dupTimeout latitude longitude " .
|
||||
"backupcmd backupdir backupsymlink backup_before_update " .
|
||||
"exclude_from_update motd updatebranch uniqueID sendStatistics ".
|
||||
"exclude_from_update motd updatebranch uniqueID sendStatistics:onUpdate,manually,never ".
|
||||
"showInternalValues:1,0 ";
|
||||
$modules{Global}{AttrFn} = "GlobalAttr";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user