Skip to content

Commit

Permalink
First Comit 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
GitWatin committed Dec 27, 2020
1 parent 272387e commit 54c3e40
Showing 1 changed file with 126 additions and 0 deletions.
126 changes: 126 additions & 0 deletions LinuxSystemHealth
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#! /bin/bash

#################################################################
#
# Title : LinuxSystemHealth
#
# Description : Display system information at logon
#
# Author : Valentin Denis
#
# Creation date : 08-10-2019
#
# Last modified : 27-12-2020
#
# Version : 2.0
#
################################################################

### Required packages
## Centos : chronyd


# Basic info
HOSTNAME=`uname -n`
SLASH=" / "

## RAM Information
MEMORY_TOTAL=`free -t -m | grep "Mem" | awk '{print $2" MB";}'`
SWAP_USE=$(free -m | tail -n 1 | awk '{print $3}')
SWAP_TOTAL=$(free -m | tail -n 1 | awk '{print $4}')

## Disk Information
# For root
ROOT_USE=$(df -Ph / | grep /dev | awk '{print $3}')$SLASH
ROOT_TOTAL=$(df -Ph / | grep /dev | awk '{print $2}')

# For / share if exist
if [ -d "/wikijs" ];then
SHARE_USE=$(df -Ph /wikijs | grep /dev | awk '{print $3}')$SLASH
SHARE_TOTAL=$(df -Ph /wikijs | grep /dev | awk '{print $2}')
else
SHARE_USE=$(echo "/share not found")
fi

### Different variable for Centos/Debian/Ubuntu

if [ -f "/etc/redhat-release" ];then
# For CentOS

#Memory information
MEMORY_USE=`free -t -m | grep Total | awk '{print $3" MB";}'`
SYSTEM=$(cat /etc/redhat-release)
IP=$(ip addr show eth0 | grep -Po 'inet \K[\d.]+')
elif [ -f "/etc/issue" ];then
# For Debian
#Memory information
MEMORY_USE=`free -t -m | grep buffers/cache: | awk '{print $3" MB";}'`
SYSTEM=$(cat /etc/issue)
IP=$(ifconfig eth0 | grep "inet ad" | cut -f2 -d: | awk '{print $1}')
elif [ -f "/etc/lsb-release" ];then
# For Ubuntu

#Memory information
MEMORY_USE=`free -t -m | grep buffers/cache: | awk '{print $3" MB";}'`
SYSTEM=$(cat /etc/lsb-release)
else
#For Another
SYSTEM=$(echo 'Not Detected')
fi

## LOAD Informations
#LOAD 1 Minute
LOAD1=`cat /proc/loadavg | awk {'print $1'}`
#LOAD 5 Minutes
LOAD2=`cat /proc/loadavg | awk {'print $2'}`
#LOAD 15 Minutes
LOAD3=`cat /proc/loadavg | awk {'print $3'}`

## CPU Informations
CPU_PERCENT=$(vmstat 1 2|tail -1 | awk '{print $13}')
CPU_CORE=$(cat /proc/cpuinfo | grep -i "^processor" | wc -l)

## Check SSH Service
SSH_STATUS=`systemctl is-active sshd`

#### Check Services

## Check SNMP Service
SNMP_STATUS=`systemctl is-active snmpd`

## Check FTP Service
FTP_STATUS=`systemctl is-active vsftpd`

## Check SAMBA Service
SAMBA_STATUS=`systemctl is-active smbd`

## Check NTP Service
NTP_STATUS=`systemctl is-active chronyd`
NTP_SYNC_TEMP=$(timedatectl |grep 'NTP synchronized:')
NTP_SYNC=${NTP_SYNC_TEMP:18}




echo "
===============================================================
- Hostname....................: $HOSTNAME
- System......................: $SYSTEM
- /Share......................: $SHARE_USE$SHARE_TOTAL
- /...........................: $ROOT_USE$ROOT_TOTAL
- IP..........................: $IP
===============================================================
- CPU usage...................: $CPU_PERCENT %
- CPU Cores...................: $CPU_CORE
- Load........................: $LOAD1 - $LOAD2 - $LOAD3
- Memory used.................: $MEMORY_USE / $MEMORY_TOTAL
- Swap in use.................: $SWAP_USE MB / $SWAP_TOTAL MB
===============================================================
- SSH.........................: $SSH_STATUS
- Samba.......................: $SAMBA_STATUS
- Chronyd (NTP)...............: $NTP_STATUS
- NTP Synchronized.......: $NTP_SYNC
- SNMP........................: $SNMP_STATUS
- FTP.........................: $FTP_STATUS
===============================================================
"

0 comments on commit 54c3e40

Please sign in to comment.