วันพฤหัสบดีที่ 15 ตุลาคม พ.ศ. 2558

Detect someone online bash script (email alert)

#!/bin/bash
SUBJ="!!!Host Online!!!"
EMAIL="xxx@gmail.com"

intertube=0
echo "begin ping"
while [ $intertube -ne 1 ]; do
        ping -c 1 192.168.1.8>/dev/null
        if [ $? -eq  0 ]; then
                echo "$(date) Host Online" | mail -s "SUBJ$ at $(date)" $EMAIL;
                intertube=1;
        else
                echo "still offine"
        fi
done
echo "fin script"

วันพฤหัสบดีที่ 1 ตุลาคม พ.ศ. 2558

วันอังคารที่ 29 กันยายน พ.ศ. 2558

Monitor Wan ip for Rasberry pi


#! /bin/sh

SUBJ="Warning: Raspberry Pi - new IP Address"
SUBJ2="Still same wan IP"
EMAIL=xxx@gmail.com"

ip1=""
ip2=""

read ip1 < ip.txt
ip2=$(wget -qO- ifconfig.me/ip)

if [ "$ip1" = "$ip2" ]
then
  echo "Wan ip same yesterday : $ip1."| mail -s "$SUBJ2" $EMAIL;
else
  echo "$ip2" > ip.txt;
  echo "New ip for rpi69: $ip2" | mail -s "$SUBJ" $EMAIL;
  exit;
fi

===============
ตั้ง cron -e  ทุก 10.10

10 10 * * * /home/chkipwan.sh












วันพฤหัสบดีที่ 3 กันยายน พ.ศ. 2558

ping plot graph

 https://oss.oetiker.ch/smokeping/doc/reading.en.html

 

Syed Jahanzaib Personal Blog to Share Knowledge !

November 12, 2011

Smokeping : Best tool to plot ping / latency graphs


6 Votes

Recently I was troubleshooting a network where concerned Admin complained that they frequently lost connectivity with multiple local server’s and also sometimes with the Internet. Sometimes pings replies works okay but latency gets high or timeout / breaks occurs. So I decided to setup mrtg base ping graph to monitor ping latency. The custom made mrtg ping probe worked fine and can provide an overview on target ping / rtt and Downtime in a nice manner, its sample can be viewed at http://www.billing.onmypc.net/mrtg/ . . .



BUT . . . . . . . . . . . . . . . . . . .
I was thinking far ahead , I was thinking for much more advanced latency and quality graphs which can show ping latency / rtt / loss in much more detailed way. I recalled my memory from old days when I used to monitor my old network with variety of tools and scripts and suddenly a name popped in my mind ” SMOKEPING ” , yes this was the tool I was looking for.
SmokePing generates graphs that can reveal the quality (packet loss and latency variability) & reachability of your IP address from several distributed locations. SmokePing is a network latency monitor. It measures network latency to a configurable set of destinations on the network, and displays its findings in easy-to-read Web pages. It uses RRDtool as its logging and graphing back-end, making the system very efficient. The presentation of the data on the Web is done through a CGI with some AJAX capabilities for interactive graph exploration.
In this article I will show you howto install smokeping on FEDORA 10.

HOWTO INSTALL SMOKEPING on FEDORA 10

Installing Smokeping is relatively simple. Just issue this command as root.
1
yum -y install smokeping
and It will install smokeping along with all other tools and dependencies it requires. It may download for about 18-20 Mb of data from internet, It may take few minutes depending on your internet connection and system speed.
NOTE:  selinux is the Problem. By default its enabled in Fedora installation. Disable it by editing
1
nano /etc/selinux/config
and change the enable to disable as following.
1
SELINUX=disable
(Restart your nix box.)
After installation completes, You can access it via
You will see something similar as shown in the following screenshot.

NOTE: If you get “Access Denied: You don’t have permission to access this Folder” error, edit the following line.
1
nano /etc/httpd/conf.d/smokeping.conf
and remove all lines in this file , and paste the following.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<Directory "/usr/share/smokeping">
order deny,allow
allow from 127.0.0.1
allow from all
</Directory>
<Directory "/var/lib/smokeping">
order deny,allow
allow from 127.0.0.1
allow from all
</Directory>
ScriptAlias /smokeping/sm.cgi  /usr/share/smokeping/cgi/smokeping.cgi
ScriptAlias /smokeping/tr.cgi  /usr/share/smokeping/cgi/tr.cgi
Alias       /smokeping/images  /var/lib/smokeping/images
Alias       /smokeping         /usr/share/smokeping/htdocs
Save & exit. Now restart apache web server by
1
service httpd restart
Now try to access the smokeping cgi, it will open properly.
Now It’s time to add your target in Smokeping for monitoring. The default location for the Smokeping config file is /etc/smokeping/config, Now just for example, we will edit this file.
1
nano /etc/smokeping/config
Remove all the lines in it and paste the following lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
*** General ***
owner    = Syed Jahanzaib
contact  = aacable@hotmail.com
mailhost = smtp.ptcl.com
sendmail = /usr/sbin/sendmail
imgcache = /var/lib/smokeping/images
imgurl   = /smokeping/images
datadir  = /var/lib/smokeping/rrd
piddir   = /var/run/smokeping
smokemail = /etc/smokeping/smokemail
tmail     = /etc/smokeping/tmail
syslogfacility = local0
*** Alerts ***
to = root@localhost
from = root@localhost
+someloss
type = loss
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times  in a row
*** Database ***
step     = 300
pings    = 20
# consfn mrhb steps total
AVERAGE  0.5   1  1008
AVERAGE  0.5  12  4320
MIN  0.5  12  4320
MAX  0.5  12  4320
AVERAGE  0.5 144   720
MAX  0.5 144   720
MIN  0.5 144   720
*** Presentation ***
template = /etc/smokeping/basepage.html
+ charts
menu = Charts
title = The most interesting destinations
++ stddev
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation
format = Standard Deviation %f
++ max
sorter = Max(entries=>5)
title = Top Max Roundtrip Time
menu = by Max
format = Max Roundtrip Time %f seconds
++ loss
sorter = Loss(entries=>5)
title = Top Packet Loss
menu = Loss
format = Packets Lost %f
++ median
sorter = Median(entries=>5)
title = Top Median Roundtrip Time
menu = by Median
format = Median RTT %f seconds
+ overview
width = 600
height = 50
range = 10h
+ detail
width = 600
height = 200
unison_tolerance = 2
"Last 3 Hours"    3h
"Last 30 Hours"   30h
"Last 10 Days"    10d
"Last 400 Days"   400d
*** Probes ***
+ FPing
binary = /usr/sbin/fping
*** Slaves ***
secrets=/etc/smokeping/smokeping_secrets
+boomer
display_name=boomer
color=0000ff
+slave2
display_name=another
color=00ff00
*** Targets ***
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of <b>GLASSLINE (Pvt) Ltd.</b> <br> Here you will learn all about the latency of our network.<br><br><br><br><br> This page is maintained by Glassline. (Pvt) ltd . <br><br>Support Email: aacable@hotmail.com<br>Web: https://aacable.wordpress.com
### YOU CAN CHANGE THE FOLLOWING ACCORDING TO YOUR NETWORK ###
+ Ping
menu = WAN Connectivity
title = WAS Side Network
++ yahoo
menu = yahoo
title = yahoo ping report
host = yahoo.com
++ google
menu = google
title = Google ping report
host = google.com
### YOU CAN CHANGE FOLLOWING ACCORDING TO YOUR NETWORK ###
+ Ping2
menu = LAN Connectivity
title = LAN Side Network
++ Mikrotik
menu = Mikrotik
title = Mikrotik PPP ping report
host = 10.10.0.1
++ Proxy
menu = Proxy
title = Proxy Server ping report
host = 10.10.0.2
++ Billing
menu = Billing
title = Radius billing Server ping report
host = 10.10.0.2
Now restart smokeping process by
1
/etc/init.d/smokeping restart
Default update time for all ping probes are 5 Minutes. Try accessing the main smokeping page after 5-10 minutes so it can create necessary RRD for targets and update its graphs.
Now click on LAN connectivity to open graphs. You will see something similar as shown in the following screenshot.

Now, Click on WAN Connectivity
Now click on  the Yahoo Ping Graph showing on Right to get more detailed graph report.

To get more detailed view, click on Last 3 hours graphs, It will open this graph in NAVIGATOR mode. Now here you can select any specific area to zoom to troubleshoot at exact which time the latency problems occurs. For example in the following screenshot you can see the blue dots which shows that ping timeout occurs at specific time.

PULL DATA FROM SPECIFIC TIME

A client complained that the internet worked very slow in the morning at 10:30am. So you can pull data from smokeping graph to validate the complain or to troubleshoot what exactly happened at 10:30am :)
As you can see the blue dots showed that the ping breaks occured in the specific timings.
There are so many interesting things you can do with SMOKE-PING.
For some more examples , please visit the author web site @
Take Care, n ALLAH HAFIZ
Regard’s
Syed Jahanzaib
aacable@hotmail.com

2 Comments »

  1. SOMKEPING !!! It was really helpful :)
    Comment by Pinochio~:) — November 13, 2011 @ 8:26 AM
  2. this is really cool, had one setup with FreeBSD-8.1.Good Job Zaib
    Comment by Oronti Adewale — November 22, 2011 @ 6:45 AM

RSS feed for comments on this post. TrackBack URI

Leave a Reply



Follow

Get every new post delivered to your Inbox.
Join 2,872 other followers


  • Blog Stats

    • 4,103,582 hits
  • Categories

  • Meta

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.
    Join 2,872 other followers

  • App for pi

    nmap
    fping
    ftpd
    htop
    smokeping

    วันศุกร์ที่ 3 เมษายน พ.ศ. 2558

    วันอาทิตย์ที่ 29 มีนาคม พ.ศ. 2558

    /etc/network/interfaces อธิบาย

     /etc/network/interfaces
     
    auto lo
    iface lo inet loopback
    
    auto eth0
    allow-hotplug eth0
    iface eth0 inet dhcp
    
    auto wlan0 ==>ตั้งให้ connect auto
    allow-hotplug wlan0
    iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet dhcp

    How to Turn a Raspberry Pi into an Always-On BitTorrent Box

    http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/

    วันพุธที่ 4 กุมภาพันธ์ พ.ศ. 2558

    wordlist

    https://crackstation.net/buy-crackstation-wordlist-password-cracking-dictionary.htm

    ตัวอย่างการใช้ wput

    ตัวอย่างการใช้ wput
    wput -B net3.cap ftp://admin:admin@192.168.81.1

    How to install Gerix Wifi Cracker on Kali

    How to install Gerix Wifi Cracker on Kali

    17/07/2013
    Kali does not offer Gerix – so we have to install first.
    welcome

    Step 1 – Copy and Paste into a root terminal

    wget https://bitbucket.org/Skin36/gerix-wifi-cracker-pyqt4/downloads/gerix-wifi-cracker-master.rar

    unrar x gerix-wifi-cracker-master.rar

    cd gerix-wifi-cracker-master

    And run it:

    python gerix.py

    ISP attacker

    https://github.com/MrNasro/zynos-attacker/

    วันอังคารที่ 20 มกราคม พ.ศ. 2558

    วิธีใช้ส่ง Gmail แบบ Command line ใน Raspberry PI

    1. ติดตั้ง ssmtp
    sudo apt-get install ssmtp
     2. แก้ไขค่า config /etc/ssmtp/ssmtp.conf โดยให้เพิ่ม config เข้าไปดังนี้
       sudo nano /etc/ssmtp/ssmtp.conf

    AuthUser=<username@gmail.com>
    AuthPass=Your-Gmail-Password
    FromLineOverride=YES
    mailhub=smtp.gmail.com:587
    UseSTARTTLS=YES

    โดย <username@gmail.com> เป็น email ของเราครับ และ Your-Gmail-Password เป็น password ของ email เราครับ ในที่นี้ผมใช้เป็น techsuiiblog@gmail.com ครับ

    3.ติดตั้ง mailutils สำหรับการส่งเมล์จาก command line ครับ
    # sudo apt-get install mailutils
    4. เมื่อติดตั้ง mailutils เรียบร้อย เราจะสามารถใช้ mail command ได้แล้วครับ สามารถทดสอบส่งได้โดยใช้เป็น
    # sudo echo “test for techsuii.com” | mail -s “test techsuii” receiver@gmail.com
    ทีนี้ปลายทางก็จะได้รับ email จาก techsuiiblog@gmail.com แล้วครับ

    วิธีการทดสอบ Speed Internet ผ่าน Command Line ใน Raspberry PI

    1. # apt-get install python
    2. # wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
    3. sudo python speedtest_cli.py
    4. Output

    Retrieving speedtest.net configuration...
    Retrieving speedtest.net server list...
    Testing from TOT (125.24.178.73)...
    Selecting best server based on latency...
    Hosted by AIS (Bangkok) [22.64 km]: 62.284 ms
    Testing download speed........................................
    Download: 9.35 Mbits/s
    Testing upload speed..................................................
    Upload: 0.50 Mbits/s

    5. หากเราต้องการจะทดสอบที่ server ตัวอื่นที่ไม่ใช่ของไทย เราสามารถ list server ได้โดยใช้คำสั่งเป็น

    sudo python speedtest_cli.py --list | more
    Retrieving speedtest.net configuration...
    Retrieving speedtest.net server list...
    5440) tondev.com (Bangkok, Thailand) [22.64 km]
    5394) CS LOXINFO (Bangkok, Thailand) [22.64 km]
    1219) STS Group (Bangkok, Thailand) [22.64 km]
    5431) Chulalongkorn University (Bangkok, Thailand) [22.64 km]
    2459) SBN (Bangkok, Thailand) [22.64 km]
    3147) AIS (Bangkok, Thailand) [22.64 km]
     428) adslthailand.com (Bangkok, Thailand) [22.64 km]
    5609) Internet Thailand PCL (Bangkok, Thailand) [22.64 km]
    4222) Shama Thunder (Bangkok, Thailand) [22.64 km]
    3855) dtac (Bangkok, Thailand) [22.64 km]
    4347) cattelecom (Bangkok, Thailand) [22.64 km]
    2256) Smart Axiata (Phnom Penh, Cambodia) [517.16 km]
    4673) CooTel (Phnom Penh, Cambodia) [517.16 km]
    1452) WiCAM Corporation (Phnom Penh, Cambodia) [517.16 km]
    5828) SINET (Phnom Penh, Cambodia) [517.16 km]
    5797) MekongNet ISP (Phnom Penh, Cambodia) [517.16 km]
    4182) EZECOM (Phnom Penh, Cambodia) [517.16 km]
    2504) ONLINE (Phnom Penh, Cambodia) [517.16 km]
    1788) Metfone (Phnom Penh, Cambodia) [517.16 km]
    3281) OPENNET (Phnom Penh, Cambodia) [517.16 km]
    1307) Prince of Songkla Univ (Surat Thani Province, Thailand) [521.14 km]
    จะเห็นว่าด้านหน้าสุดแต่ละแถว จะมีตัวเลขอยู่ นั่นคือ Server ID นั่นเอง โดยเมื่อเราเลือกได้แล้วว่าจะทดสอบกับ server ตัวไหนให้ใช้คำสั่งเป็น
    6. speedtest_cli –server serverid
    เช่น
    7. หากเราต้องการทดสอบไปที่  Viettel IDC (Ho Chi Minh City, Vietnam) ให้เราใช้คำสั่งเป็น
    sudo python speedtest_cli.py–server 2427

    แก้ปัญหา wash -i mon0 ไม่โชว์

    Hi guys i think i found the solution, that may help you.
    First of all you need to install libpcap-dev and libsqlite3-dev packages from repository.

    1. ~# apt-get install libpcap-dev
    2. ~# apt-get isntall libsqlite3-dev

    Then, you should download the reaver itself. You can do that from official site.
    3. ~# wget http://reaver-wps.googlecode.com/files/reaver-1.4.tar.gz
    Unpack tar :
    4. ~# tar -xvzf reaver-1.4.tar.gz

    Go to unpacked dir
    5. ~# cd reaver-1.4/src/
    6. ~# ./configure
    7. ~# make
    8. ~# sudo make install

    Then remove an existing wash

    8. ~# sudo rm /usr/bin/wash

    copy wash from src direcory to /usr/bin/

    9. ~# cp wash /etc/reaver/

    Now try wash

    10. ~# wash -i mon0
    and it should work. =)

    That's all. I my case I fix the problem now it works properly. I hope it helps you too.


    https://forums.kali.org/archive/index.php/t-89.html

    วันพุธที่ 14 มกราคม พ.ศ. 2558

    เปลี่ยน MOTD Raspberry PI

    1. Create a script (Home /root/update_motd.sh
    2. ใส่ #! /bin/sh upSeconds=`/usr/bin/cut -d. -f1 /proc/uptime` secs=$(($upSeconds%60)) mins=$(($upSeconds/60%60)) hours=$(($upSeconds/3600%24)) days=$(($upSeconds/86400)) UPTIME=`printf "%d days, %02dh %02dm %02ds " "$days" "$hours" "$mins" "$secs"` echo "\033[0;32m .~~. .~~. \033[0;37m`date +"%A, %e %B %Y, %R"`\033[0;32m '. \ ' ' / .' \033[0;37m`uname -srmo`\033[0;31m .~ .~~~..~. \033[0;37m\033[0;31m : .~.'~'.~. : \033[0;37mUptime.............: $UPTIME\033[0;31m ~ ( ) ( ) ~ \033[0;37mMemory.............: $((`cat /proc/meminfo | grep MemFree | awk {'print $2'}`/1024))MB (Free) / $((`cat /proc/meminfo | grep MemTotal | awk {'print $2'}`/1024))MB (Total)\033[0;31m ( : '~'.~.'~' : ) \033[0;37mRunning Processes..: `ps ax | wc -l | tr -d " "`\033[0;31m ~ .~ ( ) ~. ~ \033[0;37m\033[0;31m ( : '~' : ) \033[0;37mIP Addresses.......: `/sbin/ifconfig | /bin/grep "Bcast:" | /usr/bin/cut -d ":" -f 2 | /usr/bin/cut -d " " -f 1` / `wget -q -O - http://icanhazip.com/ | tail`\033[0;31m '~ .~~~. ~' \033[0;37mTemperature........: `vcgencmd measure_temp | sed "s/temp=//"`\033[0;31m '~' \033[0;37m" > /etc/motd
    3. sudo chmod +x /root/update_motd.sh
    4.sudo ./update_motd.sh
    5. เพิ่มใน cron ให้ทำงานตลอด
       crontab -e
       5 * * * * /root/update_motd.sh 
    #ให้ทำงานทุก 5 นาที






     


    ที่มา http://www.pihomeserver.fr/en/2013/04/29/personnaliser-votre-message-de-connexion-ssh-avec-motd/


    อธิบาย
    http://www.mewbies.com/how_to_customize_your_console_login_message_tutorial.htm