Answer the question
In order to leave comments, you need to log in
Monitoring Starline Zabbix?
Good day, Question about Monitoring Zabbix car alarm Starline.
I wrote a PHP script to receive data from the Starline alarm and write to a file, then parse it in Zabbix and save the received data. But I would like to run it completely in monitoring.
We have at our disposal:
1) Login from your personal account
2) Password from your personal
account 3) Appid
4) Secret
What you need to get data:
1) Getting the application code:
Making a request (Getting the application code-GET)
https://id.starline .ru/apiV3/application/getCode?appId= (User's Appid)&secret=(User's secret in md5)
Example - curl " https://id.starline.ru/apiV3/application/getCode?a..." -i
The output is - array(2) { ["state"]=> int(1) ["desc"]=> array(1) { ["code"]=> string(32) "507096aefc13692362f4180402eddd56" } }
Next, we will use "code"
2) Getting the application token:
Making a request (Getting the application token-GET)
https://id.starline.ru/apiV3/application/getToken?... (User's Appid)&secret=( codeToken md5)
codeToken - we get by concatenating the "Secret" of the user and the "code" obtained earlier and the md5 hash.Example
-
curl " https://id.starline.ru/apiV3/application/getToken?... " -i
the output is - { ["state"]=> int(1) ["desc"]=>array(1) { ["token"]=> string(64) "f1e4f91f6fd4fb18cbc0a47547ddc008108d086ddab0999368958401ef2bc410" } }
Further "token" we will use.
3) User authorization:
We make a request (User authorization-POST)
https://id.starline.ru/apiV3/user/login
Example: curl " https://id.starline.ru/apiV3/user/login " -i -H ' token:6517f62f5241c310ff5012360cd09e26b71395c2c068...
' -F [email protected] -F pass=7c4a8d09ca3762af61e59520943dc26494f8941b -F smsCode
=
3454 --'login' => $user_login(Login from personal account),
----'pass' => $user_pass(Password from personal account, hashed sha1),
The output is:
{
"state": 1,
"id": "200*****",
"login": "z*******",
"state": "ACTIVE",
"first_name": "Y****",
"last_name ": "L****",
"middle_name": "A********",
"company_name": "Home",
"sex": "M",
"lang": "ru",
"gmt": "+3",
"avatar": "default",
"date_register": "2019-12-16 08:08:16",
"contacts": [
{
"id": "6**** ****",
"type": "push",
"value": "{\"device_name\":\"\",\"app_version\":\"\",\"language\":\"en\",\"os_type\":\"android2\ ",\"os_version\":\"\",\"phone_model\":\"\",\"token\":\"******************** ***************************\",\"ser_num\":\"3************** **********\"}",3****************************\"}",3****************************\"}",
"confirmed": null,
"token": "g************************************** *"
},
{
"id": "6*****************",
"type": "email",
"value": "f****** ********mail.ru",
"confirmed": "1",
"token": "T*********************** *******CF"
},
{
"id": "6*****************",
"type": "phone",
"value": " 7928*************",
"confirmed": "1",
"token": "9***********************************d"
},
{
"id": "8****** **********",
"type": "push",
"value": "{\"device_name\":\"\",\"app_version\":\"\",\"language\":\"en\",\"os_type\":\"android2\ ",\"os_version\":\"\",\"phone_model\":\"\",\"token\":\"c***************** ******************************X\",\"ser_num\":\"9******* *********d\"}",
"confirmed": null,
"token": "R*********************** *********1"
},
{
"id": "1******************",
"type": "push",
"value ": "{\"device_name\":\"\",\"app_version\":\"\",\"language\":\"en\",\"os_type\":\"android2\",\"os_version\":\"\",\"phone_model\":\"\",\"token\ ":\"c***********************************************\", \"ser_num\":\"5********************4\"}",
"confirmed": null,
"token": "u********************************************f"
}
],
"auth_contact_id": null,
"roles": [
"user",
"open-api-user"
],
"subscription": null,
"user_token": "6**************** **************************:200*****3",
"last_auth_date": "2021-12-23 19:19: 59",
"last_auth_ip": "199.999.999.999"
}
}
(*Personal data is closed with asterisks)
Further we will use "user_token" at the end of the received data.
4) User authorization by StarLineID token (POST)
https:
https://developer.starline.ru/json/v2/auth.slid " -v -d '{"slid_token":" f6e706e17d41ce781b5166f09e782fd0:1663 "}'
We send the previously received "user_token"
The response is received in the body
{
"code": "200",
"codestring": "OK",
"nchan_id": "1*********************************** ******D",
"realplexor_id": "1*********************************** *54D",
"user_id": "1*****6"
}
And returns all headers from the server response to the HTTP request
{ [0]=> string(15) "HTTP/1.1 200 OK"
[1]= > string(13) "Server: nginx"
[2]=> string(35) "Date: Thu, 23 Dec 2021 19:36:15 GMT"
[3]=> string(23) "Content-Type: text/json"
[4]=> string(19) "Content-Length: 170"
[5]=> string(17) "Connection: close"
[6]=> string(120) "Set-Cookie: slnet=7*** *****************************************0; path=/; expires=Friday, 24-Dec- 21 19:36:15 GMT; domain=.starline.ru;"
[7]=> string(50) "Content-Security-Policy: upgrade-insecure-requests"
[8]=> string(71) "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload" }
Next to get data we substitute COOKIE Set-Cookie: slnet=7**************************************** **0 and "user_id": "1*****6"
5) Getting data from signaling (GET)
https://developer.starline.ru/json/v3/user/'"user_...
Example: curl " https:" --cookie 'slnet=15CFA19BFD3E8884C716FFA4E39AF866'
We substitute the "user_id": "1*****6" previously received from the request body into the address and send slnet=7************* to the cookie **************************0
In response we get:
{
"code": 200,
"codestring": "OK",
"user_data" : {
"shared_devices": [],
"devices": [
{
"event": {
"type": 1090,
"timestamp": 1640273201
},
"balance": [
{
"operator": "",
"state": 2,
"key": "active",
"ts": 1640285848,
"value": 664,
"currency": ""
}
],
"typename": "Telematic alarm system",
"common": {
"ctemp": 1,
"gsm_lvl": 22,
"mayak_temp": 0,
"etemp": 14,
"gps_lvl ": 9,
"reg_date": 1577866156,
"ts": 1640288729,
"battery": 12.890999794006348
},
"telephone": "+79************",
"r_start": {
" wakeup_ts": 1,
"battery":{
"has": true
},
"period": {
"has": false
},
"cron": {
"has": false
},
"temp": {
"has": false
}
},
"ua_url": "",
"type": 3,
"device_id": 3******* ********,
"activity_ts": 1640288729,
"position": {
"dir": 5,
"r": 0,
"s": 22,
"sat_qty": 9,
"x": 43. ****************,
"y": 44.***********************,
"ts" : 1640288839,
"is_move": true
},
"firmware_version": "2.25.1",
"status": 1,
"alias": "StarLine****",
"obd": {
"fuel_litres": 48,
"ts": 1640273191,
"mileage": null,
"fuel_percent": null
},
"state": {
"webasto" : false,
"arm_auth_wait": false,
"tilt_bpass": false,
"hijack": false,
"trunk": false,
"add_sens_bpass": false,
"shock_bpass": false,
"ign": false,
"neutral": false ,
"hood":false,
"hbrake": false,
"r_start": false,
"hfree": false,
"r_start_timer": 0,
"webasto_timer": 0,
"arm_moving_pb": false,
"alarm": false,
"valet": false,
"arm": true,
"out": false,
"door": false,
"ts ": 1640288729,
"pbrake": true,
"run": false
},
"alarm_state": {
"hood": false,
"hbrake": false,
"shock_l": false,
"hijack": false,
"trunk": false,
"add_l": false,
"tilt": false,
"add_h": false,
"shock_h": false,
"door": false,
"ts": 1640288729,
"pbrake": false,
"run": false
},
"sn": "S96 ****************",
" functions": [
"rstart_cfg",
"int_sensor",
"shock_cfg",
"scoring",
"gsm_control",
"eng_sensor",
"xml_cfg",
"gsm",
"info",
"position",
"state",
"adv_state ",
"mon_cfg",
"tracking",
"push",
"events",
"controls",
"adv_controls",
"adv_guard",
"rstart_cfg",
"shock_cfg",
"obd_params",
"ble2"
]}
]}}
And from this data we can get the location, battery charge, gasoline, SIM card balance, quantity satellites, state of protection. system, firmware version, etc.
If there is no solution, then at the moment everything is working. This article might be helpful.
For a more detailed study, there is offline documentation Starline - https://developer.starline.ru/
There are restrictions on the number of requests:
For a mortal user, it is possible to make 1000 requests within 24 hours, and you should not make more than 1 in 5 minutes (you risk getting a captcha)
Answer the question
In order to leave comments, you need to log in
In general, such multi-way actions (you also have a temporary token in the api) are best given for execution in Zabbix external script, you pass the login password to it, from there you return JSON of all (sort of like devices - an array) connected devices on the account. And then, using zabbix, create data elements through dependent item, slip the element that stores the received JSON as a master element, then cut it into numbers, strings and identifiers by preprocessing it. Well, since there is only one master item, set it to be updated every 10 minutes so as not to get beyond the limit of api requests, and parsing already received data in the api will not work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question