"use strict";(function(){var e=0;"use strict";var t=require("util");var i=require("events");var r=require("./devicePerfDb");function n(e,t){i.EventEmitter.call(this);if(false===this instanceof n){return new n}this.perfDbInstance=new r(e,t)}t.inherits(n,i.EventEmitter);n.prototype.getCpuInfo=function(t,i,r){var n=this;var s="show cpu";var a="in five minutes";var o=function c(t){var s=0;if(e==1){}var o=t.split(/\r?\n/gi);for(var c=0;c<o.length;c++){if(o[c].search(a)!==-1){s=o[c].split(":")[1].trim().split("%")[0];s=Math.ceil(s);if(c+1<o[c].length&&o[c+1].search("5Min")!=-1||c+2<o[c].length&&o[c+2].search("5Min")!=-1){break}}}var l={deviceName:i,seriaNo:r,type:"cpu",used:s};if(e==1){console.log("cpu item = "+l.used)}n.perfDbInstance.insertAndUpdatePerfTable(l,function(e){if(e==null){console.log("cpu info update success")}else{console.log(e)}})};t.exec(s,o)};n.prototype.getStaNum=function(t,i,r,n){var s=this;var a="show mac-address-table count";var o="Total Mac Addresses";var c=0;var l=function u(t){if(e==1){}var a=t.split(/\r?\n/gi);for(var l=0;l<a.length;l++){if(a[l].search(o)!==-1){c=a[l].split(":")[1].trim();c=Math.ceil(c)}}var u={deviceName:i,seriaNo:r,type:"staNum",used:c,daystr:n};if(e==1){console.log("staNumItem item = "+u.used)}s.perfDbInstance.insertAndUpdateStaTable(u,function(e){if(e==null){}else{console.log(e)}})};t.exec(a,l)};n.prototype.getUptime=function(e,t,i){var r=this;var n="show ver";var s=function a(e){var n=e.split(/\r?\n/gi);var s="";for(var a=0;a<n.length;a++){if(n[a].search("System uptime")!==-1){var o=n[a].split(": ")[1];s={deviceName:t,seriaNo:i,uptime:o};break}}console.log("upItem is "+s);r.perfDbInstance.getUptimeFromTable(t,function(e){if(e=="0:0:0:0"){c()}});var c=function l(){r.perfDbInstance.insertUptimeIntoTable(s,function(e){if(e!=null){console.log("insert uptime failed! reason: "+e)}else{console.log("insert uptime failed! success")}})}};e.exec(n,s)};module.exports=n})();