F5 Week/month patrol script

Source: Internet
Author: User
Tags failover snmp snmpwalk

General F5 (LTM) patrol content includes collecting current UCS configuration backups, collecting Qkview self-test packages, log packaging, recording the total number of current node, pool, VS, available quantity, number of exceptions, number of known, and so on.

Due to the F5 of the underlying Linux to do a lot of restrictions, so get F5 a lot of information can only be implemented through SNMP, please ensure that F5 SNMP uses V2C version, the community name can modify the variable, allow 127.0.0.1 access.

#!/bin/bashfunction line () {    cols= ' tput cols '          for l in  ' Seq 1 ${cols} '     do     echo -n  "="     done}function define () {     User= ' WhoAmI '     hostname= ' uname -n '     path=/tmp/inspection/     public= "public"     datestamp= ' date +%y%m%d '      timestamp= ' date +%h%m%s '     platform= ' Tmsh show sys hardware  | egrep -A1 Platform | awk  ' nr==2{print $2,$3} '      sn= ' tmsh show sys hardware | grep  "chassis serial"  | awk   ' {print $3} '     version= ' Tmsh show sys version | grep  -E  "  versioN " | awk  ' {print $2} '     uptime= '/usr/bin/uptime | awk  -F  ' [, | ]+ '   ' {print $4,$5,$6} '}function check () {    if  [  $user  !=  "root"  ]    then         echo  "PLEASE USE ROOT USER ."         exit 1    fi         if [ ! -d  $path  ]    then         mkdir -p  $path     fi}function select_ Version () {    bigpipe version > /dev/null 2>&1         if [ $? != 0 ]    then         version11    else        version10    fi}function  Version10 () {    fstime= ' bigpipe failover show | awk  ' {print  $4,$5} '         snmp_check_version10    snmp         tar zcf ${path}log_${hostname}_${datestamp}.tar.gz / var/log/* >/dev/null 2>&1    tmsh save sys ucs / Var/local/ucs/ucs_${hostname}_${datestamp}.ucs >/dev/null 2>&1    cp  /var/local/ucs/ucs_${hostname}_${datestamp}.ucs  $path     qkview >  /dev/null 2>&1    mv /var/tmp/${hostname}.tgz  $path          logfilt    output    backup} Function version11 () { &Nbsp;  fstime= ' tmsh show sys failover | awk  ' {print $4,$5} '         snmp_check_version11    snmp     tar zcf ${path}log_${hostname}_${datestamp}.tar.gz /var/log/* >/dev/null  2>&1    tmsh save sys ucs /var/local/ucs/ucs_${hostname}_ ${datestamp}.ucs >/dev/null 2>&1    cp /var/local/ucs/ucs_${ hostname}_${datestamp}.ucs  $path     qkview > /dev/null 2>&1     mv /var/tmp/${hostname}.qkview  $path          logfilt    output    backup}function snmp_check_ Version10 () {    numstart= ' awk  '/^snmpd {$/{print nr} '  /config/bigip_ Sys.conf '     numstop= ' awk  '/^sshd {$/{print nr} '  /config/bigip_sys.conf '     numend= ' echo | awk   "{print ${numstop}-1}" '     numcheck= ' sed -n   "${numstart},${numend}p"  /config/bigip_sys.conf | grep -E  "127.0.0.1|0.0.0.0/ 0.0.0.0 " | wc -l '         if [  $numcheck   = 0 ]    then        echo  "please  allow 127.0.0.1 snmp . "         exit 2    fi}function snmp_check _version11 () {    numstart= ' awk  '/^sys snmp {$/{print nr} '  /config /bigip_base.conf '     numstop= ' awk  '/^    communities {$/{ PRINT NR} '  /config/bigip_base.conf '     numend= ' ECHO |&NBsp;awk  "{print ${numstop}-1}" '     numcheck= ' sed -n  "${numstart},${ Numend}p " /config/bigip_base.conf | grep -E "  127. |0.0.0.0/0.0.0.0 " |  wc -l '         if [  $numcheck  = 0 ]     then        echo  "please allow  127.0.0.1 snmp . "         exit 2    fi}function snmp () {     vs_red= ' snmpwalk -v 2c -c  $public  localhost . 1.3.6.1.4.1.3375.2.2.10.13.2.1.2|grep -c  "Red" '     vs_green= ' snmpwalk -v  2c -c  $public  localhost .1.3.6.1.4.1.3375.2.2.10.13.2.1.2|grep -c  "Green"     vs_blue= ' snmpwalk -v 2c -c  $public  localhost . 1.3.6.1.4.1.3375.2.2.10.13.2.1.2|grep -c  "Blue" '     vs_total= ' snmpwalk -v 2c -c   $public  localhost .1.3.6.1.4.1.3375.2.2.10.13.2.1.2|grep -c  "F5-bigip-local-mib"     vs_yellow= ' snmpwalk -v 2c -c  $public  localhost . 1.3.6.1.4.1.3375.2.2.10.13.2.1.2|grep -c  "Yellow" '     pool_green= ' snmpwalk  -v 2c -c  $public  localhost .1.3.6.1.4.1.3375.2.2.5.5.2.1.2|grep -c  "Green"     pool_blue= ' snmpwalk -v 2c -c  $public  localhost . 1.3.6.1.4.1.3375.2.2.5.5.2.1.2|grep -c  "Blue" '     pool_red= ' snmpwalk -v  2c -c  $public  localhost .1.3.6.1.4.1.3375.2.2.5.5.2.1.2|grep -c  "Red"     pool_yellow= ' snmpwalk -v 2c -c  $public  localhost . 1.3.6.1.4.1.3375.2.2.5.5.2.1.2|grep -c  "Yellow" '     pool_total= ' snmpwalk -v 2c -c  $public   localhost .1.3.6.1.4.1.3375.2.2.5.5.2.1.2|grep -c  "F5-bigip-local-mib"      Node_blue= ' snmpwalk -v 2c -c  $public  localhost .1.3.6.1.4.1.3375.2.2.4.3.2.1.3| grep -c  "Blue" '     node_green= ' snmpwalk -v 2c -c  $public  localhost .1.3.6.1.4.1.3375.2.2.4.3.2.1.3|grep -c  "Green" '     node_ Red= ' snmpwalk -v 2c -c  $public  localhost .1.3.6.1.4.1.3375.2.2.4.3.2.1.3|grep  -c  "Red" '     node_yellow= ' snmpwalk -v 2c -c  $public   localhost .1.3.6.1.4.1.3375.2.2.4.3.2.1.3|grep -c  "Yellow" '     node_total= ' snmpwalk -v 2c -c  $public  localhost .1.3.6.1.4.1.3375.2.2.4.3.2.1.3|grep -c   "F5-bigip-local-mib" '}fuNction logfilt () {    gunzip -c /var/log/ltm.{ 30..1}.gz > ${path}log.tmp > /dev/null 2>&1    cat  /var/log/ltm >>  ${path}log.tmp    grep -E  "err|crit| Alert|emery " ${path}log.tmp > ${path}logfilt.log    numerr= ' cat ${ Path}logfilt.log | wc -l '}function output () {    line > ${ path}inspection.log    echo -e  "Date:\t\t${datestamp} ${timestamp}"   >> ${path}inspection.log    echo -e  "Hostname:\t${hostname}"   >> ${path}inspection.log    echo -e  "Platform:\t${platform}"   >> ${path}inspection.log    echo -e  "SERIAL NUMBER:\T${SN}"  >> ${path}inspection.log    echo -e  "Version:\t${version}"  >> ${path}inspection.log     echo -e  "Run time:\t${uptime}"  >> ${path}inspection.log     echo  " >> ${path}inspection.log    echo -e " Virtual  server status:\ttotal ${vs_total}\t\tavailable ${vs_green}\t\tunavailable ${vs_ Yellow}\t\toffine ${vs_red}\t\tunknow ${vs_blue} " >> ${path}inspection.log     echo -e  "Pool status:\t\ttotal ${pool_total}\t\tavailable ${pool_ Green}\t\tunavailable ${pool_yellow}\t\toffine ${pool_red}\t\tunknow ${pool_blue} " > > ${path}inspection.log    echo -e  "node status:\t\ttotal ${ Node_total}\t\tavailable ${node_green}\t\tunavailable ${node_yellow}\t\toffine ${node_red}\t\ Tunknow ${node_blue} " >> ${path}inspection.log    echo  ""  >> ${path} inspection.log    echo -e  "the recent failover time :\t${ Fstime} " >> ${path}inspection.log    echo -e " the err  Log number :\t\t${numerr} " >> ${path}inspection.log    line  >> ${path}inspection.log}function backup () {    tar zcf ${ path}inspection_backup_${datestamp}_${timestamp}.tar.gz  ' Find ${path} -type f '  >  /dev/null 2>&1    find  $path  -type f ! -name   "Inspection.log"  ! -name  "inspection_backup_${datestamp}_${timestamp}.tar.gz"  !  -name  " | xargs rm -f {}}function main" () {     define    check    select_version}main 




This article is from "rookie East" blog, please be sure to keep this source http://radish.blog.51cto.com/5944322/1735267

F5 Week/month patrol script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.