| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- package main
- import (
- //"fmt"
- //"time"
- //"runtime"
- //"strconv"
- //"runtime"
- //"strconv"
- "gitee.com/wecisecode/util/logger"
- //"git.wecise.com/wecise/odbserver/lib/wgwaiter"
- //"git.wecise.com/wecise/odbserver/odb"
- . "git.wecise.com/wecise/odbserver/odb"
- //"git.wecise.com/wecise/odbserver/odb/redisvr"
- "git.wecise.com/wecise/odbserver/odb/test"
- //"git.wecise.com/wecise/odbserver/odb/upsert"
- //"git.wecise.com/wecise/odbserver/lib/wgwaiter"
- )
- // CGO_ENABLED=1 go run --ldflags '-linkmode external -extldflags "-static"' testexec.go
- // #cgo LDFLAGS: -L/opt/odbserver/sqlite -lsqlite -ldl
- // #include "/opt/odbserver/sqlite/sqlite.h"
- // #include <stdint.h>
- // #include <stdlib.h>
- // extern int64_t uhaha_seed;
- // extern int64_t uhaha_ts;
- // void uhaha_begin_reader();
- // void uhaha_end_reader();
- func main() {
- //options := map[string]interface{} {"cache":odb.CacheAll}
- //g,err:= odb.New( options )
- //option := &StoreOption{Cache:CacheAll}
- //option := &Option{Cache: CacheAll, Keyspace: "oootest", DisableInitialHostLookup: true, DisableNotify: true}
- option := &Option{Cache: CacheAll, Keyspace: "oootest", DisableInitialHostLookup: true}
- g, err := test.NewG(option)
- if err != nil {
- logger.Error(err.Error())
- } else {
- defer g.Close()
- }
- //logger.SetRollingDaily("C:/test/zkcron/src/test", "test.log")
- logger.SetConsole(true)
- logger.SetLevel(logger.TRACE)
- //stat,err := g.Prepare(`insert into /matrix/clickcount count=?`)
- //stat,err := g.Prepare(`update /matrix/makdb/gyspj set vordercode = ?, jobcode = ?, jobname = ?, custcode = ?, custname = ?, dorderdate = ?, nordernum = ?, ntaxpricemny = ? WHERE ( ( vordercode = ? ) ) AND ( ( jobcode = ? ) ) AND ( ( jobname = ? ) ) AND ( ( custcode = ? ) ) AND ( ( custname = ? ) ) AND ( ( dorderdate = ? ) ) AND ( ( nordernum = ? ) ) AND ( ( ntaxpricemny = ? ) ) `)
- //stat,err := g.Prepare(`update /matrix/entity/hmc set config=config +?, location=? where id= ? `)
- //stat,err := g.Prepare(` insert into /matrix/tagdir (creater, domain, name, parent, path, tags) values (?, ?, ?, ?, ?, ?) `)
- //stat,err := g.Prepare(`delete from /matrix/system/hostinfo where host=? `)
- //stat,err := g.Prepare(`update /matrix/ldap set config = config + ? where otype=? refresh`)
- //stat,err := g.Prepare(`update /matrix/ldap set config = config + ? where otype=? refresh`)
- //stat,err := g.Prepare(`insert into /matrix/entity/hmc (id, config) values (?, ?)`)
- //stat,err := g.Prepare(`update / set tags = tags - 'abcdssssss123' where id in ?`)
- //stat,err := g.Prepare(`update /matrix/portal/tools set _group=_group+? where name in ? refresh`)
- //stat,err := g.Prepare(`insert into /matrix/devops/alert (src, ctime, type, _tokens, ip, entity, severity, msg) values (?, ?, ?, ?, ?, ?, ?, ?)`)
- //stat,err := g.Prepare(`insert into /matrix/action/callrecord (id, location, longitude, lac, ci, oppositenumber, starttime, bycall, name, blocation, dimensionality, phonenumber, period, callto) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)`)
- //stat,err := g.Prepare(`insert into /matrix/action/callrecord (id, blocation, longitude, period, location, name, dimensionality, oppositenumber, phonenumber, starttime, callto, bycall, ci, lac, _tokens) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
- //stat,err := g.Prepare(`insert into /matrix/action/callrecord (id, callto, name, period, bycall, _tokens, longitude, phonenumber, dimensionality, starttime, ci, location, lac, oppositenumber, blocation) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?)`)
- //stat,err := g.Prepare(`insert into /matrix/testbucket6 (id, bkdata[?]) values (?, ?) at ? `)
- //stat,err := g.Prepare(`update / set tags = tags + "aaa" where id in ?`)
- //stat,err := g.Prepare(`insert into /matrix/testbucket5 (id, bk2['file1.log']) values (?, ?) `)
- //stat,err := g.Prepare(` insert into /matrix/entity/linux (id,disk_perf) values (?, ?) at ?`)
- //stat,err := g.Prepare(`insert into /matrix/test/mpartition (v_varchar, v_int, v_float, v_text, v_bool) values(?, ?, ?, ?, ?) on conflict update v_bool=v_bool, v_float=v_float+1`)
- //stat, err := g.Prepare(`insert into /matrix/test/alert_status (identifier, severity, lastoccurrence, maintenance, msg, type, agent, firstoccurrence, omni_class, nodealias, alertgroup, node, manager, _tokens, originalseverity, summary) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict update firstoccurrence=firstoccurrence, servicenowstate=servicenowstate, emailstatus=emailstatus, tally=tally+1`)
- //stat, err := g.Prepare(`insert into /matrix/test/bucketlog (id, bklog['file1.log']) values (?, ?)`)
- //stat,err := g.Prepare(`update /matrix/portal/tools set _group = _group + ? where name in ?`)
- //stat,err := g.Prepare(`insert into /matrix/devops/alert_status (originalseverity, nodealias, alertgroup, firstoccurrence, _tokens, identifier, maintenance, entity, node, type, severity, lastoccurrence, summary, ttuser, omni_class, manager, alertkey, agent) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict update firstoccurrence=firstoccurrence, servicenowstate=servicenowstate, emailstatus=emailstatus, tally=tally+1`)
- //stat, err := g.Prepare( `insert into /matrix/test/bucketlog (id, bklog[?]) values (?, ?)`)
- //stat,err := g.Prepare(`insert into /matrix/devops/alert_status (identifier, severity, lastoccurrence, maintenance, msg, type, agent, firstoccurrence, omni_class, nodealias, alertgroup, node, manager, _tokens, originalseverity, summary) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict update firstoccurrence=firstoccurrence, servicenowstate=servicenowstate, emailstatus=emailstatus, tally=tally+1`)
- //stat,err := g.Prepare(`insert into /matrix/devops/alert_status (identifier, severity, lastoccurrence, maintenance, msg, type, agent, firstoccurrence, omni_class, nodealias, alertgroup, node, manager, _tokens, originalseverity, summary) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict update firstoccurrence=firstoccurrence, servicenowstate=servicenowstate, emailstatus=emailstatus, tally=tally+1`)
- //stat,err := g.Prepare(` insert into /matrix/devops/alert_status (identifier, firstoccurrence) values (?, ?) `)
- //stat,err := g.Prepare(`update /matrix/entity/node set connect = connect + ?, assetid= ? where id=?`)
- //stat,err := g.Prepare(` insert into /matrix/system/depot set tags =? , name=?, version=?, remark=?`)
- /*if stat,err := g.Prepare(`insert into /matrix/testgroup g1=?, g2=?, g3=?, v1=? , v2=? , f1=? , f2=?`) ;err != nil {
- logger.Info("Prepare error:"+err.Error())
- }else{
- logger.Errorf("%v", stat)
- //rst,meta,err := stat.Exec( [][]interface{}{{"g1111","g2222", map[string]interface{}{"bank":"tag1","core":"tag2"}, 11 , 22, 11.11,22.22}, {"g1111","3333", map[string]interface{}{"bank":"tag3","core":"tag3"}, 33 , 44,33.33,44.44 }})
- rst,meta,err := stat.Exec( "g0000","g00", map[string]interface{}{"bank":"tag8","core":"tag8"}, 88 , 88, 88.88,88.88 )
- if err != nil {
- logger.Info("Query error:"+err.Error())
- }else{
- logger.Info("rst ===>", rst)
- //logger.Error("meta ===>", meta)
- if meta["trace"] != nil && len(meta["trace"].([]string)) > 0 {
- for _, msg := range meta["trace"].([]string) {
- logger.Error(msg)
- }
- }
- logger.Warn(meta["columns"])
- }
- }*/
- /*if stat,err := g.Prepare(`update /matrix/clickcount set count=1 where id=?`) ;err != nil {
- logger.Info("Prepare error:"+err.Error())
- }else{
- logger.Errorf("%v", stat)
- //rst,meta,err := stat.Exec( [][]interface{}{{"g1111","g2222", map[string]interface{}{"bank":"tag1","core":"tag2"}, 11 , 22, 11.11,22.22}, {"g1111","3333", map[string]interface{}{"bank":"tag3","core":"tag3"}, 33 , 44,33.33,44.44 }})
- rst,meta,err := stat.Exec()
- if err != nil {
- logger.Info("Query error:"+err.Error())
- }else{
- logger.Info("rst ===>", rst)
- //logger.Error("meta ===>", meta)
- if meta["trace"] != nil && len(meta["trace"].([]string)) > 0 {
- for _, msg := range meta["trace"].([]string) {
- logger.Error(msg)
- }
- }
- logger.Warn(meta["columns"])
- }
- }*/
- /*if err != nil {
- logger.Errorf("%v", err)
- return
- }*/
- //for i:=0 ;i <=10 ; i++ {
- //if rst,meta,err := stat.Exec( []string{"SCRIPT"}, "test12", "10", nil ) ; err != nil {
- /*if rst,meta,err := stat.Exec( "linux:wecise", []interface{}{`DEBUG [CompactionExecutor:584] 2020-05-15 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- DEBUG [CompactionExecutor:583] 2020-05-15 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- DEBUG [CompactionExecutor:584] 2020-05-15 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- DEBUG [CompactionExecutor:583] 2020-05-15 00:49:59,666 TimeWindowCompactionStrategy.java:117 - TWCS expired check sufficiently far in the past, checking for fully expired SSTables
- DEBUG [CompactionExecutor:583] 2020-05-15 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- DEBUG [CompactionExecutor:583] 2020-05-15 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- WARN [Native-Transport-Requests-1] 2020-05-15 00:50:01,043 SelectStatement.java:429 - Aggregation query used without partition key
- WARN [Native-Transport-Requests-1] 2020-05-15 00:50:04,072 SelectStatement.java:429 - Aggregation query used without partition key
- INFO [Thread-3] 2020-05-15 00:50:08,837 IndexMatrixSchema.java:143 - [object] No need to add fields
- INFO [Thread-8] 2020-05-15 00:50:08,840 IndexMatrixSchema.java:143 - [vobject] No need to add fields
- WARN [Native-Transport-Requests-2] 2020-05-15 00:50:14,231 SelectStatement.java:429 - Aggregation query used without partition key
- WARN [Native-Transport-Requests-2] 2020-05-15 00:50:31,326 SelectStatement.java:429 - Aggregation query used without partition key
- WARN [Native-Transport-Requests-1] 2020-05-15 00:50:34,163 SelectStatement.java:429 - Aggregation query used without partition key
- WARN [Native-Transport-Requests-1] 2020-05-15 00:50:44,342 SelectStatement.java:429 - Aggregation query used without partition key` } ) ; err != nil {*/
- //if rst,meta,err := stat.Exec("callrecord:13962088589_10658112210002_2019-12-03 12:47:10","","0.0000","0","江苏盐城","接打电话:13962088589_10658112210002_2019-12-03 12:47:10","0.0000","10658112210002","13962088589",1575348430000,[]string{"phonenumber:10658112210002"},[]string{"phonenumber:13962088589"},"","",map[string]string{"_raw":"\t\t\t\t0\t\t\t0.0000\t0.0000\t10658112210002\t\t2019-12-03 12:47:10\t江苏盐城\t13962088589\t0\n"} ) ; err != nil {
- //if rst,meta,err := stat.Exec("callrecord:18861998197_10658112210002_2020-04-25 21:06:17","江苏盐城","0.0000","","","10658112210002",0,[]interface{}{"phonenumber:18861998197"},"接打电话:18861998197_10658112210002_2020-04-25 21:06:17","","0.0000","18861998197","0",[]interface{}{"phonenumber:10658112210002"}) ; err != nil {
- //if rst,meta,err := stat.Exec("id1",[]string{"id5"}) ; err != nil {
- //if rst,meta,err := stat.Exec( "linux:wecise", [][]interface{}{ []interface{}{i, nil, 3.3, 6.5, "5234567890"}, []interface{}{i, nil, 3.4, 6.6, "44444"} }, time.Now().UnixNano()/1000000 ) ; err != nil {
- //if rst,meta,err := stat.Exec( "linux:wecise", []interface{}{ 1, nil, 3.3, 6.5, "3234567890" }, "2020-04-24 22:24:15" ) ; err != nil {
- //if rst,meta,err := stat.Exec("domain", "name", 60, 100, 5, 50, 100, 10, []string{"hello:world"}) ; err != nil {
- //if rst,meta,err := stat.Exec("zabbix","2019-09-10 10:01:04","1",map[string]interface{}{"_raw":"{\"EventTime\":\"2019.09.10 10:01:04\",\"EventName\": \"Failed to fetch nginx stub status page\",\"HostName\": \"Nginx102_勿删\",\"HostIP\": \"10.0.44.102\",\"Severity\":\"Warning\",\"EventID\": \"5648\",\"EventValue\":\"1\",\"ItemValue\":\"*UNKNOWN*\" ,\"ItemName\":\"Get Nginx stub status\",\"Status\":\"1\" }"},"10.0.44.102","Nginx102_勿删",4,"Failed to fetch nginx stub status page") ; err != nil {
- /*if rst,meta,err := stat.Exec( "wecise3",[]string{"192.168.100.100", "192.168.31.125"}, "aix",`{
- "os": "aix",
- "host": "wecise3",
- "pid": "188776",
- "matrixroot": "/opt/matrix",
- "cpu_usedpercent": "0.00",
- "memory_usedpercent": "17.80",
- "disk_usedpercent": "0.54",
- "disk_total": "139776",
- "disk_free": "64000"
- }`) ; err != nil {*/
- //if rst,meta,err := stat.Exec( []string{ "node:DFD9255-940106-1"} ) ; err != nil {
- /*if rst,meta,err := stat.Exec( "file1.log", "linux:wecise", []string{"1-1--DEBUG [CompactionExecutor:584] 2020-09-25 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables", "1-2--DEBUG [CompactionExecutor:583] 2020-09-25 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables", "1-3--DEBUG [CompactionExecutor:584] 2020-09-25 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables", "1-4--DEBUG [CompactionExecutor:583] 2020-09-25 00:49:59,666 TimeWindowCompactionStrategy.java:117 - TWCS expired check sufficiently far in the past, checking for fully expired SSTables", "1-5--DEBUG [CompactionExecutor:583] 2020-09-25 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables", "1-6--DEBUG [CompactionExecutor:583] 2020-09-25 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables", "1-7--WARN [Native-Transport-Requests-1] 2020-09-25 00:50:01,043 SelectStatement.java:429 - Aggregation query used without partition key", "1-8--WARN [Native-Transport-Requests-1] 2020-09-25 00:50:04,072 SelectStatement.java:429 - Aggregation query used without partition key", "1-9--INFO [Thread-3] 2020-09-25 00:50:08,837 IndexMatrixSchema.java:143 - [object] No need to add fields", "1-10--INFO [Thread-8] 2020-09-25 00:50:08,840 IndexMatrixSchema.java:143 - [vobject] No need to add fields"} ) ; err != nil {*/
- /*if rst,meta,err := stat.Exec( "file1.log", "linux:wecise", `1-1--DEBUG [CompactionExecutor:584] 2020-11-25 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- 1-2--DEBUG [CompactionExecutor:583] 2020-11-25 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- 1-3--DEBUG [CompactionExecutor:584] 2020-11-25 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- 1-4--DEBUG [CompactionExecutor:583] 2020-11-25 00:49:59,666 TimeWindowCompactionStrategy.java:117 - TWCS expired check sufficiently far in the past, checking for fully expired SSTables
- 1-5--DEBUG [CompactionExecutor:583] 2020-11-25 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- 1-6--DEBUG [CompactionExecutor:583] 2020-11-25 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
- 1-7--WARN [Native-Transport-Requests-1] 2020-11-25 00:50:01,043 SelectStatement.java:429 - Aggregation query used without partition key
- 1-8--WARN [Native-Transport-Requests-1] 2020-11-25 00:50:04,072 SelectStatement.java:429 - Aggregation query used without partition key
- 1-9--INFO [Thread-3] 2020-11-25 00:50:08,837 IndexMatrixSchema.java:143 - [object] No need to add fields
- 1-10--INFO [Thread-8] 2020-11-25 00:50:08,840 IndexMatrixSchema.java:143 - [vobject] No need to add fields` ) ; err != nil {*/
- //if rst,meta,err := stat.Exec( 1, "wecise2", "oidgroup2", 1.62399934e+12, map[string]interface{}{"_raw":map[string]interface{}{"IPaddress":"172.26.38.248","Node":"172.26.38.248","PeerAddress":"172.26.38.248","PeerIPaddress":"172.26.38.248","Protocol":"udp","ReceivedPort":161,"ReceivedTime":0,"ReqId":106339259,"SNMP_Version":"2c","community":"public","contextEngineID":"","enterprise":"","generic-trap":0,"host":"172.26.38.248","message":"","monitorHost":"wecise","oidGroupName":"oidgroup2","pollInterval":20,"port":161,"profile":"","requestTime":1623581834003,"responseTIme":1623581834038,"returnStatus":"success","securityEngineID":"1234","securityLevel":"authPriv","securityName":"user","service":"snmp","snmpName1":"hostname","snmpName2":"ifIndex","snmpName3":"ifDescr","snmpName4":"ifSpeed","snmpName5":"ifAdminStatus","snmpName6":"ifInOctets","snmpName7":"ifOutOctets","snmpOid1":".1.3.6.1.2.1.1.5.0","snmpOid2":".1.3.6.1.2.1.2.2.1.1.2","snmpOid3":".1.3.6.1.2.1.2.2.1.2.2","snmpOid4":".1.3.6.1.2.1.2.2.1.5.2","snmpOid5":".1.3.6.1.2.1.2.2.1.7.2","snmpOid6":".1.3.6.1.2.1.2.2.1.10.2","snmpOid7":".1.3.6.1.2.1.2.2.1.16.2","snmpResult1":"wecise2","snmpResult2":2,"snmpResult3":"eth0","snmpResult4":0,"snmpResult5":1,"snmpResult6":2800559630,"snmpResult7":4261235364,"specific-trap":0,"taskTime":1623581834001}}, "172.26.38.248eth0oidgroup221", 2, "linux:172.26.38.248", "172.26.38.248", 2, 1, 1.623581834e+12, "设备: 172.26.38.248 端口: eth0 进流量当前值为: 137499 出流量当前值为: 4444444", "刘东", "300", "SNMP Monitor", "eth0", "linux SNMP Monitor") ; err != nil {
- //if rst,meta,err := stat.Exec( "hmc:node3", map[string]string{"list":"/testorg-6"}) ; err != nil {
- //if rst,meta,err := stat.Exec( []interface{}{"/newadmin2", nil}) ; err != nil {
- //if rst,meta,err := stat.Exec( map[string]string{"list2":"/testorg-6"}, "hmc:node3" ) ; err != nil {
- //if rst,meta,err := stat.Exec( "wecise" ) ; err != nil {
- //if rst,meta,err := stat.Exec( map[string]string{"home":"matrix/files"}, "usr" ) ; err != nil {
- //if rst,meta,err := stat.Exec( "list2", "hmc:node3" ) ; err != nil {
- //if rst,meta,err := stat.Exec( map[string]string{"list3":"/testorg+2"}, "wecise", "hmc:node3" ) ; err != nil {
- //stat,err := g.Prepare(`update /matrix/devops/alert set status = 12 where id = ? `)
- //stat,err := g.Prepare(`update /matrix/devops/alert set props = props + ? where severity = ? `)
- //stat, err := g.Prepare(`update /matrix/portal/tools set _group = ? where name in ? `)
- /*stat, err := g.Prepare(`insert into /native/nntest (syscode, appname, minute, busuid, origsenddate, msgtype, node, msgdealsch) values (?, ?, ?, ?, ?, ?, ?, ?) `)
- if err != nil {
- logger.Errorf("%v", err)
- }*/
- //_, _, err = stat.Exec( map[string][]interface{}{ "add": []interface{}{"网络部"}, "delete": []interface{}{"网络部"}, "edit": []interface{}{"网络部"}, "list": []interface{}{"网络部"}}, []interface{}{"配置管理"} )
- //_, _, err = stat.Exec( map[string][]interface{}{ "add": []interface{}{"市场部"}}, []interface{}{"配置管理"} )
- //_, _, err = stat.Exec( nil, []interface{}{"配置管理"} )
- /*_, _, err = stat.Exec( "BEPS" , "PMTS", 3, "2022060961524878", "20220725", "ccms.990.001.02", "9102-CCPC", 5.5 )
- if err != nil {
- logger.Errorf("%v", err)
- }*/
- /*stat, err := g.Prepare(`insert into /test/prepare (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool, v_timestamp) values (?, ?, ?, ?, ?, ?, ?, ? ,? )`)
- _, _, err = stat.Exec("*abc*", `hello word 2003 123-456-789 中华人民共和国是中国的唯一合法政府,台湾是中国一部分。 Mercury, Venus2,Earch%。Mars$Uranus CeresAndJupiterOrSaturn #Neptune Pluto_Charon"\""`, 1, 1234567890123456789, 1.1, 1.1234567890123456, 1.123456, true, nil)*/
- stat, err := g.Prepare(`insert into /test/enum (v_varchar, v_enum ) values (?, ?)`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- //_, _, err = stat.Exec("bucketpromdb:wecise", []interface{}{
- _, _, err = stat.Exec("3", "软件")
- /*_, _, err = stat.Exec("bucketpromdb:wecise", []map[string]interface{}{
- { "name":"key1", "value":2.7, "timestamp":"2021-07-28 11:24:17"},
- { "name":"key2", "value":2.8, "timestamp":"2021-07-28 11:25:18"} } )
- */
- /*stat, err := g.Prepare(`update /matrix/group set sdata = sdata - ? where fullname = ?`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- _, _, err = stat.Exec( map[string]interface{}{ "/matrix/devops/alerts_status": "{ \"type\": \"match\", \"field\": \"varchar_126\", \"value\":\"alertgroup\" }",
- "~/matrix/devops/alerts_status": "alertgroup='alertgroup'" }, "/网络部")
- //_, _, err = stat.Exec( []string{ "/matrix/devops/alerts_status", "~/matrix/devops/alerts_status" }, "/网络部")
- if err != nil {
- logger.Errorf("%v", err)
- }*/
- /*stat, err := g.Prepare(`update /test/mpartition set tags=tags+? where class = ? and id=?`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- _, _, err = stat.Exec( map[string]interface{}{ "hello", "/test/mpartition/7228936349925816366", "13234872624831284182")
- */
- /*stat4, err4 := g.Prepare(`insert into /test/malert_status_memdb (identifier, severity, lastoccurrence, maintenance, msg, type, agent, firstoccurrence, omni_class, nodealias, alertgroup, node, manager, originalseverity, summary, tags) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict update firstoccurrence=firstoccurrence, servicenowstate=servicenowstate, emailstatus=emailstatus, tally=tally+1`)
- if err4 != nil {
- logger.Errorf("%v", err4)
- }
- wgg := wgwaiter.NewWaiter()
- DEFAULT_MQL_CONCURRENT_NUM := runtime.NumCPU()
- for kk := 0; kk < 10; kk++ {
- for i := kk * DEFAULT_MQL_CONCURRENT_NUM; i < (kk+1)*DEFAULT_MQL_CONCURRENT_NUM; i++ {
- wgg.AddOne()
- go func(ii int) {
- mtype := ii % 10
- tag := "mytag"
- switch mtype {
- case 1 : tag = "mytag1"
- case 2 : tag = "mytag2"
- case 3 : tag = "mytag3"
- case 4 : tag = "mytag4"
- case 5 : tag = "mytag5"
- }
- _, _, err := stat4.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6"+strconv.Itoa(ii), 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", mtype, "huawei mttrapd #"+strconv.Itoa(ii%100), 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "MTTrapd Probe", 5, "设备:222.129.134.178电源整体功能恢复!", tag)
- if err != nil {
- wgg.Fail(err)
- } else {
- wgg.Done()
- }
- }(i)
- }
- if err := wgg.Wait(upsert.DEFAULT_MQL_TIMEOUT * time.Second); err != nil {
- logger.Error(err)
- }
- logger.Debug("concurrent insert malert_status_memdb test, loop ", kk)
- }*/
- /*stat4, err4 := g.Prepare(`insert into /testruledata (id, rawlogs) values (?, ?)`)
- if err4 != nil {
- logger.Errorf("%v", err4)
- }
- _, _, err = stat4.Exec("node:10.1.1.183", map[string]interface{}{"__name__":"aaa", "__value__":"testtestdasdfasfd手动阀十分","__timestamp__":"2024-08-28 10:27:01"})
- if err != nil {
- logger.Errorf("%v", err)
- }*/
- /*stat2, err := g.Prepare(`update /test/malert_status set severity = ?, lastoccurrence=?, maintenance=?, msg=?, type=?, firstoccurrence=?, omni_class=?, nodealias=?, alertgroup=?, manager=?, _tokens=?, originalseverity=?, summary=? where identifier = ?`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- wgg := wgwaiter.NewWaiter()
- DEFAULT_MQL_CONCURRENT_NUM := runtime.NumCPU()
- for kk := 0; kk < 2; kk++ {
- for i := kk * DEFAULT_MQL_CONCURRENT_NUM; i < (kk+1)*DEFAULT_MQL_CONCURRENT_NUM; i++ {
- wgg.AddOne()
- go func(ii int) {
- _, _, err := stat2.Exec( 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, 1622211715023, "300", "222.129.134.178", "huawei_power_func", "MTTrapd Probe", map[string]interface{}{"_raw": "{\"1\":\"SNMP Trap Test.see more:http://www.micmiu.com\",\"1_hex\":\"53 4e 4d 50 20 54 72 61 70 20 54 65 73 74 2e 73 65 65 20 6d 6f 72 65 3a 68 74 74 70 3a 2f 2f 77 77 77 2e 6d 69 63 6d 69 75 2e 63 6f 6d\",\"1_raw\":\"SNMP Trap Test.see more:http://www.micmiu.com\",\"1_text\":\"SNMP Trap Test.see more:http://www.micmiu.com\",\"2\":\"1000\",\"2_hex\":\"1000\",\"2_raw\":\"1000\",\"2_text\":\"1000\",\"3\":\".1.3.6.1.4.1.2011.5.25.219.2.5.6\",\"3_hex\":\".1.3.6.1.4.1.2011.5.25.219.2.5.6\",\"3_raw\":\".1.3.6.1.4.1.2011.5.25.219.2.5.6\",\"3_text\":\".1.3.6.1.4.1.2011.5.25.219.2.5.6\",\"4\":\"SNMPTEST\",\"4_hex\":\"53 4e 4d 50 54 45 53 54\",\"4_raw\":\"SNMPTEST\",\"4_text\":\"SNMPTEST\",\"5\":10,\"5_hex\":10,\"5_raw\":10,\"5_text\":10,\"6\":\"Sat May 29 08:55:14 CST 2021\",\"6_hex\":\"53 61 74 20 4d 61 79 20 32 39 20 30 38 3a 35 35 3a 31 34 20 43 53 54 20 32 30 32 31\",\"6_raw\":\"Sat May 29 08:55:14 CST 2021\",\"6_text\":\"Sat May 29 08:55:14 CST 2021\",\"IPaddress\":\"222.129.134.178\",\"Node\":\"222.129.134.178\",\"OID1\":\".1.3.6.1.2.1.1.1.1\",\"OID2\":\".1.3.6.1.2.1.1.3.0\",\"OID3\":\".1.3.6.1.6.3.1.1.4.1.0\",\"OID4\":\".1.3.6.1.4.1.2011.2.15.2.1.2.1.1.1.1\",\"OID5\":\".1.3.6.1.4.1.2011.2.15.2.1.2.1.1.1.2\",\"OID6\":\".1.3.6.1.4.1.2011.2.15.2.1.2.1.1.1.3\",\"PeerAddress\":\"222.129.134.178\",\"PeerIPaddress\":\"222.129.134.178\",\"Protocol\":\"udp\",\"ReceivedPort\":9162,\"ReceivedTime\":0,\"ReqId\":176301626,\"SNMP_Version\":\"2c\",\"UpTime\":\"1000\",\"Uptime\":\"8:16:40.00\",\"community\":\"public\",\"contextEngineID\":\"\",\"enterprise\":\"\",\"generic-trap\":0,\"notify\":\".1.3.6.1.4.1.2011.5.25.219.2.5.6\",\"securityEngineID\":\"1234\",\"securityLevel\":\"authPriv\",\"securityName\":\"user\",\"specific-trap\":0}"}, 5, "设备:222.129.134.178电源整体功能恢复!", "222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6"+strconv.Itoa(ii))
- if err != nil {
- wgg.Fail(err)
- } else {
- wgg.Done()
- }
- }(i)
- if err := wgg.Wait(upsert.DEFAULT_MQL_TIMEOUT * time.Second); err != nil {
- logger.Error(err)
- }
- }
- if kk % 100 == 0 {
- logger.Infof("send %d", kk * DEFAULT_MQL_CONCURRENT_NUM )
- }
- }
- if err != nil {
- logger.Errorf("%v", err)
- }
- time.Sleep(1 * time.Second)*/
- //g.Query(`SELECT prom.date("2021-07-28") FROM /test/bucketpromdb`)
- /*stat, err = g.Prepare(`insert into /matrix/ldap (fullname, id, isactive, isadmin, lft, otype, parent, passwd, rands, rgt, salt, username) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- _, _, err = stat.Exec("/admin", "8614306950096011366", true, true, 2, "usr", "/", "e9c4b39cf0b7f2e9b38c0b26b44d19ce3781a4c94491b05a4ec0f5284201f841b934480361c361879053fa2780b659609eb1", "fEEWuYMPG8", 3, "V614xVB9nQ", "admin")
- if err != nil {
- logger.Errorf("%v", err)
- }*/
- }
|