Follow us on...
Follow us on G+ Follow us on Twitter Follow us on Facebook Watch us on YouTube
Register
Results 1 to 2 of 2
  1. #1
    Status
    Offline
    awarmanf's Avatar
    Member
    Join Date
    Apr 2008
    Posts
    222
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0

    Script u/ ambil get value dari mt dan diolah di mesin lain (linux)

    Lagi mikir gimana caranya agar di mesin linux kita bisa ambil data tertentu dari mikrotik dan data ini bisa diolah sesuai kebutuhan:

    Langkah pertama, buat koneksi ssh tanpa password ke mikrotik. Caranya baca di
    Sampai di sini data yang diperoleh dari mikrotik dari manual di atas hanya ditampilkan di layar console. Sekarang katakan saya mau ambil data atau get value dari ip firewall mangle packet mark client-anu-down dan client-anu-up. Data ini nanti akan dimanipulasi di linux.

    Script lengkapnya seperti di bawah ini:
    Code:
    #!/bin/sh
    
    # PARAM
    SSHKEY="ssh -i /home/yudi/.ssh/id_dsa yudi@1.2.3.4"
    
    $SSHKEY ":global A [/ip firewall mangle get [find comment=\"MARK PACKET client-anu-up rule 1\" 
    ] bytes ]; :put \$A" | sed -e 's/\r//' > /tmp/MYVAR
    read UP1 < /tmp/MYVAR
    sleep 1
    $SSHKEY ":global B [/ip firewall mangle get [find comment=\"MARK PACKET client-anu-up rule 2\" 
    ] bytes ]; :put \$B" | sed -e 's/\r//' > /tmp/MYVAR
    read UP2 < /tmp/MYVAR
    sleep 1
    $SSHKEY ":global C [/ip firewall mangle get [find comment=\"MARK PACKET client-anu-down rule 1\
    " ] bytes ]; :put \$C" | sed -e 's/\r//' > /tmp/MYVAR
    read DW1 < /tmp/MYVAR
    sleep 1
    $SSHKEY ":global D [/ip firewall mangle get [find comment=\"MARK PACKET client-anu-down rule 2\
    " ] bytes ]; :put \$D" | sed -e 's/\r//' > /tmp/MYVAR
    read DW2 < /tmp/MYVAR
    
    UP=$(($UP1+$UP2))
    DW=$(($DW1+$DW2))
    
    echo Bytes up client anu: $UP
    echo Bytes down client anu: $DW
    Hasil keluaran dari mikrotik itu berupa karakter ASCII dengan CRLF jadi agar bisa dimanipulasi atau dipakai hitung2an karakter \r harus dibuang dulu. BTW, ini khusus mikrotik versi 3.x Click here to enlarge

  2. The Following 3 Users Say Thank You to awarmanf For This Useful Post:


  3. #2
    Status
    Offline
    dencow's Avatar
    Forum Guru
    Join Date
    Jan 2008
    Posts
    1,728
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    1 (100%)
    keren ingponya
    thanks

 

 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. cara remote BTS via winbox dari kota lain?
    By Mr. Bus in forum Wireless Networking
    Replies: 15
    Last Post: 08-03-2013, 13:26
  2. Cara belajar linux dari awal
    By rhon in forum Beginner Basics
    Replies: 18
    Last Post: 22-08-2011, 16:03
  3. cerita dari warnet linux
    By C@RLo$ in forum Chit Chat
    Replies: 66
    Last Post: 12-07-2010, 11:40
  4. Ambil data dari environment
    By awarmanf in forum Scripting @ Mikrotik
    Replies: 3
    Last Post: 29-04-2009, 13:11
  5. download dari mesin mikrotik,client ngambil dari ftp
    By carrud in forum General Networking
    Replies: 7
    Last Post: 11-04-2008, 08:50

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •