Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • message - text description of the event;


Code Block
languagexml
titleExample
<log>
  <entry id="61" time="1399898505" severity="Natice" type="message" message="Logic &apos;Температура&apos;(id=3) was activated" />
  <entry id="60" time="1399898505" severity="Warning" type="state" eid="1001" element="temperature" name="Internal T°C" old="high alarm" new="high warning" />
  <entry id="59" time="1399898406" severity="Critical" type="state" eid="1054" element="temperature" name="sc450-0020-temperature" old="low alarm" new="high alarm" />
  <entry id="58" time="1399898402" severity="Critical" type="state" eid="1020" element="temperature" name="sc470-0003-internal T°C" old="low alarm" new="high alarm" />
  <entry id="57" time="1399898369" severity="Notice" type="state" eid="1056" element="motion" name="sc408-2147483647-analog-4" old="unknown" new="normal" />
  <entry id="56" time="1399898365" severity="Critical" type="state" eid="1004" element="GSM modem" name="GSM Modem" old="normal" new="alarm" />
</log>

...

  • time - the time of the last event in the system (UTS);
  • current - the current time in the system (UTS);
  • total - the number of events in the log;
  • maxid - id of the last event in the log;


Code Block
languagexml
titleExample
<logdate time="1355137672" current="1355138383" total="6" maxid="6" />

...

The log file is filled in as events appear, and looks like:

Code Block
languagehtml/xml
titleПримерExample
#
# Device type: "VT335", Firmware version: "2.7.1".
# Hostname: "hostname", IP: "192.168.0.199", MAC: "unknown"
#
Thu Nov 17 14:23:20 2016    message: USB Flash was inserted
Thu Nov 17 14:23:25 2016    state: Element Onboard Temperature (id=201001) changed state from "unknown" to "normal" 
Thu Nov 17 14:23:25 2016    state: Element Onboard Voltage DC (id=203001) changed state from "unknown" to "normal" 
Thu Nov 17 14:23:26 2016    state: Element Dry-1 (id=101001) changed state from "unknown" to "normal" 
Thu Nov 17 14:23:26 2016    state: Element Dry-2 (id=101002) changed state from "unknown" to "normal" 
Thu Nov 17 14:23:30 2016    message: System started up and ready
Thu Nov 17 14:23:41 2016    state: Element GSM Modem (id=404001) changed state from "unknown" to "normal" 

...

The dump file of changes is populated periodically (every 60 seconds), and reflects the identifiers and values of the sensors whose values have changed over the elapsed time period. Every 60 minutes, the dump records the values of all sensors, even if their values have not changed. Dump changes in text form:

Code Block
languagehtml/xml
titleПримерExample
Device type: "VT335" 
Firmware version: "2.7.1" 
Hostname: "spirt" 
IP: "192.168.0.193" 
MAC: "d8:80:39:9e:97:a3" 
Date and Time 
Thu May 11 16:45:54 2017,201001,201002 
,24.100,22.600 
Thu May 11 16:46:54 2017,201001 
,24.000

The full dump file is filled periodically (every 60 minutes), and contains a complete description of the elements and modules of the system:

Code Block
languagehtml/xml
titleПримерExample
Thu Nov 17 14:28:52 2016
    [101001]={module:"2022";clas:"discrete";type:"dry";name:"Dry-1";state:"normal";hwport:"1";value:"0";utype:"";reverse:"0";};
    [101002]={module:"2022";clas:"discrete";type:"dry";name:"Dry-2";state:"normal";hwport:"2";value:"0";utype:"";reverse:"0";};
    [203001]={module:"2020";clas:"analog";type:"voltage";name:"Onboard Voltage DC";state:"normal";value:"12.2";vmax:"24.0";vmin:"0.0";low_alarm:"9.0";low_warning:"11.0";high_warning:"13.0";high_alarm:"14.0";at0:"1.000";at75:"0.000";um:"V";};
    [301001]={module:"2021";clas:"switch";type:"relay";name:"Analog Power";state:"on";value:"1";initial:"on";pulse:"15";};
    [304001]={module:"2023";clas:"switch";type:"strobo";name:"Power-1";state:"off";value:"0";initial:"off";pulse:"2";hwport:"1";};
    [403001]={module:"2031";num:"1";clas:"devhwr";type:"usb-cam";name:"USB Web camera";url:"";fps:"1.0";username:"";password:"";resolution:"320x240";};
    [404001]={module:"2030";clas:"devhwr";type:"GSM modem";state:"normal";name:"GSM Modem";value:"90";imei:"866104023288015";pin:"";sms_centre:"+79168999100";allowed:"";status:"found, ready";verbosity:"2";};

...

When you remove the USB flash drive without first unmounting, data loss is possible.

Save the log to the FTP server

...

Working with SATA Hard Disk Drive

The SATA HDD is used to record changes in the system: logs, sensor readings, element settings, video records.

The FAT32 and Ext4 file system is supported. HDD must be formatted by the user. The contents of the HDD can be obtained from the address 192.168.0.193/satahdd/ (the default IP address of the device).

The names of directories and files are also formed as when working with SD Card.

The user can set the following logging parameters through the API:

  • enable and disable the logging function;
  • lifetime of files - all older files are deleted from the HDD memory (by default 7 days).

When the system is rebooted, new files are created for writing. Required directories are created automatically if logging is enabled.

The following values of the querytype field are used for management:

  • getsatahdd - get information about the drive, returns the response as

    Code Block
    <satahdd state="normal" mpoint="/tmp/mnt/satahdd" fullsize="7808156" freesize="7806524" lifetime="31536000" enablelog="1" enablelogvideo="1" />

    , where:

    • state - HDD status:
      • normal - working state, the drive is installed;
      • not connected - the drive is not installed or removed from the connector;
      • off - the drive is unmounted by the umount command;
    • mpoint - mount point for HDD in the system;
    • fullsize - total amount of memory, in MB;
    • freesize - the amount of free memory in MB;
    • lifetime - the lifetime of the files, in seconds (the default is 7 days, ie 604800 seconds);
    • enablelog - logging to disk is enabled or disabled  (0 - disabled, 1 - enabled);
    • enablelogvideo - saving of video files to this media is enabled or disabled (0 - disabled, 1 - enabled);
  • setsatahdd - set the parameters of the log on the drive. Extra options are:
    • lifetime - the lifetime of the files, in seconds (minimum 3 hours, maximum 1 year);
    • enablelog - logging process on the drive is enabled or disabled (0 - disabled, 1 - enabled);
    • enablelogvideo - saving video to drive enabled or disabled (0 - disabled, 1 - enabled).

When specifying parameters, if the new configuration is different from the current one, the current log and dump files are closed, new files are created and new logging parameters are applied. In addition, the settings are saved in the device's permanent memory and additional save command is not required.

Setting the parameters lifetime, enablelog and enablelogvideo is possible in the absence of the installed drive. If there is no hardware support for SATA drive, then "not supported" error is returned.

Save the log to the FTP server

Logging and dumping to the FTP server is done through a files on one of the media (in priority order - SATA HDD, SD card, USB flash drive). At a given time (00:00), the data files from the media is transferred to the FTP server. The structure of the folders and files on the remote server is similar to that created on the SD Card and USB Flash Drive. The length of recording events in one file, after which the file from the RAM is transferred to the remote server, is one hour and is not available for modification by the user.

The user can set the following logging parameters through the API :

...

Sending the log archive file to e-mail

Temporary log Log files, sensor dumps and etc. are periodically at a given time (00:00) compressed into a the archive file (*.gz extension) and added as such to the archive file. The resulting archive file can be and sent to several specified mail addresses.Because files are stored in RAM, then with a sudden reboot (for example, due to a system failure), the unsent data will be lost. The folder structure in the created archive is similar to that created on the SD Card and USB Flash Drive, all log and dump files are compressed by the archiver. The length of recording events in one file, after which the file is compressed and added to the archive, is one hour and is not available for user modificationThe folder structure in the created archive is similar to that created on the SD Card and USB Flash Drive.

Video files are not archived, but sent to the mail immediately.Because there might not be enough RAM for archiving.

The user can set the following logging parameters through the API :

...

It is possible to record on the specified medium of second-by-second samples of analog and discrete sensors. The data is recorded according to the specified media (HDD, USB-Flash Drive, SD Card, FTP server). In this case, detailed logging should be enabled (allowed) on the specified medium.

To write files in the root directory, which also contains the log, diff video and full other directories, a directory called sensors is created, inside which directories are created with the name corresponding to the identifier of the observed sensor (201001, 101004, etc.). File names are formed based on the time of their creation, and have the form 2016.11.17_16-37-43.201001.csv. The file name extension includes the identifier of the sensor. The files are written in the text table format CSV.

The per-second dump file is filled in periodically (a group of samples every 30 seconds), and reflects the counting time (in readable form and in UTS format) and the value of the sensor (in a float format with an accuracy of 3 decimal places). For analog sensors, the scores are per second. For discrete, in the absence of state changes, counts can go less often. If there is no sensor, the directory and file are not created and are not filled. Dump in text form:

Code Block
languagehtml/xml
titleПримерExample
Device type: "VT335" 
Firmware version: "2.7.1" 
Hostname: "spirt" 
IP: "192.168.0.193" 
MAC: "d8:80:39:9e:97:a3" 
Date and Time,UTS,Value 
Thu May 11 12:23:51 2017,1494505431,23.400 
Thu May 11 12:23:52 2017,1494505432,23.500 
Thu May 11 12:23:53 2017,1494505433,23.600 
Thu May 11 12:23:54 2017,1494505434,23.700

...

  • getsensdump - get information about sensor dump for every second, returns a response in the form <sensdump elementslist="201001,201002,101001," enable_usb="1" enable_sd="0" enable_ftp="0" enable_mail="1" />, where:
    • elementslist - the list of observed sensors, separated by commas;
    • enable_hdd - flag to enable the SATA HDD;
    • enable_usb - flag to enable the USB flash drive;
    • enable_sd - the flag to enable the use of SD Card media;
    • enable_ftp - flag to enable use as an FTP server media;
    • enable_mail - the flag to enable sending the log file to e-mail.
  • setsensdump - set the parameters of a sensor dump for every second. Extra options are:
    • elementslist - the list of observed sensors, separated by commas;
    • enable_hdd - flag to enable the SATA HDD;
    • enable_usb - flag to enable the USB flash drive;
    • enable_sd - the flag to enable the use of SD Card media;
    • enable_ftp - flag to enable use as an FTP server media;
    • enable_mail - the flag to enable sending of a log file to an email

...