This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
aix:scripts_category:nagios_aix_check [2024/06/14 17:06] manu [Check SEA status] |
aix:scripts_category:nagios_aix_check [2025/02/24 15:34] (current) manu [Check path disks] |
||
---|---|---|---|
Line 321: | Line 321: | ||
</code> | </code> | ||
- | ==== check_ntp_aix.sh ==== | + | ==== check_ntp_aix.sh (as nagios user) ==== |
+ | <code> | ||
+ | #!/bin/ksh93 | ||
+ | # | ||
+ | # AIX check NTP for Nagios v1.0 06/2023 | ||
+ | # EIF | ||
+ | # | ||
+ | |||
+ | STATE_OK=0 | ||
+ | STATE_WARNING=1 | ||
+ | STATE_CRITICAL=2 | ||
+ | STATE_UNKNOWN=3 | ||
+ | STATE_DEPENDENT=4 | ||
+ | |||
+ | MAXSEC=30 # max delay allowed in seconds | ||
+ | OUTPUT=$(ntpq -p 2>&1 | sed 's/$/;/g') | ||
+ | |||
+ | if [ $(echo $OUTPUT | grep refused >/dev/null 2>&1; echo $?) -eq 0 ] | ||
+ | then | ||
+ | EXIT_CODE=$STATE_CRITICAL | ||
+ | OUTPUT="Process: xntpd not running" | ||
+ | else | ||
+ | if [[ $(echo $OUTPUT | tr ';' '\n' | sed '/^$/d' | sed 's/^\ //g' | tail +3) == "" ]] | ||
+ | then | ||
+ | EXIT_CODE=$STATE_CRITICAL | ||
+ | OUTPUT="Process: xntpd not running" | ||
+ | else | ||
+ | OFFSET=$(echo $OUTPUT | tr ';' '\n' | sed '/^$/d' | sed 's/^\ //g' | tail +3 | rev | awk '{print $2}' | rev | cut -d'.' -f1 | sed 's/+//' | sed 's/-//' | sort -u | tail -1) | ||
+ | if [ $(echo $OUTPUT | tr ';' '\n' | sed '/^$/d' | sed 's/^\ //g' | tail +3 | grep -q '^\*'; echo $?) -eq 0 ] | ||
+ | then | ||
+ | EXIT_CODE=$STATE_OK | ||
+ | OUTPUT="Process: xntpd offset ${OFFSET}s synchronized OK" | ||
+ | else | ||
+ | if [ $(echo $OFFSET) -lt "$MAXSEC" ] | ||
+ | then | ||
+ | EXIT_CODE=$STATE_OK | ||
+ | OUTPUT="Process: xntpd offset ${OFFSET}s synchronized OK" | ||
+ | else | ||
+ | EXIT_CODE=$STATE_WARNING | ||
+ | OUTPUT="Process: xntpd offset ${OFFSET}s Not synchronized" | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | echo $OUTPUT | tr ';' '\n' | sed '/^$/d' | sed 's/^\ //g' | tail +3 | rev | awk '{print $2}' | rev | cut -d'.' -f1 | sed 's/-//' | ||
+ | |||
+ | echo $OUTPUT | ||
+ | exit $EXIT_CODE | ||
+ | </code> | ||
+ | |||
+ | As root: | ||
<code> | <code> | ||
#!/bin/ksh93 | #!/bin/ksh93 | ||
Line 521: | Line 572: | ||
# v1.2 change for VSCSI | # v1.2 change for VSCSI | ||
# v1.3 add verbose (-v), improvements linux | # v1.3 add verbose (-v), improvements linux | ||
+ | # On linux, add into /etc/sudoers the following lines for linux: | ||
+ | # nagios ALL=(ALL) NOPASSWD: /usr/sbin/multipath | ||
+ | # nrpe ALL=(ALL) NOPASSWD: /usr/sbin/multipath | ||
+ | |||
# number of path per type of disk | # number of path per type of disk | ||
Line 573: | Line 628: | ||
pathok_pct=$(echo "scale=1;100*$pathok/$nbpath" | bc | cut -d '.' -f1) | pathok_pct=$(echo "scale=1;100*$pathok/$nbpath" | bc | cut -d '.' -f1) | ||
verbose="$verbose $i;$pathok/$nbpath" # verbose message | verbose="$verbose $i;$pathok/$nbpath" # verbose message | ||
- | if [ "$pathok_pct" -le "50" ] | + | if [ "$pathok_pct" -lt "50" ] |
then | then | ||
MSG="$MSG $i;$pathok/$nbpath" | MSG="$MSG $i;$pathok/$nbpath" | ||
Line 653: | Line 708: | ||
pathok_pct=$(echo "scale=1;100*$pathok/$nbpath" | bc | cut -d '.' -f1) | pathok_pct=$(echo "scale=1;100*$pathok/$nbpath" | bc | cut -d '.' -f1) | ||
verbose="$verbose $hdisk;$pathok/$nbpath" | verbose="$verbose $hdisk;$pathok/$nbpath" | ||
- | if [ "$pathok_pct" -le "50" ] | + | if [ "$pathok_pct" -lt "50" ] |
then | then | ||
MSG="$MSG $hdisk;$pathok/$nbpath" | MSG="$MSG $hdisk;$pathok/$nbpath" | ||
Line 713: | Line 768: | ||
<code> | <code> | ||
#!/bin/ksh | #!/bin/ksh | ||
- | # v1.0 eif check LACP | + | # v1.1 eif check LACP |
# | # | ||
# Add sudoers: | # Add sudoers: | ||
Line 737: | Line 792: | ||
MSG="No SEA available on $hostname" | MSG="No SEA available on $hostname" | ||
EXITSTATUS=2 #Exit status critical | EXITSTATUS=2 #Exit status critical | ||
- | exit $EXITSTATUS | + | else |
- | fi | + | #Verification ensemble des cartes si disponible |
+ | for ent in $(lsdev -Cc adapter | grep Shared | awk '{print $1}') | ||
+ | do | ||
+ | # check physical ports / links | ||
+ | count_all=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep -i status | grep "Physical Port Link Status" | wc -l | awk '{print $1}') | ||
+ | count_up=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep -i status | grep "Physical Port Link Status" | grep Up |wc -l | awk '{print $1}') | ||
- | #Verification ensemble des cartes si disponible | + | if [ $count_up -ne $count_all ] |
- | for ent in $(lsdev -Cc adapter | grep Shared | awk '{print $1}') | + | then |
- | do | + | MSG="One or more Ethernet port down" |
- | # check physical ports / links | + | EXITSTATUS=1 #Exit status Warning |
- | count_all=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep -i status | grep "Physical Port Link Status" | wc -l | awk '{print $1}') | + | else |
- | count_up=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep -i status | grep "Physical Port Link Status" | grep Up |wc -l | awk '{print $1}') | + | MSG="No ethernet port issue" |
+ | EXITSTATUS=0 #Exit status OK | ||
+ | fi | ||
- | if [ $count_up -ne $count_all ] | + | # check physical ports Speed, must be the same on all ports |
- | then | + | nb_speed=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep "Physical Port Speed" | sort -u | wc -l | awk '{print $1}') |
- | MSG="One or more Ethernet port down" | + | |
- | EXITSTATUS=1 #Exit status Warning | + | |
- | else | + | |
- | MSG="No ethernet port issue" | + | |
- | EXITSTATUS=0 #Exit status OK | + | |
- | fi | + | |
- | # check physical ports Speed, must be the same on all ports | + | if [ $nb_speed != "1" ] |
- | nb_speed=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep "Physical Port Speed" | sort -u | wc -l | awk '{print $1}') | + | then |
+ | MSG="Ethernet Ports bad speed" | ||
+ | EXITSTATUS=1 #Exit status Warning | ||
+ | fi | ||
- | if [ $nb_speed != "1" ] | + | # check LACP |
- | then | + | count_all=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep "Synchronization" | wc -l | awk '{print $1}') |
- | MSG="Ethernet Ports bad speed" | + | count_up=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep "Synchronization" | grep 'IN_SYNC' | wc -l | awk '{print $1}') |
- | EXITSTATUS=1 #Exit status Warning | + | echo "count_all=$count_all count_up=$count_up" >> /tmp/aaa |
- | fi | + | if [ $count_up -ne $count_all ] |
- | + | then | |
- | # check LACP | + | MSG="LACP not synced" |
- | count_all=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep "Synchronization" | wc -l | awk '{print $1}') | + | EXITSTATUS=1 #Exit status Warning |
- | count_up=$(sudo /usr/bin/entstat -d $ent 2>&1 | grep "Synchronization" | grep 'IN_SYNC' | wc -l | awk '{print $1}') | + | fi |
- | echo "count_all=$count_all count_up=$count_up" >> /tmp/aaa | + | done |
- | if [ $count_up -ne $count_all ] | + | fi |
- | then | + | |
- | MSG="LACP not synced" | + | |
- | EXITSTATUS=1 #Exit status Warning | + | |
- | fi | + | |
- | done | + | |
echo $MSG | echo $MSG |