Add getUUID subroutine, Add ZM_TELEMETRY_LAST_UPLOAD
This commit is contained in:
parent
7a9740b1a4
commit
18c493a180
|
@ -2763,6 +2763,27 @@ body = "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% s
|
|||
type => $types{boolean},
|
||||
category => "system",
|
||||
},
|
||||
{
|
||||
name => "ZM_TELEMETRY_UUID",
|
||||
default => "yes",
|
||||
description => "Unique identifier for ZoneMinder telemetry",
|
||||
help => qqq("
|
||||
This variable is auto-generated once by the system and is used to
|
||||
uniquely identify it among all other ZoneMinder systems in
|
||||
existence.
|
||||
"),
|
||||
type => $types{string},
|
||||
category => "dynamic",
|
||||
},
|
||||
{
|
||||
name => "ZM_TELEMETRY_LAST_UPLOAD",
|
||||
default => "",
|
||||
description => "When the last ZoneMinder telemetry upload ocurred",
|
||||
help => "",
|
||||
type => $types{integer},
|
||||
readonly => 1,
|
||||
category => "dynamic",
|
||||
},
|
||||
{
|
||||
name => "ZM_UPDATE_CHECK_PROXY",
|
||||
default => "",
|
||||
|
|
|
@ -91,7 +91,7 @@ if ( $Config{ZM_TELEMETRY_DATA} )
|
|||
if ( sendData($result) ) {
|
||||
$lastCheck = $now;
|
||||
|
||||
my $lc_sql = "update Config set Value = ? where Name = 'ZM_DYN_LAST_CHECK'";
|
||||
my $lc_sql = "update Config set Value = ? where Name = 'ZM_TELEMETRY_LAST_UPLOAD'";
|
||||
my $lc_sth = $dbh->prepare_cached( $lc_sql ) or die( "Can't prepare '$lc_sql': ".$dbh->errstr() );
|
||||
my $lc_res = $lc_sth->execute( $lastCheck ) or die( "Can't execute: ".$lc_sth->errstr() );
|
||||
}
|
||||
|
@ -156,3 +156,24 @@ sub sendData {
|
|||
return $success;
|
||||
}
|
||||
|
||||
# Retrieves the UUID from the database. Creates a new UUID if one does not exist.
|
||||
sub getUUID {
|
||||
my $uuid= "";
|
||||
|
||||
if ( $Config{ZM_TELEMETRY_UUID} ) {
|
||||
$uuid = $Config{ZM_TELEMETRY_UUID};
|
||||
} else {
|
||||
use OSSSP::uuid;
|
||||
my $uuidobj = OSSP::uuid->new;
|
||||
$uuidobj -> make("v1");
|
||||
$uuid = $uuidobj->export("str");
|
||||
|
||||
my $sql = "update Config set Value = ? where Name = 'ZM_TELEMETRY_UUID'";
|
||||
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
my $res = $sth->execute( $uuid ) or die( "Can't execute: ".$sth->errstr() );
|
||||
}
|
||||
|
||||
return $uuid;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue