Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
Useful Linux Bash Scripts
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Don GasCan" data-source="post: 19509533" data-attributes="member: 316529"><p><strong><span style="font-size: 12px"><span style="font-size: 10px">Disk space check </span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">output=$(df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $4 " " $1 }')</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px">usep=$(echo $output | awk '{ print $1}' | cut -d'G' -f1 |cut -d '.' -f1)</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> partition=$(echo $output | awk '{ print $2 }' )</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> if [ $usep -le 10 ]; then</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> echo "Running out of space \"$partition ($usep GB)\" on $(hostname) as on $(date)" |</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> mail -s "Alert from file Server: Almost out of disk space $usep GB. Delete backups older than 3 days from /home/uploads." <a href="mailto:xxxx@gmail.com">xxxx@gmail.com</a></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> fi</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">Server down check bash</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">!/bin/bash</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">IP=192.168.1.91</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> ping -c 4 $IP &> /dev/null</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> if [ $? == 0 ]</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> then</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> echo "$IP Server is UP"</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> else</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> echo "91 server ($IP)is not responding on $(date).Check the server time once you start." |</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> mail -s "91 Bono QA server is down!!" <a href="mailto:xxx@gmai.com">xxx@gmai.com</a></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> fi</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">Check any IP duplication in network </span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">#!/bin/bash </span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">cd /rezsystem/rezadmin/</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">rm -rf ip_duplication1.log</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">rm -rf ip_duplication2.log</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">rm -rf ip_duplication3.log</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">rm -rf ip_duplication4.log</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">arp-scan -I eth0 -l | awk '{ print $1 }' >> ip_duplication1.log</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">sort ip_duplication1.log | uniq -d -c >> ip_duplication2.log</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">usep=$(cat ip_duplication2.log |wc -l)</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">if [ $usep -ne 0 ]; then</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">arp-scan -I eth0 -l |grep "DUP: 2" | awk '{ print $1 }' >> ip_duplication3.log</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">while read line</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">do</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">arp-scan -I eth0 -l |egrep -w $line >> ip_duplication4.log</span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">done < ip_duplication3.log</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">echo "Following IPs are duplicated in 192.168.0.0/23 network as on $(date).</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px">$(cat ip_duplication4.log)" | </span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> mail -s "IP Duplication Found in Local Network." <a href="mailto:xxx@gmail.com">xxx@gmail.com</a></span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"> fi</span></span></strong></p><p> <strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p><p><strong><span style="font-size: 12px"><span style="font-size: 10px"></span></span></strong></p></blockquote><p></p>
[QUOTE="Don GasCan, post: 19509533, member: 316529"] [B][SIZE="3"][SIZE="2"]Disk space check output=$(df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $4 " " $1 }') usep=$(echo $output | awk '{ print $1}' | cut -d'G' -f1 |cut -d '.' -f1) partition=$(echo $output | awk '{ print $2 }' ) if [ $usep -le 10 ]; then echo "Running out of space \"$partition ($usep GB)\" on $(hostname) as on $(date)" | mail -s "Alert from file Server: Almost out of disk space $usep GB. Delete backups older than 3 days from /home/uploads." [email]xxxx@gmail.com[/email] fi Server down check bash !/bin/bash IP=192.168.1.91 ping -c 4 $IP &> /dev/null if [ $? == 0 ] then echo "$IP Server is UP" else echo "91 server ($IP)is not responding on $(date).Check the server time once you start." | mail -s "91 Bono QA server is down!!" [email]xxx@gmai.com[/email] fi Check any IP duplication in network #!/bin/bash cd /rezsystem/rezadmin/ rm -rf ip_duplication1.log rm -rf ip_duplication2.log rm -rf ip_duplication3.log rm -rf ip_duplication4.log arp-scan -I eth0 -l | awk '{ print $1 }' >> ip_duplication1.log sort ip_duplication1.log | uniq -d -c >> ip_duplication2.log usep=$(cat ip_duplication2.log |wc -l) if [ $usep -ne 0 ]; then arp-scan -I eth0 -l |grep "DUP: 2" | awk '{ print $1 }' >> ip_duplication3.log while read line do arp-scan -I eth0 -l |egrep -w $line >> ip_duplication4.log done < ip_duplication3.log echo "Following IPs are duplicated in 192.168.0.0/23 network as on $(date). $(cat ip_duplication4.log)" | mail -s "IP Duplication Found in Local Network." [email]xxx@gmail.com[/email] fi [/SIZE][/SIZE][/B] [/QUOTE]
Insert quotes…
Verification
Haya warak paha keeyada? (haya wadi kireema paha)
Post reply
Top
Bottom