testexec.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. package main
  2. import (
  3. //"fmt"
  4. //"time"
  5. //"runtime"
  6. //"strconv"
  7. //"runtime"
  8. //"strconv"
  9. "gitee.com/wecisecode/util/logger"
  10. //"git.wecise.com/wecise/odbserver/lib/wgwaiter"
  11. //"git.wecise.com/wecise/odbserver/odb"
  12. . "git.wecise.com/wecise/odbserver/odb"
  13. //"git.wecise.com/wecise/odbserver/odb/redisvr"
  14. "git.wecise.com/wecise/odbserver/odb/test"
  15. //"git.wecise.com/wecise/odbserver/odb/upsert"
  16. //"git.wecise.com/wecise/odbserver/lib/wgwaiter"
  17. )
  18. // CGO_ENABLED=1 go run --ldflags '-linkmode external -extldflags "-static"' testexec.go
  19. // #cgo LDFLAGS: -L/opt/odbserver/sqlite -lsqlite -ldl
  20. // #include "/opt/odbserver/sqlite/sqlite.h"
  21. // #include <stdint.h>
  22. // #include <stdlib.h>
  23. // extern int64_t uhaha_seed;
  24. // extern int64_t uhaha_ts;
  25. // void uhaha_begin_reader();
  26. // void uhaha_end_reader();
  27. func main() {
  28. //options := map[string]interface{} {"cache":odb.CacheAll}
  29. //g,err:= odb.New( options )
  30. //option := &StoreOption{Cache:CacheAll}
  31. //option := &Option{Cache: CacheAll, Keyspace: "oootest", DisableInitialHostLookup: true, DisableNotify: true}
  32. option := &Option{Cache: CacheAll, Keyspace: "oootest", DisableInitialHostLookup: true}
  33. g, err := test.NewG(option)
  34. if err != nil {
  35. logger.Error(err.Error())
  36. } else {
  37. defer g.Close()
  38. }
  39. //logger.SetRollingDaily("C:/test/zkcron/src/test", "test.log")
  40. logger.SetConsole(true)
  41. logger.SetLevel(logger.TRACE)
  42. //stat,err := g.Prepare(`insert into /matrix/clickcount count=?`)
  43. //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 = ? ) ) `)
  44. //stat,err := g.Prepare(`update /matrix/entity/hmc set config=config +?, location=? where id= ? `)
  45. //stat,err := g.Prepare(` insert into /matrix/tagdir (creater, domain, name, parent, path, tags) values (?, ?, ?, ?, ?, ?) `)
  46. //stat,err := g.Prepare(`delete from /matrix/system/hostinfo where host=? `)
  47. //stat,err := g.Prepare(`update /matrix/ldap set config = config + ? where otype=? refresh`)
  48. //stat,err := g.Prepare(`update /matrix/ldap set config = config + ? where otype=? refresh`)
  49. //stat,err := g.Prepare(`insert into /matrix/entity/hmc (id, config) values (?, ?)`)
  50. //stat,err := g.Prepare(`update / set tags = tags - 'abcdssssss123' where id in ?`)
  51. //stat,err := g.Prepare(`update /matrix/portal/tools set _group=_group+? where name in ? refresh`)
  52. //stat,err := g.Prepare(`insert into /matrix/devops/alert (src, ctime, type, _tokens, ip, entity, severity, msg) values (?, ?, ?, ?, ?, ?, ?, ?)`)
  53. //stat,err := g.Prepare(`insert into /matrix/action/callrecord (id, location, longitude, lac, ci, oppositenumber, starttime, bycall, name, blocation, dimensionality, phonenumber, period, callto) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)`)
  54. //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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
  55. //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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?)`)
  56. //stat,err := g.Prepare(`insert into /matrix/testbucket6 (id, bkdata[?]) values (?, ?) at ? `)
  57. //stat,err := g.Prepare(`update / set tags = tags + "aaa" where id in ?`)
  58. //stat,err := g.Prepare(`insert into /matrix/testbucket5 (id, bk2['file1.log']) values (?, ?) `)
  59. //stat,err := g.Prepare(` insert into /matrix/entity/linux (id,disk_perf) values (?, ?) at ?`)
  60. //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`)
  61. //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`)
  62. //stat, err := g.Prepare(`insert into /matrix/test/bucketlog (id, bklog['file1.log']) values (?, ?)`)
  63. //stat,err := g.Prepare(`update /matrix/portal/tools set _group = _group + ? where name in ?`)
  64. //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`)
  65. //stat, err := g.Prepare( `insert into /matrix/test/bucketlog (id, bklog[?]) values (?, ?)`)
  66. //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`)
  67. //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`)
  68. //stat,err := g.Prepare(` insert into /matrix/devops/alert_status (identifier, firstoccurrence) values (?, ?) `)
  69. //stat,err := g.Prepare(`update /matrix/entity/node set connect = connect + ?, assetid= ? where id=?`)
  70. //stat,err := g.Prepare(` insert into /matrix/system/depot set tags =? , name=?, version=?, remark=?`)
  71. /*if stat,err := g.Prepare(`insert into /matrix/testgroup g1=?, g2=?, g3=?, v1=? , v2=? , f1=? , f2=?`) ;err != nil {
  72. logger.Info("Prepare error:"+err.Error())
  73. }else{
  74. logger.Errorf("%v", stat)
  75. //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 }})
  76. rst,meta,err := stat.Exec( "g0000","g00", map[string]interface{}{"bank":"tag8","core":"tag8"}, 88 , 88, 88.88,88.88 )
  77. if err != nil {
  78. logger.Info("Query error:"+err.Error())
  79. }else{
  80. logger.Info("rst ===>", rst)
  81. //logger.Error("meta ===>", meta)
  82. if meta["trace"] != nil && len(meta["trace"].([]string)) > 0 {
  83. for _, msg := range meta["trace"].([]string) {
  84. logger.Error(msg)
  85. }
  86. }
  87. logger.Warn(meta["columns"])
  88. }
  89. }*/
  90. /*if stat,err := g.Prepare(`update /matrix/clickcount set count=1 where id=?`) ;err != nil {
  91. logger.Info("Prepare error:"+err.Error())
  92. }else{
  93. logger.Errorf("%v", stat)
  94. //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 }})
  95. rst,meta,err := stat.Exec()
  96. if err != nil {
  97. logger.Info("Query error:"+err.Error())
  98. }else{
  99. logger.Info("rst ===>", rst)
  100. //logger.Error("meta ===>", meta)
  101. if meta["trace"] != nil && len(meta["trace"].([]string)) > 0 {
  102. for _, msg := range meta["trace"].([]string) {
  103. logger.Error(msg)
  104. }
  105. }
  106. logger.Warn(meta["columns"])
  107. }
  108. }*/
  109. /*if err != nil {
  110. logger.Errorf("%v", err)
  111. return
  112. }*/
  113. //for i:=0 ;i <=10 ; i++ {
  114. //if rst,meta,err := stat.Exec( []string{"SCRIPT"}, "test12", "10", nil ) ; err != nil {
  115. /*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
  116. DEBUG [CompactionExecutor:583] 2020-05-15 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
  117. DEBUG [CompactionExecutor:584] 2020-05-15 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
  118. 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
  119. DEBUG [CompactionExecutor:583] 2020-05-15 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
  120. DEBUG [CompactionExecutor:583] 2020-05-15 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
  121. WARN [Native-Transport-Requests-1] 2020-05-15 00:50:01,043 SelectStatement.java:429 - Aggregation query used without partition key
  122. WARN [Native-Transport-Requests-1] 2020-05-15 00:50:04,072 SelectStatement.java:429 - Aggregation query used without partition key
  123. INFO [Thread-3] 2020-05-15 00:50:08,837 IndexMatrixSchema.java:143 - [object] No need to add fields
  124. INFO [Thread-8] 2020-05-15 00:50:08,840 IndexMatrixSchema.java:143 - [vobject] No need to add fields
  125. WARN [Native-Transport-Requests-2] 2020-05-15 00:50:14,231 SelectStatement.java:429 - Aggregation query used without partition key
  126. WARN [Native-Transport-Requests-2] 2020-05-15 00:50:31,326 SelectStatement.java:429 - Aggregation query used without partition key
  127. WARN [Native-Transport-Requests-1] 2020-05-15 00:50:34,163 SelectStatement.java:429 - Aggregation query used without partition key
  128. WARN [Native-Transport-Requests-1] 2020-05-15 00:50:44,342 SelectStatement.java:429 - Aggregation query used without partition key` } ) ; err != nil {*/
  129. //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 {
  130. //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 {
  131. //if rst,meta,err := stat.Exec("id1",[]string{"id5"}) ; err != nil {
  132. //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 {
  133. //if rst,meta,err := stat.Exec( "linux:wecise", []interface{}{ 1, nil, 3.3, 6.5, "3234567890" }, "2020-04-24 22:24:15" ) ; err != nil {
  134. //if rst,meta,err := stat.Exec("domain", "name", 60, 100, 5, 50, 100, 10, []string{"hello:world"}) ; err != nil {
  135. //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 {
  136. /*if rst,meta,err := stat.Exec( "wecise3",[]string{"192.168.100.100", "192.168.31.125"}, "aix",`{
  137. "os": "aix",
  138. "host": "wecise3",
  139. "pid": "188776",
  140. "matrixroot": "/opt/matrix",
  141. "cpu_usedpercent": "0.00",
  142. "memory_usedpercent": "17.80",
  143. "disk_usedpercent": "0.54",
  144. "disk_total": "139776",
  145. "disk_free": "64000"
  146. }`) ; err != nil {*/
  147. //if rst,meta,err := stat.Exec( []string{ "node:DFD9255-940106-1"} ) ; err != nil {
  148. /*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 {*/
  149. /*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
  150. 1-2--DEBUG [CompactionExecutor:583] 2020-11-25 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
  151. 1-3--DEBUG [CompactionExecutor:584] 2020-11-25 00:49:59,666 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
  152. 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
  153. 1-5--DEBUG [CompactionExecutor:583] 2020-11-25 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
  154. 1-6--DEBUG [CompactionExecutor:583] 2020-11-25 00:49:59,667 TimeWindowCompactionStrategy.java:124 - TWCS skipping check for fully expired SSTables
  155. 1-7--WARN [Native-Transport-Requests-1] 2020-11-25 00:50:01,043 SelectStatement.java:429 - Aggregation query used without partition key
  156. 1-8--WARN [Native-Transport-Requests-1] 2020-11-25 00:50:04,072 SelectStatement.java:429 - Aggregation query used without partition key
  157. 1-9--INFO [Thread-3] 2020-11-25 00:50:08,837 IndexMatrixSchema.java:143 - [object] No need to add fields
  158. 1-10--INFO [Thread-8] 2020-11-25 00:50:08,840 IndexMatrixSchema.java:143 - [vobject] No need to add fields` ) ; err != nil {*/
  159. //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 {
  160. //if rst,meta,err := stat.Exec( "hmc:node3", map[string]string{"list":"/testorg-6"}) ; err != nil {
  161. //if rst,meta,err := stat.Exec( []interface{}{"/newadmin2", nil}) ; err != nil {
  162. //if rst,meta,err := stat.Exec( map[string]string{"list2":"/testorg-6"}, "hmc:node3" ) ; err != nil {
  163. //if rst,meta,err := stat.Exec( "wecise" ) ; err != nil {
  164. //if rst,meta,err := stat.Exec( map[string]string{"home":"matrix/files"}, "usr" ) ; err != nil {
  165. //if rst,meta,err := stat.Exec( "list2", "hmc:node3" ) ; err != nil {
  166. //if rst,meta,err := stat.Exec( map[string]string{"list3":"/testorg+2"}, "wecise", "hmc:node3" ) ; err != nil {
  167. //stat,err := g.Prepare(`update /matrix/devops/alert set status = 12 where id = ? `)
  168. //stat,err := g.Prepare(`update /matrix/devops/alert set props = props + ? where severity = ? `)
  169. //stat, err := g.Prepare(`update /matrix/portal/tools set _group = ? where name in ? `)
  170. /*stat, err := g.Prepare(`insert into /native/nntest (syscode, appname, minute, busuid, origsenddate, msgtype, node, msgdealsch) values (?, ?, ?, ?, ?, ?, ?, ?) `)
  171. if err != nil {
  172. logger.Errorf("%v", err)
  173. }*/
  174. //_, _, err = stat.Exec( map[string][]interface{}{ "add": []interface{}{"网络部"}, "delete": []interface{}{"网络部"}, "edit": []interface{}{"网络部"}, "list": []interface{}{"网络部"}}, []interface{}{"配置管理"} )
  175. //_, _, err = stat.Exec( map[string][]interface{}{ "add": []interface{}{"市场部"}}, []interface{}{"配置管理"} )
  176. //_, _, err = stat.Exec( nil, []interface{}{"配置管理"} )
  177. /*_, _, err = stat.Exec( "BEPS" , "PMTS", 3, "2022060961524878", "20220725", "ccms.990.001.02", "9102-CCPC", 5.5 )
  178. if err != nil {
  179. logger.Errorf("%v", err)
  180. }*/
  181. /*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 (?, ?, ?, ?, ?, ?, ?, ? ,? )`)
  182. _, _, 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)*/
  183. stat, err := g.Prepare(`insert into /test/enum (v_varchar, v_enum ) values (?, ?)`)
  184. if err != nil {
  185. logger.Errorf("%v", err)
  186. }
  187. //_, _, err = stat.Exec("bucketpromdb:wecise", []interface{}{
  188. _, _, err = stat.Exec("3", "软件")
  189. /*_, _, err = stat.Exec("bucketpromdb:wecise", []map[string]interface{}{
  190. { "name":"key1", "value":2.7, "timestamp":"2021-07-28 11:24:17"},
  191. { "name":"key2", "value":2.8, "timestamp":"2021-07-28 11:25:18"} } )
  192. */
  193. /*stat, err := g.Prepare(`update /matrix/group set sdata = sdata - ? where fullname = ?`)
  194. if err != nil {
  195. logger.Errorf("%v", err)
  196. }
  197. _, _, err = stat.Exec( map[string]interface{}{ "/matrix/devops/alerts_status": "{ \"type\": \"match\", \"field\": \"varchar_126\", \"value\":\"alertgroup\" }",
  198. "~/matrix/devops/alerts_status": "alertgroup='alertgroup'" }, "/网络部")
  199. //_, _, err = stat.Exec( []string{ "/matrix/devops/alerts_status", "~/matrix/devops/alerts_status" }, "/网络部")
  200. if err != nil {
  201. logger.Errorf("%v", err)
  202. }*/
  203. /*stat, err := g.Prepare(`update /test/mpartition set tags=tags+? where class = ? and id=?`)
  204. if err != nil {
  205. logger.Errorf("%v", err)
  206. }
  207. _, _, err = stat.Exec( map[string]interface{}{ "hello", "/test/mpartition/7228936349925816366", "13234872624831284182")
  208. */
  209. /*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`)
  210. if err4 != nil {
  211. logger.Errorf("%v", err4)
  212. }
  213. wgg := wgwaiter.NewWaiter()
  214. DEFAULT_MQL_CONCURRENT_NUM := runtime.NumCPU()
  215. for kk := 0; kk < 10; kk++ {
  216. for i := kk * DEFAULT_MQL_CONCURRENT_NUM; i < (kk+1)*DEFAULT_MQL_CONCURRENT_NUM; i++ {
  217. wgg.AddOne()
  218. go func(ii int) {
  219. mtype := ii % 10
  220. tag := "mytag"
  221. switch mtype {
  222. case 1 : tag = "mytag1"
  223. case 2 : tag = "mytag2"
  224. case 3 : tag = "mytag3"
  225. case 4 : tag = "mytag4"
  226. case 5 : tag = "mytag5"
  227. }
  228. _, _, 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)
  229. if err != nil {
  230. wgg.Fail(err)
  231. } else {
  232. wgg.Done()
  233. }
  234. }(i)
  235. }
  236. if err := wgg.Wait(upsert.DEFAULT_MQL_TIMEOUT * time.Second); err != nil {
  237. logger.Error(err)
  238. }
  239. logger.Debug("concurrent insert malert_status_memdb test, loop ", kk)
  240. }*/
  241. /*stat4, err4 := g.Prepare(`insert into /testruledata (id, rawlogs) values (?, ?)`)
  242. if err4 != nil {
  243. logger.Errorf("%v", err4)
  244. }
  245. _, _, err = stat4.Exec("node:10.1.1.183", map[string]interface{}{"__name__":"aaa", "__value__":"testtestdasdfasfd手动阀十分","__timestamp__":"2024-08-28 10:27:01"})
  246. if err != nil {
  247. logger.Errorf("%v", err)
  248. }*/
  249. /*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 = ?`)
  250. if err != nil {
  251. logger.Errorf("%v", err)
  252. }
  253. wgg := wgwaiter.NewWaiter()
  254. DEFAULT_MQL_CONCURRENT_NUM := runtime.NumCPU()
  255. for kk := 0; kk < 2; kk++ {
  256. for i := kk * DEFAULT_MQL_CONCURRENT_NUM; i < (kk+1)*DEFAULT_MQL_CONCURRENT_NUM; i++ {
  257. wgg.AddOne()
  258. go func(ii int) {
  259. _, _, 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))
  260. if err != nil {
  261. wgg.Fail(err)
  262. } else {
  263. wgg.Done()
  264. }
  265. }(i)
  266. if err := wgg.Wait(upsert.DEFAULT_MQL_TIMEOUT * time.Second); err != nil {
  267. logger.Error(err)
  268. }
  269. }
  270. if kk % 100 == 0 {
  271. logger.Infof("send %d", kk * DEFAULT_MQL_CONCURRENT_NUM )
  272. }
  273. }
  274. if err != nil {
  275. logger.Errorf("%v", err)
  276. }
  277. time.Sleep(1 * time.Second)*/
  278. //g.Query(`SELECT prom.date("2021-07-28") FROM /test/bucketpromdb`)
  279. /*stat, err = g.Prepare(`insert into /matrix/ldap (fullname, id, isactive, isadmin, lft, otype, parent, passwd, rands, rgt, salt, username) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
  280. if err != nil {
  281. logger.Errorf("%v", err)
  282. }
  283. _, _, err = stat.Exec("/admin", "8614306950096011366", true, true, 2, "usr", "/", "e9c4b39cf0b7f2e9b38c0b26b44d19ce3781a4c94491b05a4ec0f5284201f841b934480361c361879053fa2780b659609eb1", "fEEWuYMPG8", 3, "V614xVB9nQ", "admin")
  284. if err != nil {
  285. logger.Errorf("%v", err)
  286. }*/
  287. }