Example:
Jump server : [root@inddcpjmp01 solaris]# ./solaris_health_check.sh indsuntst01
1. Remote Health Check Script (solaris_health_check.sh)
[root@inddcpjmp01 solaris]# cat solaris_health_check.sh
#!/bin/bash
# ===================================================================
# Solaris Health Check Script (Formatted Log Version)
# Author: Tasleem Ahmed Khan
# Version: 1.0
# ===================================================================
# Usage: ./solaris_health_check.sh <server1> [server2] [server3] ...
# Description: Performs complete health check of Solaris servers
# and writes clean, structured log files.
# ===================================================================
if [ $# -lt 1 ]; then
echo "Usage: $0 <server1> [server2] [server3] ..."
exit 1
fi
timestamp=$(date +'%Y%m%d_%H%M%S')
log_dir="health_logs"
mkdir -p "$log_dir"
# ===================================================================
# Function: perform_health_check
# ===================================================================
perform_health_check() {
local server=$1
local logfile="${log_dir}/${server}_health_${timestamp}.log"
echo "=============================================================" | tee "$logfile"
echo " SOLARIS HEALTH CHECK REPORT" | tee -a "$logfile"
echo "=============================================================" | tee -a "$logfile"
echo " Server Name : $server" | tee -a "$logfile"
echo " Date & Time : $(date)" | tee -a "$logfile"
echo " Log File : $logfile" | tee -a "$logfile"
echo "=============================================================" | tee -a "$logfile"
ssh -o ConnectTimeout=10 "$server" bash <<'EOF' >> "$logfile" 2>&1
echo
echo "==================== SYSTEM INFORMATION ===================="
hostname=$(hostname)
os_version=$(cat /etc/release | head -1)
platform=$(uname -i)
kernel=$(uname -r)
arch=$(uname -p)
uptime_info=$(uptime | sed 's/^[ \t]*//')
echo "Hostname : $hostname"
echo "OS Version : $os_version"
echo "Platform : $platform"
echo "Kernel Version : $kernel"
echo "Architecture : $arch"
echo "Uptime : $uptime_info"
echo
# ------------------- CPU INFO -------------------
echo "==================== CPU INFORMATION ======================="
total_cpu=$(psrinfo | wc -l)
mpstat_out=$(mpstat 1 2 | tail -1)
idle_cpu=$(echo "$mpstat_out" | awk '{print $NF}')
used_cpu=$(echo "scale=2; 100 - $idle_cpu" | bc)
echo "Total CPU Cores : $total_cpu"
echo "CPU Used (%) : $used_cpu"
echo "CPU Free (%) : $idle_cpu"
echo "CPU Model Info :"
psrinfo -pv | sed 's/^/ /'
echo
# ------------------- MEMORY INFO -------------------
echo "==================== MEMORY INFORMATION ===================="
total_mem=$(prtconf | grep "Memory size" | awk '{print $3}')
mem_line=$(vmstat 1 2 | tail -1)
free_pages=$(echo "$mem_line" | awk '{print $5}')
pagesize=$(pagesize)
free_mem=$(echo "$free_pages * $pagesize / 1024 / 1024" | bc)
used_mem=$(echo "$total_mem - $free_mem" | bc)
echo "Total Memory (MB): $total_mem"
echo "Used Memory (MB) : $used_mem"
echo "Free Memory (MB) : $free_mem"
echo
# ------------------- DISK INFO -------------------
echo "==================== DISK INFORMATION ======================"
total_disk=$(df -k | awk 'NR>1 {sum+=$2} END {print sum/1024/1024}')
used_disk=$(df -k | awk 'NR>1 {sum+=$3} END {print sum/1024/1024}')
free_disk=$(df -k | awk 'NR>1 {sum+=$4} END {print sum/1024/1024}')
echo "Total Disk (GB): $total_disk"
echo "Used Disk (GB) : $used_disk"
echo "Free Disk (GB) : $free_disk"
echo
echo "--- Disk Usage Details ---"
df -h | awk '{printf " %-35s %-10s %-10s %-10s %-10s\n", $1,$2,$3,$4,$5}'
echo
# ------------------- LOAD & PROCESSES -------------------
echo "==================== SERVER LOAD & PROCESSES ==============="
load_avg=$(uptime | awk -F'load average: ' '{print $2}')
process_count=$(ps -ef | wc -l)
echo "Load Average : $load_avg"
echo "Running Processes : $process_count"
echo
echo "--- Top 10 CPU-Consuming Processes ---"
ps -eo pid,ppid,comm,vsz,pcpu | sort -k 4 -r | head -n 11
echo
echo "--- Top 10 Memory-Consuming Processes ---"
ps -eo pid,ppid,comm,pmem,pcpu | sort -r -n -k5 | head -n 11
echo
# ------------------- NETWORK INFO -------------------
echo "==================== NETWORK INFORMATION =================="
echo "--- Interface & IP Details ---"
ifconfig -a
echo
echo "--- Routing Table ---"
netstat -rn
echo
echo "--- Open Ports ---"
netstat -an | grep LISTEN | awk '{print $1, $4, $6}'
echo
echo "--- Active TCP Connections (Top 15) ---"
netstat -an | grep ESTABLISHED | head -n 15
echo
# ------------------- FILESYSTEM / ZFS -------------------
echo "==================== FILESYSTEM / ZFS STATUS ==============="
if command -v zpool >/dev/null 2>&1; then
echo "--- ZFS Pool Summary ---"
zpool list
echo
echo "--- ZFS Detailed Status ---"
zpool status
else
echo "ZFS not installed or not available."
fi
echo
# ------------------- SERVICES & HARDWARE -------------------
echo "==================== SERVICES & HARDWARE =================="
echo "--- SMF Services Status ---"
svcs -xv
echo
echo "--- Hardware Diagnostics ---"
if command -v prtdiag >/dev/null 2>&1; then
prtdiag -v
else
echo "prtdiag not available."
fi
echo
echo "--- Failed Services (if any) ---"
svcs -xv | grep -i "maintenance"
echo
EOF
echo
echo "Health check completed for $server"
echo "Log saved at: $logfile"
echo "-------------------------------------------------------------"
}
# ===================================================================
# Main Loop
# ===================================================================
for server in "$@"; do
echo "Running health check on $server..."
perform_health_check "$server"
done
echo
echo "============================================================="
echo "All health checks completed. Logs saved under: $log_dir"
echo "============================================================="
[root@inddcpjmp01 solaris]#
[root@inddcpjmp01 solaris]# ./solaris_health_check.sh indsuntst01
Running health check on indsuntst01...
=============================================================
SOLARIS HEALTH CHECK REPORT
=============================================================
Server Name : indsuntst01
Date & Time : Sunday 26 October 2025 01:15:10 PM IST
Log File : health_logs/indsuntst01_health_20251026_131510.log
=============================================================
Health check completed for indsuntst01
Log saved at: health_logs/indsuntst01_health_20251026_131510.log
-------------------------------------------------------------
=============================================================
All health checks completed. Logs saved under: health_logs
=============================================================
[root@inddcpjmp01 solaris]#
More details output:
More details output:
[root@inddcpjmp01 solaris]# cat health_logs/indsuntst01_health_20251026_131510.log
=============================================================
SOLARIS HEALTH CHECK REPORT
=============================================================
Server Name : indsuntst01
Date & Time : Sunday 26 October 2025 01:15:10 PM IST
Log File : health_logs/indsuntst01_health_20251026_131510.log
=============================================================
==================== SYSTEM INFORMATION ====================
Hostname : indsuntst01
OS Version : Oracle Solaris 11.4 X86
Platform : i86pc
Kernel Version : 5.11
Architecture : i386
Uptime : 6:45pm up 37 min(s), 1 user, load average: 0.00, 0.00, 0.01
==================== CPU INFORMATION =======================
Total CPU Cores : 2
CPU Used (%) : 0
CPU Free (%) : 100
CPU Model Info :
The physical processor has 2 virtual processors (0-1)
x86 (AuthenticAMD 870F10 family 23 model 113 step 0 clock 3593 MHz)
AMD Ryzen 7 3700X 8-Core Processor
==================== MEMORY INFORMATION ====================
Total Memory (MB): 4096
Used Memory (MB) : -6293
Free Memory (MB) : 10389
==================== DISK INFORMATION ======================
Total Disk (GB): 254.553
Used Disk (GB) : 5.51858
Free Disk (GB) : 178.873
--- Disk Usage Details ---
Filesystem Size Used Available Capacity
rpool/ROOT/solaris 19G 2.7G 13G 17%
rpool/ROOT/solaris/var 19G 181M 13G 2%
/devices 0K 0K 0K 0%
/dev 0K 0K 0K 0%
ctfs 0K 0K 0K 0%
proc 0K 0K 0K 0%
mnttab 0K 0K 0K 0%
swap 3.4G 6.5M 3.4G 1%
swap 3.4G 4K 3.4G 1%
objfs 0K 0K 0K 0%
sharefs 0K 0K 0K 0%
fd 0K 0K 0K 0%
/usr/lib/libc/libc_hwcap2.so.1 16G 2.7G 13G 17%
rpool/VARSHARE 19G 2.8M 13G 1%
rpool/VARSHARE/tmp 19G 31K 13G 1%
rpool/VARSHARE/kvol 19G 31K 13G 1%
rpool/VARSHARE/zones 19G 31K 13G 1%
rpool/export 19G 32K 13G 1%
rpool/export/home 19G 37K 13G 1%
rpool 19G 4.3M 13G 1%
rpool/VARSHARE/pkg 19G 32K 13G 1%
rpool/VARSHARE/pkg/repositories 19G 31K 13G 1%
rpool/VARSHARE/sstore 19G 2.9M 13G 1%
==================== SERVER LOAD & PROCESSES ===============
Load Average : oad average: 0.00, 0.00, 0.01
Running Processes : 80
--- Top 10 CPU-Consuming Processes ---
831 1 /usr/lib/devchassis/devchassisd 4492 0.0
784 762 /usr/lib/hal/hald-addon-storage 4252 0.0
867 861 /usr/apache2/2.4/bin/rotatelogs 3752 0.0
863 861 /usr/apache2/2.4/bin/rotatelogs 3752 0.0
1051 1 /usr/lib/fm/notify/smtp-notify 12316 0.0
1048 1 /usr/lib/fm/notify/asr-notify 12380 0.0
773 762 /usr/lib/hal/hald-addon-acpi 5804 0.0
1044 1 /usr/lib/sstore/bin/sysstatd 27544 0.0
812 1 /usr/lib/sstore/bin/sstored 195660 0.1
313 1 /usr/lib/devfsadm/devfsadmd 15172 0.0
279 1 /usr/lib/sysevent/syseventd 11532 0.0
--- Top 10 Memory-Consuming Processes ---
1656 1653 bash 0.1 0.1
1653 627 /usr/lib/ssh/sshd 0.2 0.1
812 1 /usr/lib/sstore/bin/sstored 4.3 0.1
1723 1656 head 0.0 0.0
1722 1656 sort 0.1 0.0
1721 1656 ps 0.1 0.0
1460 1457 -bash 0.1 0.0
1457 627 /usr/lib/ssh/sshd 0.2 0.0
1118 1 /usr/lib/inet/sendmail 0.1 0.0
1115 1 /usr/lib/inet/sendmail 0.1 0.0
1095 1 /usr/sbin/dhcpagent 0.2 0.0
==================== NETWORK INFORMATION ==================
--- Interface & IP Details ---
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
net0: flags=100001000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,PHYSRUNNING> mtu 1500 index 2
inet 192.168.10.245 netmask ffffff00 broadcast 192.168.10.255
ether 0:c:29:b0:45:66
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 ::1/128
net0: flags=120002004841<UP,RUNNING,MULTICAST,DHCP,IPv6,PHYSRUNNING> mtu 1500 index 2
inet6 fe80::20c:29ff:feb0:4566/10
ether 0:c:29:b0:45:66
--- Routing Table ---
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ---------- ---------
default 192.168.10.1 UG 1 0
127.0.0.1 127.0.0.1 UH 2 58 lo0
192.168.10.0 192.168.10.245 U 6 1059 net0
Routing Table: IPv6
Destination/Mask Gateway Flags Ref Use If
--------------------------- --------------------------- ----- --- ------- -----
::1 ::1 UH 2 14 lo0
fe80::/10 fe80::20c:29ff:feb0:4566 U 2 0 net0
--- Open Ports ---
127.0.0.1.5999 0 0
*.22 0 0
127.0.0.1.631 0 0
*.111 0 0
*.111 0 0
*.515 0 0
*.6787 0 0
127.0.0.1.4999 0 0
127.0.0.1.25 0 0
127.0.0.1.587 0 0
::1.5999 0 0
*.22 0 0
::1.631 0 0
*.111 0 0
*.515 0 0
*.6787 0 0
::1.25 0 0
--- Active TCP Connections (Top 15) ---
192.168.10.245.22 192.168.10.105.51866 63488 0 256296 0 ESTABLISHED
192.168.10.245.22 192.168.10.105.35844 84480 0 256296 0 ESTABLISHED
==================== FILESYSTEM / ZFS STATUS ===============
--- ZFS Pool Summary ---
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
rpool 19.6G 6.08G 13.5G 30% 1.00x ONLINE -
--- ZFS Detailed Status ---
pool: rpool
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
c2t0d0 ONLINE 0 0 0
errors: No known data errors
==================== SERVICES & HARDWARE ==================
--- SMF Services Status ---
svc:/network/ntp:default (Network Time Protocol (NTP) Version 4)
State: maintenance since Sun Oct 26 18:08:38 2025
Reason: Start method exited with $SMF_EXIT_ERR_CONFIG.
See: http://support.oracle.com/msg/SMF-8000-KS
See: man -M /usr/share/man -s 4 ntp.conf
See: man -M /usr/share/man -s 8 ntpd
See: man -M /usr/share/man -s 8 ntpq
See: /var/svc/log/network-ntp:default.log
Impact: This service is not running.
--- Hardware Diagnostics ---
System Configuration: VMware, Inc. VMware Virtual Platform
BIOS Configuration: Phoenix Technologies LTD 6.00 11/12/2020
==== Processor Sockets ====================================
Version Location Tag
-------------------------------- --------------------------
AMD Ryzen 7 3700X 8-Core Processor CPU #001
AMD Ryzen 7 3700X 8-Core Processor CPU #001
==== Memory Device Sockets ================================
Type Status Set Device Locator Bank Locator
----------- ------ --- ------------------- ----------------
DRAM in use 0 RAM slot #0 RAM slot #0
DRAM empty 0 RAM slot #1 RAM slot #1
DRAM empty 0 RAM slot #2 RAM slot #2
DRAM empty 0 RAM slot #3 RAM slot #3
DRAM empty 0 RAM slot #4 RAM slot #4
DRAM empty 0 RAM slot #5 RAM slot #5
DRAM empty 0 RAM slot #6 RAM slot #6
DRAM empty 0 RAM slot #7 RAM slot #7
DRAM empty 0 RAM slot #8 RAM slot #8
DRAM empty 0 RAM slot #9 RAM slot #9
DRAM empty 0 RAM slot #10 RAM slot #10
DRAM empty 0 RAM slot #11 RAM slot #11
DRAM empty 0 RAM slot #12 RAM slot #12
DRAM empty 0 RAM slot #13 RAM slot #13
DRAM empty 0 RAM slot #14 RAM slot #14
DRAM empty 0 RAM slot #15 RAM slot #15
DRAM empty 0 RAM slot #16 RAM slot #16
DRAM empty 0 RAM slot #17 RAM slot #17
DRAM empty 0 RAM slot #18 RAM slot #18
DRAM empty 0 RAM slot #19 RAM slot #19
DRAM empty 0 RAM slot #20 RAM slot #20
DRAM empty 0 RAM slot #21 RAM slot #21
DRAM empty 0 RAM slot #22 RAM slot #22
DRAM empty 0 RAM slot #23 RAM slot #23
DRAM empty 0 RAM slot #24 RAM slot #24
DRAM empty 0 RAM slot #25 RAM slot #25
DRAM empty 0 RAM slot #26 RAM slot #26
DRAM empty 0 RAM slot #27 RAM slot #27
DRAM empty 0 RAM slot #28 RAM slot #28
DRAM empty 0 RAM slot #29 RAM slot #29
DRAM empty 0 RAM slot #30 RAM slot #30
DRAM empty 0 RAM slot #31 RAM slot #31
DRAM empty 0 RAM slot #32 RAM slot #32
DRAM empty 0 RAM slot #33 RAM slot #33
DRAM empty 0 RAM slot #34 RAM slot #34
DRAM empty 0 RAM slot #35 RAM slot #35
DRAM empty 0 RAM slot #36 RAM slot #36
DRAM empty 0 RAM slot #37 RAM slot #37
DRAM empty 0 RAM slot #38 RAM slot #38
DRAM empty 0 RAM slot #39 RAM slot #39
DRAM empty 0 RAM slot #40 RAM slot #40
DRAM empty 0 RAM slot #41 RAM slot #41
DRAM empty 0 RAM slot #42 RAM slot #42
DRAM empty 0 RAM slot #43 RAM slot #43
DRAM empty 0 RAM slot #44 RAM slot #44
DRAM empty 0 RAM slot #45 RAM slot #45
DRAM empty 0 RAM slot #46 RAM slot #46
DRAM empty 0 RAM slot #47 RAM slot #47
DRAM empty 0 RAM slot #48 RAM slot #48
DRAM empty 0 RAM slot #49 RAM slot #49
DRAM empty 0 RAM slot #50 RAM slot #50
DRAM empty 0 RAM slot #51 RAM slot #51
DRAM empty 0 RAM slot #52 RAM slot #52
DRAM empty 0 RAM slot #53 RAM slot #53
DRAM empty 0 RAM slot #54 RAM slot #54
DRAM empty 0 RAM slot #55 RAM slot #55
DRAM empty 0 RAM slot #56 RAM slot #56
DRAM empty 0 RAM slot #57 RAM slot #57
DRAM empty 0 RAM slot #58 RAM slot #58
DRAM empty 0 RAM slot #59 RAM slot #59
DRAM empty 0 RAM slot #60 RAM slot #60
DRAM empty 0 RAM slot #61 RAM slot #61
DRAM empty 0 RAM slot #62 RAM slot #62
DRAM empty 0 RAM slot #63 RAM slot #63
other empty 0 NVD #0 NVD #0
other empty 0 NVD #1 NVD #1
other empty 0 NVD #2 NVD #2
other empty 0 NVD #3 NVD #3
other empty 0 NVD #4 NVD #4
other empty 0 NVD #5 NVD #5
other empty 0 NVD #6 NVD #6
other empty 0 NVD #7 NVD #7
other empty 0 NVD #8 NVD #8
other empty 0 NVD #9 NVD #9
other empty 0 NVD #10 NVD #10
other empty 0 NVD #11 NVD #11
other empty 0 NVD #12 NVD #12
other empty 0 NVD #13 NVD #13
other empty 0 NVD #14 NVD #14
other empty 0 NVD #15 NVD #15
other empty 0 NVD #16 NVD #16
other empty 0 NVD #17 NVD #17
other empty 0 NVD #18 NVD #18
other empty 0 NVD #19 NVD #19
other empty 0 NVD #20 NVD #20
other empty 0 NVD #21 NVD #21
other empty 0 NVD #22 NVD #22
other empty 0 NVD #23 NVD #23
other empty 0 NVD #24 NVD #24
other empty 0 NVD #25 NVD #25
other empty 0 NVD #26 NVD #26
other empty 0 NVD #27 NVD #27
other empty 0 NVD #28 NVD #28
other empty 0 NVD #29 NVD #29
other empty 0 NVD #30 NVD #30
other empty 0 NVD #31 NVD #31
other empty 0 NVD #32 NVD #32
other empty 0 NVD #33 NVD #33
other empty 0 NVD #34 NVD #34
other empty 0 NVD #35 NVD #35
other empty 0 NVD #36 NVD #36
other empty 0 NVD #37 NVD #37
other empty 0 NVD #38 NVD #38
other empty 0 NVD #39 NVD #39
other empty 0 NVD #40 NVD #40
other empty 0 NVD #41 NVD #41
other empty 0 NVD #42 NVD #42
other empty 0 NVD #43 NVD #43
other empty 0 NVD #44 NVD #44
other empty 0 NVD #45 NVD #45
other empty 0 NVD #46 NVD #46
other empty 0 NVD #47 NVD #47
other empty 0 NVD #48 NVD #48
other empty 0 NVD #49 NVD #49
other empty 0 NVD #50 NVD #50
other empty 0 NVD #51 NVD #51
other empty 0 NVD #52 NVD #52
other empty 0 NVD #53 NVD #53
other empty 0 NVD #54 NVD #54
other empty 0 NVD #55 NVD #55
other empty 0 NVD #56 NVD #56
other empty 0 NVD #57 NVD #57
other empty 0 NVD #58 NVD #58
other empty 0 NVD #59 NVD #59
other empty 0 NVD #60 NVD #60
other empty 0 NVD #61 NVD #61
other empty 0 NVD #62 NVD #62
other empty 0 NVD #63 NVD #63
==== On-Board Devices =====================================
VMware SVGA II
ES1371
==== Upgradeable Slots ====================================
ID Status Type Description
--- --------- ---------------- ----------------------------
0 unknown ISA ISA Slot J8
0 unknown ISA ISA Slot J9
0 unknown ISA ISA Slot J10
1 in use PCI PCI Slot J11
2 in use PCI PCI Slot J12
3 in use PCI PCI Slot J13
4 available PCI PCI Slot J14
--- Failed Services (if any) ---
State: maintenance since Sun Oct 26 18:08:38 2025
[root@inddcpjmp01 solaris]#
No comments:
Post a Comment