[root@ scripts]# cat 01_request.sh
#!/bin/bash
# mikeyom@gmail.com 10-2021
my_year=`date +'%Y' -d "10 minute ago"`
my_month=`date +'%m' -d "10 minute ago"`
my_date=`date +'%d' -d "10 minute ago"`
my_hour=`date +'%H' -d "10 minute ago"`
my_min=`date +'%M' -d "10 minute ago"`
if [ ! -f /tmp/rtb-request.txt ]; then
touch /tmp/rtb-request.txt
fi
my_num=`zcat /opt/jboss/wildfly/standalone/log/requests/gzipped-$my_year-$my_month-$my_date-$my_hour/requests.v11.log.$my_year-$my_month-$my_date-$my_hour-$my_min.gz_processed | wc -l`
echo "$my_num $my_year-$my_month$my_date-$my_hour$my_min" >> /tmp/rtb-request.txt
w | head -n 1 | awk '{print $8}' | cut -d"," -f1 | cut -d "." -f1 > /tmp/one_rtb_load.txt
free -t | awk 'NR == 2 {printf(" %.0f"), $3/$2*100}' > /tmp/one_rtb_mem1.txt
echo "" >> /tmp/one_rtb_mem1.txt
cat /tmp/one_rtb_mem1.txt | awk '{print $1}' > /tmp/one_rtb_mem.txt
idle=`/usr/bin/iostat | head -n 4 | tail -n 1 | awk '{print $6}' | cut -d'.' -f1`
used=$(( 100 - $idle ))
echo "$used" > /tmp/one_rtb_cpu.txt
#!/bin/bash
# mikeyom@gmail.com 12-2023
my_path2=/backup/C2/2023-1129/hs
ls -l $my_path2/ | awk '{print $9}' > /root/scripts/z_aero/hs.txt
sed -i '1d' /root/scripts/z_aero/hs.txt
while read -u3 hs
do
asrestore --host 127.0.0.1 -i $my_path2/$hs --namespace ns1d --unique
done 3< /root/scripts/z_aero/hs.txt
find /aerospike/* -type d -ctime +21 -exec rm -rf {} \;
#!/bin/bash
# mikeyom@gmail.com 04-2023
my_path=/var/lib/jenkins/mike_scripts/z_pub_ip
declare -a set1_list=("host1" "host2" "host3" "host4")
for my_set in "${set1_list[@]}"
do
echo "============================================================"
echo ""
echo $my_set
echo ""
gcloud compute instances --project $my_set list | grep RUNNING > $my_path/$my_set.txt
cat $my_path/$my_set.txt
done
#!/bin/bash
# mikeyom@gmail.com 02-2024
rm -f .my.cnf
echo "y" | cp .my.cnf.failed_over .my.cnf
my_path=/home/myom
my_year=`date +'%Y'`
my_month=`date +'%m'`
my_date=`date +'%d'`
my_hour=`date +'%H'`
my_min=`date +'%M'`
today="$my_year-$my_month$my_date"
my_time="$my_year-$my_month$my_date-$my_hour$my_min"
mkdir $my_path/$today
echo "" >> $my_path/status.txt
echo "Starting the DB backup sqldump $my_time" >> $my_path/status.txt
mydumper \
--outputdir=/home/myom/$today/ \
--rows=500000 \
--build-empty-files \
--threads=5 \
--compress-protocol
/home/myom/timestamp.sh
#!/bin/bash
# mikeyom@gmail.com 03-2023
/usr/bin/mysqldump --set-gtid-purged=OFF mydb > mydb.sql
root@as-ea1c-sftp:/usr/lib/nagios/plugins# cat check_4ndisk.sh
#!/bin/bash
# myom@gmail.com 07-2023
declare -a set1_list=("/dev/root" "/dev/sdb" "/dev/sdc" "/dev/sdd")
my_host=`hostname`
for my_set in "${set1_list[@]}"
do
my_size=`df -h | grep $my_set | awk '{print $2}'`
my_used=`df -h | grep $my_set | awk '{print $3}'`
my_ava=`df -h | grep $my_set | awk '{print $4}'`
my_pct=`df -h | grep $my_set | awk '{print $5}' | cut -d"%" -f1`
if [ $my_pct -gt 90 ]; then
echo "Critical - $my_host $my_set disk size is $my_size using $my_used percentage is $my_pct%"
exit 2
fi
done
echo "OK - All disks of $my_host are good"
exit 0
#!/bin/bash
# mikeyom@gmail.com 03-2021
my_host=`hostname`
my_total=`free -g | grep Mem | awk '{print $2}'`
my_used=`free -g | grep Mem | awk '{print $3}'`
if [ $my_used -eq 0 ]; then
echo "OK - $my_host total memory is $my_total GB used memory is $my_used GB and memory useage percentage is $my_mem % | Mem=${my_mem};0;100"
exit 0
fi
my_mem=`free -g | grep Mem | awk '{print $3/$2 * 100.0}' | cut -d'.' -f1`
my_high=90
my_warn=80
if [ $my_mem -gt $my_high ]; then
echo "Critical - $my_host total memory is $my_total GB used memory is $my_used GB and memory useage percentage is $my_mem % | Mem=${my_mem};0;100"
exit 2
fi
if [ $my_mem -gt $my_warn ]; then
echo "Warning - $my_host total memory is $my_total GB used memory is $my_used GB and memory useage percentage is $my_mem % | Mem=${my_mem};0;100"
exit 1
fi
echo "OK - $my_host total memory is $my_total GB used memory is $my_used GB and memory useage percentage is $my_mem % | Mem=${my_mem};0;100"
exit 0
#!/bin/bash
# mikeyom@gmail.com 07-2023
my_path=/var/lib/jenkins/mike_scripts/pubip
my_proj="myproj"
max_vm="50"
gcloud compute instances --project $my_proj list | grep RUNNING > $my_path/$my_proj.txt
cat $my_path/$my_proj.txt | awk '{print $(NF-1)}' > $my_path/$my_proj-ip.txt
echo "0" > $my_path/$my_proj-status.txt
while read -u3 ip
do
if [[ $ip == 10* ]]; then
echo $ip
echo "All internal IPs"
else
echo $ip
echo "External IP exists in $my_proj"
echo "1" > $my_path/$my_proj-status.txt
fi
done 3< $my_path/$my_proj-ip.txt
my_status=`cat $my_path/$my_proj-status.txt`
if [ $my_status -eq 1 ]; then
mail -s "External IP exists in $my_proj" mikeyom@gmail.com < $my_path/$my_proj.txt
fi
my_num=`wc -l $my_path/$my_proj.txt | awk '{print $1}'`
echo ""
echo $my_num
#exit 0
if [ $my_num -gt $max_vm ]; then
mailx -s "$my_proj current $my_num max $max_vm" mikeyom@gmail.com < $my_path/$my_proj.txt
cat $my_path/$my_proj.txt
else
echo "Good: $my_proj current $my_num max $max_vm"
cat $my_path/$my_proj.txt
fi
#!/bin/bash
for file in *.zip
do
mv -- "$file" "${file// /_}"
done
git clone https://github.com/drwetter/testssl.sh
#!/bin/bash
# mikeyom@gmail.com 02-2023
my_file=/home/myom/scan_ip.txt
rm -rf /home/myom/scan_results.txt
touch /home/myom/scan_results.txt
while read -u3 ip
do
echo "=============================================" >> /home/myom/scan_results.txt
echo "" /home/scan_results.txt
/home/myom/testssl.sh/testssl.sh -U $ip:443 | tee -a /home/myom/scan_results.txt
echo "" >> /home/myom/scan_results.txt
done 3< $my_file
#!/bin/bash
# mikeyom@gmail.com 05-2023
my_path=/var/lib/jenkins/mike_scripts/z_sftp
rm -f $my_path/result.txt
touch $my_path/result.txt
while read -u3 login
do
user=`echo $login | awk '{print $1}'`
pass=`echo $login | awk '{print $2}'`
echo "" >> $my_path/result.txt
echo "$user" >> $my_path/result.txt
echo "" >> $my_path/result.txt
lftp -e "set net:timeout 10" sftp://"$user":"$pass"@sftp.mikeyom.com -e "ls; bye" | tee >> $my_path/result.txt
echo "==================================================================" >> $my_path/result.txt
done 3< $my_path/users.txt
#!/bin/bash
zcat split_fileaa.gz | split -b 4G - split_part
gzip split_part*
cd /usr/local/nagios/libexec
vi check_4apache
#!/bin/bash
# mikeyom@gmail.com 03-2023
my_status=`systemctl show -p ActiveState apache2 | sed 's/ActiveState=//g'`
if [ $my_status != 'active' ]; then
echo "Critical - Apache2 service is not running"
exit 2
fi
echo "OK - Apache2 is running"
exit 0
define service {
use local-service ; Name of service template to use
host_name localhost
service_description HTTP
check_command check_4apache
notifications_enabled 0
}
#!/bin/bash
# mikeyom@gmail.com 01-2023
my_path=/tmp/z_nagios
AGO="10"
# my_year=`date +'%Y' -d "$AGO minutes ago"`
# my_month=`date +'%m' -d "$AGO minutes ago"`
# my_date=`date +'%d' -d "$AGO minutes ago"`
# my_hour=`date +'%H' -d "$AGO minutes ago"`
# my_min=`date +'%M' -d "$AGO minutes ago"`
my_year=`date +'%Y' -d "$AGO Hours ago"`
my_month=`date +'%m' -d "$AGO Hours ago"`
my_date=`date +'%d' -d "$AGO Hours ago"`
my_hour=`date +'%H' -d "$AGO Hours ago"`
my_min=`date +'%M' -d "$AGO Hours ago"`
echo $my_year
echo $my_month
echo $my_date
echo $my_hour
my_chk=`aws s3 ls s3://my_aws/logs/con_req_eve_v2/y=$my_year/m=$my_month/d=$my_date/h=$my_hour/ | wc -l`
echo "$my_chk $my_year-$my_month$my_date-$my_hour" >> $my_path/metamarket.txt
tail -n 20 $my_path/metamarket.txt > $my_path/metamarket.txt.tmp
rm -f $my_path/metamarket.txt
mv $my_path/metamarket.txt.tmp $my_path/metamarket.txt