protected void Btn_cisco_click (object sender, EventArgs e)
{
Try
{
String ip = txt_ip. Value;
String community = Txt_ttm. Value;
String oid = Txt_oid. Value;
String outoid = Txt_outoid. Value;
String city = txt_city. Value;
DOS command to perform import and export traffic
string cmd = dos + "+ community +" "+ IP +" "+ oid +" && "+ dos +" "+ Community +" "+ IP +" + outoid ;
String executedos = Getexecutedos.executedos (cmd, 180000);
String outvalue = String. Empty;
String invalue = String. Empty;
if (!string. IsNullOrEmpty (Executedos))
{
Executedos = Executedos.replace ("Snmpv2-smi", "$");
string[] STRs = Executedos.split (' $ ');
foreach (var item in STRs)
{
Outvalue = Item. Substring (item. LastIndexOf ("INTEGER:") + 8);
}
foreach (var item in STRs)
{
Invalue = Item. Substring (item. IndexOf ("INTEGER:") + 8);
Invalue = Invalue.replace ("snmpv2-smi::enterprises.9.2.2.1.1.8.10201 = INTEGER:", "");
String arry = Invalue.replace ("\ r \ n", "&");
string[] Value = Arry. Split (' & ');
for (int i = 0; i < value. Length-1; i++)
{
if (i = = 0)
{
Invalue = value[0];
Break
}
}
}
Model.host model = new Host ();
Model.hostname = IP;
Model.oid = oid;
Model. Outoid = outoid;
model.community = community;
model.city = City;
Model.addtime = DateTime.Now.ToString ("Yyyy-mm-dd HH:mm:ss");
Model. Outoctets = (float) math.round (Convert.tosingle (outvalue)/1024/1024, 2);
Model. Inoctets = (float) math.round (Convert.tosingle (invalue)/1024/1024, 2);
int res = BLL.ADDHOSTIP (model);
if (res > 0)
{
Response.Write ("Import Flow:" + Math.Round (Convert.tosingle (invalue)/1024/1024, 2) + "" + "MB" + "egress Flow:" + math.round (convert. ToSingle (outvalue)/1024/1024, 2) + "+" MB ");
}
}
}
catch (Exception ex)
{
Response.Write ("<script type= ' text/javascript ' >alert ('" + Ex.) Message + "') </script>");
}
}
}
Asp. NET call DOS command to get switch traffic