| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129 |
- package conflict
- import (
- "fmt"
- "os"
- "runtime"
- "strconv"
- "strings"
- "sync"
- "testing"
- "time"
- "git.wecise.com/wecise/odbserver/lib/wgwaiter"
- . "git.wecise.com/wecise/odbserver/odb"
- "git.wecise.com/wecise/odbserver/odb/test"
- "gitee.com/wecisecode/util/logger"
- "gitee.com/wecisecode/util/set/strset"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- //"git.wecise.com/wecise/util/cast"
- "git.wecise.com/wecise/odb-go/odb"
- )
- type ConflictTests struct {
- Test *testing.T
- g *Gutil
- }
- func GT(t *testing.T, g *Gutil) *ConflictTests {
- return &ConflictTests{Test: t, g: g}
- }
- var odbcfg *odb.Config
- func init() {
- odbpath := os.Getenv("ODBPATH")
- if odbpath == "" {
- odbpath = "47.92.151.165:11001"
- }
- odbpaths := strset.New(strings.Split(odbpath, ",")...).List()
- keyspace := os.Getenv("KEYSPACE")
- if keyspace == "" {
- keyspace = "ooootest"
- }
- odbcfg = &odb.Config{
- Hosts: odbpaths,
- Keyspace: keyspace,
- User: fmt.Sprint("测试客户端"),
- Pass: "********",
- PoolSize: 20,
- Debug: true,
- }
- }
- func getClient() (c odb.Client, err error) {
- client, err := odb.NewClient(odbcfg)
- if err != nil {
- return nil, err
- }
- return client, nil
- }
- func ConflictTest(t *testing.T) {
- g := test.TestG()
- t.Run("InitG", func(t *testing.T) {
- test := &ConflictTests{Test: t, g: g}
- test.InitG()
- })
- t.Run("Class", func(t *testing.T) {
- test := &ConflictTests{Test: t, g: g}
- test.Class()
- })
- t.Run("Data", func(t *testing.T) {
- test := &ConflictTests{Test: t, g: g}
- test.Data()
- })
- /*t.Run("DataFromClient", func(t *testing.T) {
- test := &ConflictTests{Test: t, g: g}
- test.DataFromClient()
- })*/
- time.Sleep(time.Duration(1) * time.Second)
- t.Run("Valid", func(t *testing.T) {
- test := &ConflictTests{Test: t, g: g}
- test.Valid()
- })
- }
- func (t *ConflictTests) InitG() {
- require.NotNil(t.Test, t.g)
- }
- /*
- alter class /test/malert_status with notify = 2m
- insert into /test/malert_status (identifier, agent, node) values ('112', 'aaa', 'nnnn')
- update /test/malert_status set manager='1' where identifier='112'
- memcache.load('TESTCACHE2', 'mql', "select * from /test/malert_status limit -1", {{'identifier'}}, 10)
- local ret = memcache.query('TESTCACHE2', "identifier='111'")
- */
- func (t *ConflictTests) Class(trigger ...string) {
- if len(trigger) == 0 {
- trigger = append(trigger, `log.info("hello modify")`)
- }
- _, _, err := t.g.Query(`
- create class if not exists /test();
- create class if not exists /matrix/test ( identifier int) ;
- create class if not exists /test/alert_status (
- acknowledged int "acknowledged",
- msg varchar "msg",
- agent varchar "AAgent",
- alertgroup varchar "alertgroup",
- alertkey varchar "alertkey",
- bsm_classname varchar "bsm_classname",
- bsm_identity varchar "bsm_identity",
- bsm_subidentity varchar "bsm_subidentity",
- businessimpact int "businessimpact",
- causetype int "causetype",
- ciid varchar "ciid",
- cmdbenrichstatus int "cmdbenrichstatus",
- corrscore int "corrscore",
- customer varchar "customer",
- domaingroup varchar "domaingroup",
- domainsubgroup varchar "domainsubgroup",
- duration int "duration",
- emailstatus int "emailstatus",
- eventid varchar "eventid",
- eventtype enum {
- "10":["主机告警"],
- "11":["数据库告警"],
- "12":["中间件类告警"],
- "13":["应用类告警"],
- "14":["硬件类告警"],
- "99":["其他类告警"]} "事件类型",
- expiretime int "expiretime",
- extendedattr varchar "extendedattr",
- firstoccurrence timestamp "firstoccurrence",
- flash int "flash",
- grade int "grade",
- identifier varchar "identifier",
- internallast timestamp "internallast",
- lastoccurrence timestamp "lastoccurrence",
- localnodealias varchar "localnodealias",
- localobjrelate int "localobjrelate",
- localpriobj varchar "localpriobj",
- localrootobj varchar "localrootobj",
- localsecobj varchar "localsecobj",
- localtertobj varchar "localtertobj",
- location varchar "location",
- logticket int "logticket",
- maintenance enum {
- "0":["Unknown", "未知"],
- "1":["true", "维护期内"],
- "2":["false", "维护期外"]} "级别",
- manager varchar "manager",
- market varchar "market",
- netype varchar "netype",
- nmoscausetype int "nmoscausetype",
- nmosdomainname varchar "nmosdomainname",
- nmosentityid int "nmosentityid",
- nmoseventmap varchar "nmoseventmap",
- nmosmanagedstatus int "nmosmanagedstatus",
- nmosobjinst int "nmosobjinst",
- nmosserial varchar "nmosserial",
- node varchar "node",
- nodealias varchar "nodealias",
- nodename varchar "nodename",
- objectfullname varchar "objectfullname",
- oldrow int "oldrow",
- omni_class varchar "class",
- omni_serial int "serial",
- originalseverity int "originalseverity",
- ownergid int "ownergid",
- owneruid int "owneruid",
- physicalcard varchar "physicalcard",
- physicalport int "physicalport",
- physicalslot int "physicalslot",
- platform varchar "platform",
- poll int "poll",
- probesubsecondid int "probesubsecondid",
- processreq int "processreq",
- region varchar "region",
- remotenodealias varchar "remotenodealias",
- remoteobjrelate int "remoteobjrelate",
- remotepriobj varchar "remotepriobj",
- remoterootobj varchar "remoterootobj",
- remotesecobj varchar "remotesecobj",
- remotetertobj varchar "remotetertobj",
- servername varchar "servername",
- serverserial int "serverserial",
- service varchar "service",
- servicenowerrorcode int "servicenowerrorcode",
- servicenowstate int "servicenowstate",
- servicenowsysid varchar "servicenowsysid",
- severity enum {
- "0":["Unknown", "未知"],
- "1":["Trace", "追踪"],
- "2":["Debug", "调试"],
- "3":["Info", "消息"],
- "4":["Warn", "警告"],
- "5":["Error", "错误"],
- "6":["Fatal", "致命错误"]} "级别",
- siteid varchar "siteid",
- statechange timestamp "statechange",
- summary varchar "summary",
- suppressescl int "suppressescl",
- tally int "tally",
- tasklist int "tasklist",
- ticketstatus varchar "ticketstatus",
- ttnumber varchar "ttnumber",
- ttstate int "ttstate",
- ttuser varchar "ttuser",
- type enum {
- "0":["Type not set"],
- "1":["problem", "问题"],
- "2":["resolution", "恢复"],
- "7":["ISM new alarm", "问题"],
- "8":["ISM old alarm", "恢复"]} "类型",
- url varchar "url",
- x733corrnotif varchar "x733corrnotif",
- x733eventtype int "x733eventtype",
- x733probablecause int "x733probablecause",
- x733specificprob varchar "x733specificprob",
- prom bucket {
- "cache": true,
- "ttl": 365,
- "type": "promdb"
- } "prom",
- keys( identifier ) ,
- index( acknowledged,alertgroup,alertkey,bsm_classname,bsm_identity,bsm_subidentity,businessimpact,causetype,ciid,cmdbenrichstatus,corrscore,customer,domaingroup,domainsubgroup,emailstatus,eventid,eventtype,expiretime,extendedattr,firstoccurrence,flash,grade,identifier,internallast,lastoccurrence,localnodealias,localobjrelate,localpriobj,localrootobj,localsecobj,localtertobj,location,logticket,manager,market,netype,nmoscausetype,nmosdomainname,nmosentityid,nmoseventmap,nmosmanagedstatus,nmosobjinst,nmosserial,node,nodealias,nodename,objectfullname,oldrow,omni_serial,originalseverity,ownergid,owneruid,physicalcard,physicalport,physicalslot,platform,poll,probesubsecondid,processreq,region,remotenodealias,remoteobjrelate,remotepriobj,remoterootobj,remotesecobj,remotetertobj,servername,serverserial,service,servicenowerrorcode,servicenowstate,servicenowsysid,severity,siteid,statechange,summary,suppressescl,tally,tasklist,ticketstatus,ttnumber,ttstate,ttuser,type,url,x733corrnotif,x733eventtype,x733probablecause,x733specificprob)
- )with ttl=366 day , autosearch=true , history=true , version=true , key=manu, alias='alert_status_test' , nickname='alert_status_test';
-
- create class if not exists /test/malert_status (
- acknowledged int "acknowledged",
- msg varchar "msg",
- agent varchar "AAgent",
- alertgroup varchar "alertgroup",
- alertkey varchar "alertkey",
- bsm_classname varchar "bsm_classname",
- bsm_identity varchar "bsm_identity",
- bsm_subidentity varchar "bsm_subidentity",
- businessimpact int "businessimpact",
- causetype int "causetype",
- ciid varchar "ciid",
- cmdbenrichstatus int "cmdbenrichstatus",
- corrscore int "corrscore",
- customer varchar "customer",
- domaingroup varchar "domaingroup",
- domainsubgroup varchar "domainsubgroup",
- duration int "duration",
- emailstatus int "emailstatus",
- eventid varchar "eventid",
- eventtype enum {
- "10":["主机告警"],
- "11":["数据库告警"],
- "12":["中间件类告警"],
- "13":["应用类告警"],
- "14":["硬件类告警"],
- "99":["其他类告警"]} "事件类型",
- expiretime int "expiretime",
- extendedattr varchar "extendedattr",
- firstoccurrence timestamp "firstoccurrence",
- flash int "flash",
- grade int "grade",
- identifier varchar "identifier",
- internallast timestamp "internallast",
- lastoccurrence timestamp "lastoccurrence",
- localnodealias varchar "localnodealias",
- localobjrelate int "localobjrelate",
- localpriobj varchar "localpriobj",
- localrootobj varchar "localrootobj",
- localsecobj varchar "localsecobj",
- localtertobj varchar "localtertobj",
- location varchar "location",
- logticket int "logticket",
- maintenance enum {
- "0":["Unknown", "未知"],
- "1":["true", "维护期内"],
- "2":["false", "维护期外"]} "级别",
- manager varchar "manager",
- market varchar "market",
- netype varchar "netype",
- nmoscausetype int "nmoscausetype",
- nmosdomainname varchar "nmosdomainname",
- nmosentityid int "nmosentityid",
- nmoseventmap varchar "nmoseventmap",
- nmosmanagedstatus int "nmosmanagedstatus",
- nmosobjinst int "nmosobjinst",
- nmosserial varchar "nmosserial",
- node varchar "node",
- nodealias varchar "nodealias",
- nodename varchar "nodename",
- objectfullname varchar "objectfullname",
- oldrow int "oldrow",
- omni_class varchar "class",
- omni_serial int "serial",
- originalseverity int "originalseverity",
- ownergid int "ownergid",
- owneruid int "owneruid",
- physicalcard varchar "physicalcard",
- physicalport int "physicalport",
- physicalslot int "physicalslot",
- platform varchar "platform",
- poll int "poll",
- probesubsecondid int "probesubsecondid",
- processreq int "processreq",
- region varchar "region",
- remotenodealias varchar "remotenodealias",
- remoteobjrelate int "remoteobjrelate",
- remotepriobj varchar "remotepriobj",
- remoterootobj varchar "remoterootobj",
- remotesecobj varchar "remotesecobj",
- remotetertobj varchar "remotetertobj",
- servername varchar "servername",
- serverserial int "serverserial",
- service varchar "service",
- servicenowerrorcode int "servicenowerrorcode",
- servicenowstate int "servicenowstate",
- servicenowsysid varchar "servicenowsysid",
- severity enum {
- "0":["Unknown", "未知"],
- "1":["Trace", "追踪"],
- "2":["Debug", "调试"],
- "3":["Info", "消息"],
- "4":["Warn", "警告"],
- "5":["Error", "错误"],
- "6":["Fatal", "致命错误"]} "级别",
- siteid varchar "siteid",
- statechange timestamp "statechange",
- summary varchar "summary",
- suppressescl int "suppressescl",
- tally int "tally",
- tasklist int "tasklist",
- ticketstatus varchar "ticketstatus",
- ttnumber varchar "ttnumber",
- ttstate int "ttstate",
- ttuser varchar "ttuser",
- type enum {
- "0":["Type not set"],
- "1":["problem", "问题"],
- "2":["resolution", "恢复"],
- "7":["ISM new alarm", "问题"],
- "8":["ISM old alarm", "恢复"]} "类型",
- url varchar "url",
- x733corrnotif varchar "x733corrnotif",
- x733eventtype int "x733eventtype",
- x733probablecause int "x733probablecause",
- x733specificprob varchar "x733specificprob",
- prom bucket {
- "cache": true,
- "ttl": 365,
- "type": "promdb"
- } "prom",
-
- keys( identifier ) ,
- index( acknowledged,alertgroup,alertkey,bsm_classname,bsm_identity,bsm_subidentity,businessimpact,causetype,ciid,cmdbenrichstatus,corrscore,customer,domaingroup,domainsubgroup,emailstatus,eventid,eventtype,expiretime,extendedattr,firstoccurrence,flash,grade,identifier,internallast,lastoccurrence,localnodealias,localobjrelate,localpriobj,localrootobj,localsecobj,localtertobj,location,logticket,manager,market,netype,nmoscausetype,nmosdomainname,nmosentityid,nmoseventmap,nmosmanagedstatus,nmosobjinst,nmosserial,node,nodealias,nodename,objectfullname,oldrow,omni_serial,originalseverity,ownergid,owneruid,physicalcard,physicalport,physicalslot,platform,poll,probesubsecondid,processreq,region,remotenodealias,remoteobjrelate,remotepriobj,remoterootobj,remotesecobj,remotetertobj,servername,serverserial,service,servicenowerrorcode,servicenowstate,servicenowsysid,severity,siteid,statechange,summary,suppressescl,tally,tasklist,ticketstatus,ttnumber,ttstate,ttuser,type,url,x733corrnotif,x733eventtype,x733probablecause,x733specificprob)
- )with ttl=366 day , core=memory, autosearch=true , history=true , version=true , key=manu, alias='alert_status_test' , nickname='malert_status_test', partition=(agent, node), onconflict=(maintenance keep, tally incr, firstoccurrence keep) ;
-
- create class if not exists /test/malert_status_memdb (
- acknowledged int "acknowledged",
- msg varchar "msg",
- agent varchar "AAgent",
- alertgroup varchar "alertgroup",
- alertkey varchar "alertkey",
- bsm_classname varchar "bsm_classname",
- bsm_identity varchar "bsm_identity",
- bsm_subidentity varchar "bsm_subidentity",
- businessimpact int "businessimpact",
- causetype int "causetype",
- ciid varchar "ciid",
- cmdbenrichstatus int "cmdbenrichstatus",
- corrscore int "corrscore",
- customer varchar "customer",
- domaingroup varchar "domaingroup",
- domainsubgroup varchar "domainsubgroup",
- duration int "duration",
- emailstatus int "emailstatus",
- eventid varchar "eventid",
- eventtype enum {
- "10":["主机告警"],
- "11":["数据库告警"],
- "12":["中间件类告警"],
- "13":["应用类告警"],
- "14":["硬件类告警"],
- "99":["其他类告警"]} "事件类型",
- expiretime int "expiretime",
- extendedattr varchar "extendedattr",
- firstoccurrence timestamp "firstoccurrence",
- flash int "flash",
- grade int "grade",
- identifier varchar "identifier",
- internallast timestamp "internallast",
- lastoccurrence timestamp "lastoccurrence",
- localnodealias varchar "localnodealias",
- localobjrelate int "localobjrelate",
- localpriobj varchar "localpriobj",
- localrootobj varchar "localrootobj",
- localsecobj varchar "localsecobj",
- localtertobj varchar "localtertobj",
- location varchar "location",
- logticket int "logticket",
- maintenance enum {
- "0":["Unknown", "未知"],
- "1":["true", "维护期内"],
- "2":["false", "维护期外"]} "级别",
- manager varchar "manager",
- market varchar "market",
- netype varchar "netype",
- nmoscausetype int "nmoscausetype",
- nmosdomainname varchar "nmosdomainname",
- nmosentityid int "nmosentityid",
- nmoseventmap varchar "nmoseventmap",
- nmosmanagedstatus int "nmosmanagedstatus",
- nmosobjinst int "nmosobjinst",
- nmosserial varchar "nmosserial",
- node varchar "node",
- nodealias varchar "nodealias",
- nodename varchar "nodename",
- objectfullname varchar "objectfullname",
- oldrow int "oldrow",
- omni_class varchar "class",
- omni_serial int "serial",
- originalseverity int "originalseverity",
- ownergid int "ownergid",
- owneruid int "owneruid",
- physicalcard varchar "physicalcard",
- physicalport int "physicalport",
- physicalslot int "physicalslot",
- platform varchar "platform",
- poll int "poll",
- probesubsecondid int "probesubsecondid",
- processreq int "processreq",
- region varchar "region",
- remotenodealias varchar "remotenodealias",
- remoteobjrelate int "remoteobjrelate",
- remotepriobj varchar "remotepriobj",
- remoterootobj varchar "remoterootobj",
- remotesecobj varchar "remotesecobj",
- remotetertobj varchar "remotetertobj",
- servername varchar "servername",
- serverserial int "serverserial",
- service varchar "service",
- servicenowerrorcode int "servicenowerrorcode",
- servicenowstate int "servicenowstate",
- servicenowsysid varchar "servicenowsysid",
- severity enum {
- "0":["Unknown", "未知"],
- "1":["Trace", "追踪"],
- "2":["Debug", "调试"],
- "3":["Info", "消息"],
- "4":["Warn", "警告"],
- "5":["Error", "错误"],
- "6":["Fatal", "致命错误"]} "级别",
- siteid varchar "siteid",
- statechange timestamp "statechange",
- summary varchar "summary",
- suppressescl int "suppressescl",
- tally int "tally",
- tasklist int "tasklist",
- ticketstatus varchar "ticketstatus",
- ttnumber varchar "ttnumber",
- ttstate int "ttstate",
- ttuser varchar "ttuser",
- type enum {
- "0":["Type not set"],
- "1":["problem", "问题"],
- "2":["resolution", "恢复"],
- "7":["ISM new alarm", "问题"],
- "8":["ISM old alarm", "恢复"]} "类型",
- url varchar "url",
- x733corrnotif varchar "x733corrnotif",
- x733eventtype int "x733eventtype",
- x733probablecause int "x733probablecause",
- x733specificprob varchar "x733specificprob",
- prom bucket {
- "cache": true,
- "ttl": 365,
- "type": "promdb"
- } "prom",
-
- keys( identifier ) ,
- index( acknowledged,alertgroup,alertkey,bsm_classname,bsm_identity,bsm_subidentity,businessimpact,causetype,ciid,cmdbenrichstatus,corrscore,customer,domaingroup,domainsubgroup,emailstatus,eventid,eventtype,expiretime,extendedattr,firstoccurrence,flash,grade,identifier,internallast,lastoccurrence,localnodealias,localobjrelate,localpriobj,localrootobj,localsecobj,localtertobj,location,logticket,manager,market,netype,nmoscausetype,nmosdomainname,nmosentityid,nmoseventmap,nmosmanagedstatus,nmosobjinst,nmosserial,node,nodealias,nodename,objectfullname,oldrow,omni_serial,originalseverity,ownergid,owneruid,physicalcard,physicalport,physicalslot,platform,poll,probesubsecondid,processreq,region,remotenodealias,remoteobjrelate,remotepriobj,remoterootobj,remotesecobj,remotetertobj,servername,serverserial,service,servicenowerrorcode,servicenowstate,servicenowsysid,severity,siteid,statechange,summary,suppressescl,tally,tasklist,ticketstatus,ttnumber,ttstate,ttuser,type,url,x733corrnotif,x733eventtype,x733probablecause,x733specificprob)
- )with ttl=366 day , core=memoryonly, autosearch=true , history=true , version=true , key=manu, alias='malert_status_memdb' , nickname='malert_status_memdb', partition=(agent, node), onconflict=(maintenance keep, tally incr, firstoccurrence keep) ;
-
- create class if not exists /test/malert_status_cache (
- acknowledged int "acknowledged",
- msg varchar "msg",
- agent varchar "AAgent",
- alertgroup varchar "alertgroup",
- alertkey varchar "alertkey",
- bsm_classname varchar "bsm_classname",
- bsm_identity varchar "bsm_identity",
- bsm_subidentity varchar "bsm_subidentity",
- businessimpact int "businessimpact",
- causetype int "causetype",
- ciid varchar "ciid",
- cmdbenrichstatus int "cmdbenrichstatus",
- corrscore int "corrscore",
- customer varchar "customer",
- domaingroup varchar "domaingroup",
- domainsubgroup varchar "domainsubgroup",
- duration int "duration",
- emailstatus int "emailstatus",
- eventid varchar "eventid",
- eventtype enum {
- "10":["主机告警"],
- "11":["数据库告警"],
- "12":["中间件类告警"],
- "13":["应用类告警"],
- "14":["硬件类告警"],
- "99":["其他类告警"]} "事件类型",
- expiretime int "expiretime",
- extendedattr varchar "extendedattr",
- firstoccurrence timestamp "firstoccurrence",
- flash int "flash",
- grade int "grade",
- identifier varchar "identifier",
- internallast timestamp "internallast",
- lastoccurrence timestamp "lastoccurrence",
- localnodealias varchar "localnodealias",
- localobjrelate int "localobjrelate",
- localpriobj varchar "localpriobj",
- localrootobj varchar "localrootobj",
- localsecobj varchar "localsecobj",
- localtertobj varchar "localtertobj",
- location varchar "location",
- logticket int "logticket",
- maintenance enum {
- "0":["Unknown", "未知"],
- "1":["true", "维护期内"],
- "2":["false", "维护期外"]} "级别",
- manager varchar "manager",
- market varchar "market",
- netype varchar "netype",
- nmoscausetype int "nmoscausetype",
- nmosdomainname varchar "nmosdomainname",
- nmosentityid int "nmosentityid",
- nmoseventmap varchar "nmoseventmap",
- nmosmanagedstatus int "nmosmanagedstatus",
- nmosobjinst int "nmosobjinst",
- nmosserial varchar "nmosserial",
- node varchar "node",
- nodealias varchar "nodealias",
- nodename varchar "nodename",
- objectfullname varchar "objectfullname",
- oldrow int "oldrow",
- omni_class varchar "class",
- omni_serial int "serial",
- originalseverity int "originalseverity",
- ownergid int "ownergid",
- owneruid int "owneruid",
- physicalcard varchar "physicalcard",
- physicalport int "physicalport",
- physicalslot int "physicalslot",
- platform varchar "platform",
- poll int "poll",
- probesubsecondid int "probesubsecondid",
- processreq int "processreq",
- region varchar "region",
- remotenodealias varchar "remotenodealias",
- remoteobjrelate int "remoteobjrelate",
- remotepriobj varchar "remotepriobj",
- remoterootobj varchar "remoterootobj",
- remotesecobj varchar "remotesecobj",
- remotetertobj varchar "remotetertobj",
- servername varchar "servername",
- serverserial int "serverserial",
- service varchar "service",
- servicenowerrorcode int "servicenowerrorcode",
- servicenowstate int "servicenowstate",
- servicenowsysid varchar "servicenowsysid",
- severity enum {
- "0":["Unknown", "未知"],
- "1":["Trace", "追踪"],
- "2":["Debug", "调试"],
- "3":["Info", "消息"],
- "4":["Warn", "警告"],
- "5":["Error", "错误"],
- "6":["Fatal", "致命错误"]} "级别",
- siteid varchar "siteid",
- statechange timestamp "statechange",
- summary varchar "summary",
- suppressescl int "suppressescl",
- tally int "tally",
- tasklist int "tasklist",
- ticketstatus varchar "ticketstatus",
- ttnumber varchar "ttnumber",
- ttstate int "ttstate",
- ttuser varchar "ttuser",
- type enum {
- "0":["Type not set"],
- "1":["problem", "问题"],
- "2":["resolution", "恢复"],
- "7":["ISM new alarm", "问题"],
- "8":["ISM old alarm", "恢复"]} "类型",
- url varchar "url",
- x733corrnotif varchar "x733corrnotif",
- x733eventtype int "x733eventtype",
- x733probablecause int "x733probablecause",
- x733specificprob varchar "x733specificprob",
- prom bucket {
- "cache": true,
- "ttl": 365,
- "type": "promdb"
- } "prom",
-
- keys( identifier ) ,
- index( alertgroup, alertkey, agent, node, type, maintenance)
- )with ttl=366 day , core=cacheonly, autosearch=true , history=true , version=true , key=manu, alias='malert_status_cache' , nickname='malert_status_cache', partition=(agent, node), ckeys=(type desc), onconflict=(maintenance keep, tally incr, firstoccurrence keep) ;
-
- create class if not exists /test/malert_status_seq (
- acknowledged int "acknowledged",
- msg varchar "msg",
- agent varchar "AAgent",
- alertgroup varchar "alertgroup",
- alertkey varchar "alertkey",
- bsm_classname varchar "bsm_classname",
- bsm_identity varchar "bsm_identity",
- bsm_subidentity varchar "bsm_subidentity",
- businessimpact int "businessimpact",
- causetype int "causetype",
- ciid varchar "ciid",
- cmdbenrichstatus int "cmdbenrichstatus",
- corrscore int "corrscore",
- customer varchar "customer",
- domaingroup varchar "domaingroup",
- domainsubgroup varchar "domainsubgroup",
- duration int "duration",
- emailstatus int "emailstatus",
- eventid varchar "eventid",
- eventtype enum {
- "10":["主机告警"],
- "11":["数据库告警"],
- "12":["中间件类告警"],
- "13":["应用类告警"],
- "14":["硬件类告警"],
- "99":["其他类告警"]} "事件类型",
- expiretime int "expiretime",
- extendedattr varchar "extendedattr",
- firstoccurrence timestamp "firstoccurrence",
- flash int "flash",
- grade int "grade",
- identifier varchar "identifier",
- internallast timestamp "internallast",
- lastoccurrence timestamp "lastoccurrence",
- localnodealias varchar "localnodealias",
- localobjrelate int "localobjrelate",
- localpriobj varchar "localpriobj",
- localrootobj varchar "localrootobj",
- localsecobj varchar "localsecobj",
- localtertobj varchar "localtertobj",
- location varchar "location",
- logticket int "logticket",
- maintenance enum {
- "0":["Unknown", "未知"],
- "1":["true", "维护期内"],
- "2":["false", "维护期外"]} "级别",
- manager varchar "manager",
- market varchar "market",
- netype varchar "netype",
- nmoscausetype int "nmoscausetype",
- nmosdomainname varchar "nmosdomainname",
- nmosentityid int "nmosentityid",
- nmoseventmap varchar "nmoseventmap",
- nmosmanagedstatus int "nmosmanagedstatus",
- nmosobjinst int "nmosobjinst",
- nmosserial varchar "nmosserial",
- node varchar "node",
- nodealias varchar "nodealias",
- nodename varchar "nodename",
- objectfullname varchar "objectfullname",
- oldrow int "oldrow",
- omni_class varchar "class",
- omni_serial int "serial",
- originalseverity int "originalseverity",
- ownergid int "ownergid",
- owneruid int "owneruid",
- physicalcard varchar "physicalcard",
- physicalport int "physicalport",
- physicalslot int "physicalslot",
- platform varchar "platform",
- poll int "poll",
- probesubsecondid int "probesubsecondid",
- processreq int "processreq",
- region varchar "region",
- remotenodealias varchar "remotenodealias",
- remoteobjrelate int "remoteobjrelate",
- remotepriobj varchar "remotepriobj",
- remoterootobj varchar "remoterootobj",
- remotesecobj varchar "remotesecobj",
- remotetertobj varchar "remotetertobj",
- servername varchar "servername",
- serverserial int "serverserial",
- service varchar "service",
- servicenowerrorcode int "servicenowerrorcode",
- servicenowstate int "servicenowstate",
- servicenowsysid varchar "servicenowsysid",
- severity enum {
- "0":["Unknown", "未知"],
- "1":["Trace", "追踪"],
- "2":["Debug", "调试"],
- "3":["Info", "消息"],
- "4":["Warn", "警告"],
- "5":["Error", "错误"],
- "6":["Fatal", "致命错误"]} "级别",
- siteid varchar "siteid",
- statechange timestamp "statechange",
- summary varchar "summary",
- suppressescl int "suppressescl",
- tally int "tally",
- tasklist int "tasklist",
- ticketstatus varchar "ticketstatus",
- ttnumber varchar "ttnumber",
- ttstate int "ttstate",
- ttuser varchar "ttuser",
- type enum {
- "0":["Type not set"],
- "1":["problem", "问题"],
- "2":["resolution", "恢复"],
- "7":["ISM new alarm", "问题"],
- "8":["ISM old alarm", "恢复"]} "类型",
- url varchar "url",
- x733corrnotif varchar "x733corrnotif",
- x733eventtype int "x733eventtype",
- x733probablecause int "x733probablecause",
- x733specificprob varchar "x733specificprob",
-
- keys( identifier ) ,
- index( acknowledged,alertgroup,alertkey,bsm_classname,bsm_identity,bsm_subidentity,businessimpact,causetype,ciid,cmdbenrichstatus,corrscore,customer,domaingroup,domainsubgroup,emailstatus,eventid,eventtype,expiretime,extendedattr,firstoccurrence,flash,grade,identifier,internallast,lastoccurrence,localnodealias,localobjrelate,localpriobj,localrootobj,localsecobj,localtertobj,location,logticket,manager,market,netype,nmoscausetype,nmosdomainname,nmosentityid,nmoseventmap,nmosmanagedstatus,nmosobjinst,nmosserial,node,nodealias,nodename,objectfullname,oldrow,omni_serial,originalseverity,ownergid,owneruid,physicalcard,physicalport,physicalslot,platform,poll,probesubsecondid,processreq,region,remotenodealias,remoteobjrelate,remotepriobj,remoterootobj,remotesecobj,remotetertobj,servername,serverserial,service,servicenowerrorcode,servicenowstate,servicenowsysid,severity,siteid,statechange,summary,suppressescl,tally,tasklist,ticketstatus,ttnumber,ttstate,ttuser,type,url,x733corrnotif,x733eventtype,x733probablecause,x733specificprob)
- )with ttl=366 day , autosearch=true , history=true , version=true , key=manu, alias='malert_status_seq' , nickname='malert_status_seq', partition=(agent, node) ;
- CREATE OR REPLACE TRIGGER testupdate2 ON /test/alert_status
- COMMENT "这是注释"
- GROUP 运维组
- SCHEDULE before MODIFY
- PRIORITY 20
- STATUS enable
- BEGIN
- log.trace("trigger test")
- ` + strings.Join(trigger, "\n") + `
- END;
-
- delete from /test/alert_status
- ;
- ;// commnet
- ;-- 注释
- ;
- `)
- if err != nil {
- logger.Errorf("===>%v", err.Error())
- }
- require.Nil(t.Test, err, fmt.Sprint(err))
- }
- func (t *ConflictTests) DataConcurrent(count int) {
- var wg sync.WaitGroup
- for i := 0; i < count; i++ {
- wg.Add(1)
- go func(n int) {
- defer wg.Done()
- stat, err := t.g.Prepare(`insert into /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`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- require.Nil(t.Test, err, fmt.Sprint(err))
- _, _, err = stat.Exec(fmt.Sprint("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6.", n), 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "MTTrapd Probe", nil, 5, "设备:222.129.134.178电源整体功能恢复!")
- if err != nil {
- logger.Errorf("%v", err)
- }
- require.Nil(t.Test, err, fmt.Sprint(err))
- }(i)
- }
- wg.Wait()
- // 等待后台压缩延迟保存结束
- time.Sleep(1 * time.Second)
- }
- /*
- insert into /test/alert_status (identifier, severity, lastoccurrence, maintenance, msg, type, agent, firstoccurrence, omni_class, nodealias, alertgroup, node, manager, originalseverity, summary) values ("2222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.7", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "MTTrapd Probe", 5, "设备:222.129.134.178电源整体功能恢复!") on conflict update firstoccurrence=firstoccurrence, servicenowstate=servicenowstate, emailstatus=emailstatus, tally=tally+1
- delete from /test/alert_status where identifier = '2222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.7'
- */
- func (t *ConflictTests) DataFromClient() {
- time.Sleep(2 * time.Second)
- client, err := getClient()
- if err != nil {
- logger.Error(err)
- }
- defer func() {
- if err := client.Close(); err != nil {
- logger.Error(err)
- }
- }()
- 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 := client.Query(`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`, "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).Do()
- if err != nil {
- wgg.Fail(err)
- } else {
- wgg.Done()
- }
- }(i)
- }
- if err := wgg.Wait(120 * time.Second); err != nil {
- logger.Error(err)
- }
- logger.Debug("concurrent insert malert_status_memdb test, loop ", kk)
- }
- 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 := client.Query(`insert into /test/malert_status_cache (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`, "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).Do()
- if err != nil {
- wgg.Fail(err)
- } else {
- wgg.Done()
- }
- }(i)
- }
- if err := wgg.Wait(120 * time.Second); err != nil {
- logger.Error(err)
- }
- logger.Debug("concurrent insert malert_status_cache test, loop ", kk)
- }
- }
- func (t *ConflictTests) Data() {
- var err error
- //print("base insert test")
- stat, err := t.g.Prepare(`insert into /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`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- require.Nil(t.Test, err, fmt.Sprint(err))
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.7", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.8", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.9", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- //print("concurrent insert test")
- var wg sync.WaitGroup
- for i := 0; i < 10; i++ {
- //time.Sleep(time.Duration(800) * time.Millisecond)
- wg.Add(1)
- go func() {
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- //time.Sleep(time.Duration(80) * time.Millisecond)
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- //time.Sleep(time.Duration(80) * time.Millisecond)
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.7", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- //time.Sleep(time.Duration(80) * time.Millisecond)
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.7", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- //time.Sleep(time.Duration(80) * time.Millisecond)
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.8", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- //time.Sleep(time.Duration(80) * time.Millisecond)
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.8", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- //time.Sleep(time.Duration(80) * time.Millisecond)
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.9", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- require.Nil(t.Test, err, fmt.Sprint(err))
- //time.Sleep(time.Duration(80) * time.Millisecond)
- _, _, err = stat.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.9", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- require.Nil(t.Test, err, fmt.Sprint(err))
- wg.Done()
- }()
- }
- wg.Wait()
- time.Sleep(time.Duration(5000) * time.Millisecond)
- //print("concurrent update connect test")
- for i := 0; i < 10; i++ {
- //time.Sleep(time.Duration(800) * time.Millisecond)
- wg.Add(1)
- go func(aa int) {
- _, _, err = t.g.Query(fmt.Sprintf(`update /test/alert_status set connect = connect + "Project:prj%d" `, aa))
- if err != nil {
- logger.Errorf("%v", err)
- }
- wg.Done()
- }(i)
- }
- wg.Wait()
- time.Sleep(time.Duration(5000) * time.Millisecond)
- //print("concurrent update tags test")
- wg.Add(1)
- go func() {
- _, _, err = t.g.Query(fmt.Sprintf(`update /test/alert_status set tags = "mytag6" where identifier = '%s'`, "222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6"))
- if err != nil {
- logger.Errorf("%v", err)
- }
- wg.Done()
- }()
- wg.Add(1)
- go func() {
- _, _, err = t.g.Query(fmt.Sprintf(`update /test/alert_status set tags = "mytag7" where identifier = '%s'`, "222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.7"))
- if err != nil {
- logger.Errorf("%v", err)
- }
- wg.Done()
- }()
- wg.Add(1)
- go func() {
- _, _, err = t.g.Query(fmt.Sprintf(`update /test/alert_status set tags = "mytag8" where identifier = '%s'`, "222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.8"))
- if err != nil {
- logger.Errorf("%v", err)
- }
- wg.Done()
- }()
- //time.Sleep(time.Duration(1) * time.Second)
- wg.Add(1)
- go func() {
- _, _, err = t.g.Query(fmt.Sprintf(`update /test/alert_status set tags = "mytag9" where identifier = '%s'`, "222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.9"))
- if err != nil {
- logger.Errorf("%v", err)
- }
- wg.Done()
- }()
- wg.Wait()
- //print("concurrent insert malert_status test")
- stat2, err := t.g.Prepare(`insert into /test/malert_status (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 err != nil {
- logger.Errorf("%v", err)
- }
- require.Nil(t.Test, err, fmt.Sprint(err))
- 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 := stat2.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(120 * time.Second); err != nil {
- logger.Error(err)
- }
- logger.Debug("concurrent insert malert_status test, loop ", kk)
- }
- //print("insert malert_status_seq test")
- stat3, err := t.g.Prepare(`insert into /test/malert_status_seq (identifier, severity, lastoccurrence, maintenance, msg, type, agent, firstoccurrence, omni_class, nodealias, alertgroup, node, manager, _tokens, originalseverity, summary) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict sequence`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- require.Nil(t.Test, err, fmt.Sprint(err))
- _, _, err = stat3.Exec("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6", 5, 1622249715000, 1, "设备:222.129.134.178电源整体功能恢复!", 2, "huawei mttrapd", 1622211715023, "300", "222.129.134.178", "huawei_power_func", "222.129.134.178", "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电源整体功能恢复!")
- require.Nil(t.Test, err, fmt.Sprint(err))
- }
- func (t *ConflictTests) Valid() {
- rtn, _, err := t.g.Query(`select tally FROM /test/alert_status refresh`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 4, len(rtn), fmt.Sprintf("not find total = %v", "4"))
- assert.Equal(t.Test, 20, rtn[0]["tally"].(int), fmt.Sprintf("not find tally = %v", "20"))
- assert.Equal(t.Test, 20, rtn[1]["tally"].(int), fmt.Sprintf("not find tally = %v", "20"))
- assert.Equal(t.Test, 20, rtn[2]["tally"].(int), fmt.Sprintf("not find tally = %v", "20"))
- assert.Equal(t.Test, 20, rtn[3]["tally"].(int), fmt.Sprintf("not find tally = %v", "20"))
- }
- rtn, _, err = t.g.Query(`select connect FROM /test/alert_status refresh`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 4, len(rtn), fmt.Sprintf("not find total = %v", "4"))
- mm1 := rtn[0]["connect"].(map[string][]string)
- mm2 := rtn[1]["connect"].(map[string][]string)
- mm3 := rtn[2]["connect"].(map[string][]string)
- mm4 := rtn[3]["connect"].(map[string][]string)
- assert.Equal(t.Test, 10, len(mm1["_all"]), fmt.Sprintf("not find tally = %v", "10"))
- assert.Equal(t.Test, 10, len(mm2["_all"]), fmt.Sprintf("not find tally = %v", "10"))
- assert.Equal(t.Test, 10, len(mm3["_all"]), fmt.Sprintf("not find tally = %v", "10"))
- assert.Equal(t.Test, 10, len(mm4["_all"]), fmt.Sprintf("not find tally = %v", "10"))
- }
- rtn, _, err = t.g.Query(`select tags FROM /test/alert_status refresh`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn[0]["tags"].([]string)), fmt.Sprintf("not find tags = %v", "1"))
- assert.Equal(t.Test, 1, len(rtn[1]["tags"].([]string)), fmt.Sprintf("not find tags = %v", "1"))
- assert.Equal(t.Test, 1, len(rtn[2]["tags"].([]string)), fmt.Sprintf("not find tags = %v", "1"))
- assert.Equal(t.Test, 1, len(rtn[3]["tags"].([]string)), fmt.Sprintf("not find tags = %v", "1"))
- }
- }
|