⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 很不错的东东
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  SNmPsend, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Button1: TButton;
    Label2: TLabel;
    Label4: TLabel;
    Edit3: TEdit;
    Memo1: TMemo;
    Label5: TLabel;
    Timer1: TTimer;
    Image1: TImage;
    Label3: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Button2: TButton;
    Label10: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ipIn:array[1..21] of integer;
  ipOut:array[1..21] of integer;
  ipInInc:array[1..20] of integer;
  ipOutInc:array[1..20] of integer;
  ipHost:string;
  implementation

{$R *.DFM}
 procedure drawPic();
 var
 yh1,yh2,yh3,x,y,i:integer;
 begin
 x:=5;
 y:=295;
 with Form1.Image1.Canvas do
 begin
 Brush.Color:=clblack;
 FillRect(form1.Image1.ClientRect);
 pen.Color:=clRed;
 pen.Width:=5;
 for i:=1 to 20  do
 begin
 yh1:=round(ln(ipInInc[21-i]+1)*30);
 if yh1>290 then yh1:=290;
 if yh1<0   then yh1:=0;
 moveto(x,y-yh1);
 yh2:=yh1;
 yh3:=round(ln(ipInInc[21-i-1]+1)*30);
 lineto(x+20,y-yh3);
 x:=x+20;
 y:=295;
 end;
 x:=15;
 pen.color:=clyellow;
 for i:=1 to 20  do
 begin
 yh1:=round(ln(ipOutInc[21-i]+1)*30);
 if yh1>290 then yh1:=290;
 if yh1<0   then yh1:=0;
 moveto(x,y-yh1);
 yh2:=yh1;
 yh3:=round(ln(ipOutInc[21-i-1]+1)*30);
 lineto(x+20,y-yh3);
 x:=x+20;
 y:=295;
 end;
 end;
 end;
procedure TForm1.Button1Click(Sender: TObject);
var
  response,s:string;
  n:integer;
begin
  if SNMPget(Edit3.Text,'public',ipHost,response)
    then
      begin
       // label2.Caption:='成功!';
	memo1.Lines.Clear;

	memo1.Lines.Text:=response;
	s:='';
	for n:=1 to Length(response) do
	  begin
	    s:=s+'$'+IntToHex(Ord(response[n]),2)+' ';
	  end;

      end
    else
      begin
        //label2.Caption:='不成功!请检查OID的输入';
	memo1.Lines.Clear;

      end;
end;



procedure TForm1.Timer1Timer(Sender: TObject);
var
x,y,value, i:integer;
 response:string;

begin      //ip input
 if SNMPget('1.3.6.1.2.1.4.3.0','public',ipHost,response)
    then
      begin
       //label10.Caption:='成功...';
       for i:=1 to 20 do
        begin
        ipIn[22-i]:=ipIn[21-i];
        end;

      try
        ipIn[1]:=strtoint(response);
        except
        on EConvertError do ;
        end;
      end
    else
      begin
	//label10.Caption:='不成功!请检查主机地址的输入!)';

      end;
      //ipoutput
   if SNMPget('1.3.6.1.2.1.4.10.0','public',ipHost,response)
    then
      begin
       //label10.Caption:='成功...';
       for i:=1 to 20 do
        begin
        ipOut[22-i]:=ipOut[21-i];
        end;

      try
        ipOut[1]:=strtoint(response);
        except
        on EConvertError do ;
        end;
      end
    else
      begin
	label10.Caption:='不成功!请检查主机地址的输入!';

      end;
   for i:=1 to 20 do
    if  ipIn[22-i] <>0 then
       ipInInc[21-i]:=ipIn[21-i]-ipIn[22-i];

      for i:=1 to 20 do
    if  ipOut[22-i] <>0 then
       ipOutInc[21-i]:=ipOut[21-i]-ipOut[22-i];
    drawPic();
    label7.Caption:=inttostr(ipInInc[1]);
     label9.Caption:=inttostr(ipOutInc[1]);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 ipHost:=Edit1.Text;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 i:integer;
begin

for i:=1 to 21 do
 begin
 ipOut[i]:=0;
 ipIn[i]:=0;
 end;
 for i:=1 to 20 do
 begin
  ipOutInc[i]:=0;
  ipInInc[i]:=0;
  end;
iphost:=edit1.Text;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -