标签 datamark 的文章

简单方便的使用datamark 用做 树莓派监控

第一步:
访问http://dm.trtos.com/ 获取id
会跳转到 http://dm.trtos.com/web/datamark/index.php?id=4DRtDABC 后面的4DRtDABC就是id
第二步
http://dm.trtos.com/web/datamark/set.php?id=4DRtDABC&name=这里填入项目&value=这里填入描述
第三步
访问 http://dm.trtos.com/web/datamark/index.php?id=4DRtDABC 就可以直接看到记录,可删除打印等
非常简单
微信截图_20200522104416.png

树莓派python 代码

import requests
url = "http://dm.trtos.com/web/datamark/set.php?id=4DRtDABC&name=这里填入项目&value=这里填入描述"
r = requests.get(url)
print(r)

DataMark 云便签 API

地址 http://dm.trtos.com/

JSON 操作 DataMark 数据项

地址:http://dm.trtos.com/php/json.php
Post 添加数据
{"action":"add","id":"y9JM9Rd","content": [{"name": "项目1","value": "5555"},{"name": "项目2","value": "1234"}]}
返回
{"action":"add","status":"succeed"}
Post 删除所有数据
{"action":"del","id":"y9JM9Rd"}
返回
{"action":"del","status":"succeed"}
Post 获取分配ID
{"action":"getid"}
返回
{"action":"getid","id":"y9JM9Rd"}
Post 获取记录(必要参数id,可选参数name,value)
{"action":"get","id":"y9JM9Rd"}
{"action":"get","id":"y9JM9Rd","name":"项目1"}
{"action":"get","id":"y9JM9Rd","name":"项目1","value":"5555"}
返回
[{"Name":"Name1","Value":"xiaowu"},{"Name":"Name2","Value":"Xiaotian"}]

上传背景图代码 可用于监控
微信截图_20200703145710.png

#!usr/bin/python
# image.py
# -*- coding=utf-8 -*-
from poster.encode import multipart_encode
import urllib2
import sys
from urllib2 import Request, urlopen, URLError, HTTPError
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
  
register_openers()
f=open("4UTmPcpw.jpg", "rb")

datagen, headers = multipart_encode({"myFile": f})
request = urllib2.Request("http://trtos.com/web/datamark/upload.php", datagen, headers)
try:
    response = urllib2.urlopen(request)
    print response.read()
     
except URLError,e:
    print e.reason
    print e.code

修改数据标签 指定选项内容
这种方式比较简单 直接通过浏览器访问方式操作
微信截图_20200703152045.png
eg:设置名和值 http://dm.trtos.com/web/datamark/update.php?id=5oOeooHz&index=149717&name=使用率&value=99%
eg:设置名 http://dm.trtos.com/web/datamark/update.php?id=5oOeooHz&index=149717&name=使用率
eg:获取名和值 http://dm.trtos.com/web/datamark/update.php?id=5oOeooHz&index=149717
下例 是使用python 上传 ip地址

import requests
import datetime
import socket
def get_host_ip():
    """
    查询本机ip地址
    :return: ip
    """
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('8.8.8.8', 80))
        ip = s.getsockname()[0]
    finally:
        s.close()
    return ip

hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
ip="0.0.0.0"
ip=get_host_ip()
date=datetime.datetime.now()
response = requests.get('http://dm.trtos.com/web/datamark/update.php?id=5oOeooHz&index=149717&name=树莓派IP&value='+ip+":"+str(date))
print(response.text)


共享变量

设置值 http://www.trtos.com/php/value.php?name=my_value&value=123456
读取值 http://www.trtos.com/php/value.php?name=my_value