نمایش نتایج 1 تا 3 از 3

نام تاپیک: چک کردن آپ تایم روتربورد میکروتیک

  1. #1
    کاربر دائمی آواتار ehsan_faal
    تاریخ عضویت
    خرداد 1392
    محل زندگی
    تهران
    پست
    325

    چک کردن آپ تایم روتربورد میکروتیک

    سلام.
    با استفاده از chilkat یه برنامه نوشتم که با ssh به روتربوردی که تو اتاق سرور هست و فقط برای چک کردن وضعیت برق شهر اونجا گذاشته شده، آپ تایمش رو بخونم.
    با وینباکس هم میشه اینکار رو کرد اما وینباکس در صورت disconnect شدن هیچ alarm صداداری نمیده و فقط میگه که reconnect کن.
    مشکلاتی که دارم اینا هستن:
    ۱- برنامه resource زیادی میکشه. از خود وینباکس با اونهمه امکانات هم بیشتر.
    ۲- توی لاگ روتر با هر بار فراخوانی تابع مربوط به ssh یه خط connect و disconnect‌میاد در صورتی که من یک بار فقط session ‌رو ایجاد و یک بار هم بستمش.
    ۳- dll های این کتابخونه رو نیمشه به خود فایل نهایی attach کرد؟
    اینم کدی که استفاده میکنم در حال حاضر:
    راه بهینه تری پیشنهاد بدید عالی میشه:

    Program Project1;

    {$APPTYPE CONSOLE}

    {$R *.res}

    {$R 'MYDDL.res' 'MYDDL.rc'}

    Uses
    System.SysUtils,
    System.StrUtils,
    Ssh;

    Var
    Ssh: HCkSsh;
    cmdOutput: PWideChar;

    Procedure RunSSH;
    Var
    success: Boolean;
    port: Integer;
    host: PWideChar;
    channelNum: Integer;
    Begin
    Ssh := CkSsh_Create();
    success := CkSsh_UnlockComponent(Ssh, 's2yjlR.CB10750_Ig3zlV2R4C77');
    If (success <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Exit;
    End;
    port := ****;
    host := '192.168.185.254';
    success := CkSsh_Connect(Ssh, host, port);
    If (success <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Exit;
    End;
    CkSsh_putIdleTimeoutMs(Ssh, 5000);
    success := CkSsh_AuthenticatePw(Ssh, '****', '*****');
    If (success <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Exit;
    End;
    channelNum := CkSsh_OpenSessionChannel(Ssh);
    If (channelNum < 0) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Exit;
    End;

    success := CkSsh_SendReqExec(Ssh, channelNum, 'system resource print');
    If (success <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Exit;
    End;
    success := CkSsh_ChannelReceiveToClose(Ssh, channelNum);
    If (success <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Exit;
    End;
    cmdOutput := CkSsh__getReceivedText(Ssh, channelNum, 'ansi');
    If (CkSsh_getLastMethodSuccess(Ssh) <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Exit;
    End;
    End;

    Begin
    Try
    While True Do
    Begin
    RunSSH;
    Writeln(Trim(LeftStr(cmdOutput, Pos(#10, cmdOutput))));
    Sleep(5000);
    End;
    Finally
    CkSsh_Disconnect(Ssh);
    CkSsh_Dispose(Ssh);
    End;
    Readln;
    End.

  2. #2
    کاربر دائمی آواتار ehsan_faal
    تاریخ عضویت
    خرداد 1392
    محل زندگی
    تهران
    پست
    325

    نقل قول: چک کردن آپ تایم روتربورد میکروتیک

    فکر میکردم اینجوری بشه مشکل دوم رو حل کرد اما نمیشه ظاهرا:


    Program Project1;

    {$APPTYPE CONSOLE}
    {$R *.res}

    Uses
    System.SysUtils,
    System.StrUtils,
    Ssh;

    Var
    Ssh: HCkSsh;
    cmdOutput: PWideChar;
    success: Boolean;
    port: Integer;
    host: PWideChar;
    channelNum: Integer;

    Begin
    Ssh := nil;
    Try
    Ssh := CkSsh_Create();
    success := CkSsh_UnlockComponent(Ssh, 's2yjlR.CB10750_Ig3zlV2R4C77');
    If (success <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    port := ****;
    host := '192.168.185.254';
    success := CkSsh_Connect(Ssh, host, port);
    If (success <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));

    End;
    CkSsh_putIdleTimeoutMs(Ssh, 5000);
    success := CkSsh_AuthenticatePw(Ssh, '****', '******');
    If (success <> True) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    channelNum := CkSsh_OpenSessionChannel(Ssh);
    If (channelNum < 0) Then
    Begin
    Writeln(CkSsh__lastErrorText(Ssh));
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;

    While True Do
    Begin
    success := CkSsh_SendReqExec(Ssh, channelNum, 'system resource print');
    If (success <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    success := CkSsh_ChannelReceiveToClose(Ssh, channelNum);
    If (success <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    cmdOutput := CkSsh__getReceivedText(Ssh, channelNum, 'ansi');
    If (CkSsh_getLastMethodSuccess(Ssh) <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    Writeln(Trim(LeftStr(cmdOutput, Pos(#10, cmdOutput))));
    Sleep(3000);
    End;
    Except
    On E: Exception Do
    Begin
    Writeln('Exception class name = ' + E.ClassName);
    Writeln('Exception message = ' + E.Message);
    CkSsh_Disconnect(Ssh);
    CkSsh_Dispose(Ssh);
    Readln;
    End;
    End;
    End.

  3. #3
    کاربر دائمی آواتار ehsan_faal
    تاریخ عضویت
    خرداد 1392
    محل زندگی
    تهران
    پست
    325

    نقل قول: چک کردن آپ تایم روتربورد میکروتیک

    مشکل دوم حل شد، ظاهرا برای کامندی که از طریق ssh میزنم باید یک چنل دیگه درست بشه.

    Program Project1;

    {$APPTYPE CONSOLE}
    {$R *.res}

    Uses
    System.SysUtils,
    System.StrUtils,
    Ssh;

    Var
    Ssh: HCkSsh;
    cmdOutput: PWideChar;
    success: Boolean;
    port: Integer;
    host: PWideChar;
    channelNum: Integer;

    Begin
    Ssh := nil;
    Try
    Ssh := CkSsh_Create();
    success := CkSsh_UnlockComponent(Ssh, 's2yjlR.CB10750_Ig3zlV2R4C77');
    If (success <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    port := ****;
    host := '192.168.185.254';
    success := CkSsh_Connect(Ssh, host, port);
    If (success <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));

    End;
    CkSsh_putIdleTimeoutMs(Ssh, 5000);
    success := CkSsh_AuthenticatePw(Ssh, '*****', '******');
    If (success <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    channelNum := CkSsh_OpenSessionChannel(Ssh);
    If (channelNum < 0) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;

    While True Do
    Begin
    success := CkSsh_SendReqExec(Ssh, channelNum, 'system resource print');
    If (success <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    success := CkSsh_ChannelReceiveToClose(Ssh, channelNum);
    If (success <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    cmdOutput := CkSsh__getReceivedText(Ssh, channelNum, 'ansi');
    If (CkSsh_getLastMethodSuccess(Ssh) <> True) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    Writeln(Trim(LeftStr(cmdOutput, Pos(#10, cmdOutput))));
    Sleep(3000);
    channelNum := CkSsh_OpenSessionChannel(Ssh);
    If (channelNum < 0) Then
    Begin
    Raise Exception.Create(CkSsh__lastErrorText(Ssh));
    End;
    End;
    Except
    On E: Exception Do
    Begin
    CkSsh_Disconnect(Ssh);
    CkSsh_Dispose(Ssh);
    Writeln('Exception class name = ' + E.ClassName);
    Writeln('Exception Message = ' + E.Message);
    Readln;
    End;
    End;
    End.


تاپیک های مشابه

  1. کد چک کردن فول ورژن بودن اپ در آندروید ستودیو
    نوشته شده توسط Aram0630 در بخش Android Studio
    پاسخ: 0
    آخرین پست: چهارشنبه 27 بهمن 1395, 20:15 عصر
  2. چک کردن تموم شدن تایم ثبت نام در php
    نوشته شده توسط png_92 در بخش PHP
    پاسخ: 7
    آخرین پست: جمعه 22 خرداد 1394, 00:02 صبح
  3. چک کردن آپ بودن mysql
    نوشته شده توسط navid3d_69 در بخش PHP
    پاسخ: 8
    آخرین پست: پنج شنبه 19 دی 1392, 11:16 صبح
  4. چک کردن وضعیت چند باتون قبل از خروج
    نوشته شده توسط Gladiator در بخش برنامه نویسی در Delphi
    پاسخ: 4
    آخرین پست: یک شنبه 11 آبان 1382, 22:53 عصر
  5. چک کردن وجود جدول در بانک اطلاعاتی
    نوشته شده توسط v_shalchian در بخش بانک های اطلاعاتی در Delphi
    پاسخ: 2
    آخرین پست: یک شنبه 30 شهریور 1382, 10:01 صبح

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •