echo ""; echo "Server Status One-liner"; echo ""; echo "Storage: "; df -h | sed -n '2,2p' | awk '{print "Disk:",$3"/"$2,$5}'; df -i | sed -n '2,2p' | awk '{print "Inodes:",$3"/"$2,$5}'; echo ""; echo "Load Average: "; cat /proc/loadavg; echo -ne "Thread Count: "; cat /proc/cpuinfo | grep processor | wc -l; echo ""; echo "Usage: "; mpstat | tail -2; echo ""; echo "Memory: "; free -m; echo ""; echo "Vmstat: "; vmstat; echo ""; echo "Services: ";ps cax | grep mysqld > /dev/null; if [ $? -eq 0 ]; then echo "mysql is running"; else echo "mysql is not running"; fi; ps cax | grep httpd > /dev/null; if [ $? -eq 0 ]; then echo "httpd is running"; else echo "httpd is not running"; fi; ps cax | grep exim > /dev/null; if [ $? -eq 0 ]; then echo "exim is running"; else echo "exim is not running"; fi; ps cax | grep named > /dev/null; if [ $? -eq 0 ]; then echo "named is running"; else echo "named is not running(Are they root?)"; fi; ps cax | grep pure-ftpd > /dev/null; if [ $? -eq 0 ]; then echo "ftpd is running"; else echo "ftpd is not running"; fi; ps cax | grep courier > /dev/null; if [ $? -eq 0 ]; then echo "courier is running"; else echo "courier is not running"; fi; netstat -tunap | grep -v 0.0.0.0 | awk '/.*[0-9]+.[0-9]+.[0-9]+.[0-9].*/{gsub(/::ffff:/,"",$0);print $4"\t" $5 "\t" $6"\t" $7}' | awk -F"/" '{print $1"\t"$2}' > netstat.log; echo ""; echo "Connections:";echo "Number of connections to each port:";cat netstat.log | awk {'print $1'} | cut -d: -f 2 | sort | uniq -c | sort -nk 1;echo;echo "Number of connections from each IP:";cat netstat.log | awk {'print $2'} | cut -d: -f 1 | sort | uniq -c | sort -nk 1;echo;echo "Number of instances of a particular IP connecting to particular port with connection states:";cat netstat.log | awk -F":" {'print $2 "\t" $3'} | awk {'print $1 "\t" $2 "\t" $4 "\t" $6'} | sort | uniq -c | sort -nk 1;echo;echo "SYN_RECV connections:";cat netstat.log | awk -F":" {'print $2 "\t" $3'} | awk {'print $1 "\t" $2 "\t" $4 "\t" $6'} | sort | uniq -c | sort -nk 1 | grep SYN_RECV; echo "Most CPU Intensive:"; ps auxf | sort -nr -k 3 | head -2;echo; echo "Most Memory Intensive:"; ps auxf | sort -nr -k 4 | head -2;
Sample Output:
Server Status One-liner
Storage:
df: ‘/root/.gvfs’: Permission denied
Disk: 57G/70G 86%
df: ‘/root/.gvfs’: Permission denied
Inodes: 1019615/4644864 22%
Load Average:
0.72 0.44 0.35 1/1184 8286
Thread Count: 4
Usage:
The program 'mpstat' is currently not installed. You can install it by typing:
sudo apt-get install sysstat
Memory:
total used free shared buffers cached
Mem: 7871 7673 197 950 45 1360
-/+ buffers/cache: 6268 1602
Swap: 6991 386 6605
Vmstat:
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 396204 202088 46168 1393032 0 2 42 76 66 66 25 6 69 0 0
Services:
mysql is running
httpd is not running
exim is not running
named is not running(Are they root?)
ftpd is not running
courier is not running
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Connections:
Number of connections to each port:
1 33306
1 33307
1 34253
1 34254
1 34535
1 35586
1 36520
1 36521
1 36522
1 36523
1 36524
1 36525
1 36526
1 38223
1 39106
1 39108
1 39272
1 39343
1 40549
1 41492
1 41652
1 41839
1 41844
1 41968
1 42078
1 42633
1 42634
1 42635
1 42636
1 42637
1 42638
1 43153
1 43967
1 44350
1 45159
1 47356
1 47357
1 47358
1 47361
1 47362
1 47363
1 47364
1 47365
1 47366
1 47367
1 47613
1 47909
1 48820
1 48821
1 48863
1 48934
1 49216
1 50291
1 50929
1 50930
1 51830
1 51852
1 52456
1 52768
1 52769
1 52775
1 52780
1 53433
1 53814
1 53815
1 53816
1 54277
1 55059
1 56293
1 56334
1 56911
1 56912
1 58636
1 58693
1 59312
1 59482
1 59952
1 59957
1 59975
1 60823
1 8005
2
Number of connections from each IP:
1 104.34.103.43
1 111.221.77.142
1 111.254.2.21
1 122.54.231.245
1 124.106.174.155
1 124.106.174.83
1 127.0.0.1
1 157.56.53.50
1 162.213.33.243
1 173.194.117.195
1 173.194.126.199
1 173.194.203.109
1 173.194.33.136
1 192.241.166.202
1 192.30.252.127
1 192.30.252.86
1 192.30.252.90
1 192.30.252.91
1 216.58.221.35
1 218.250.208.11
1 31.13.95.12
1 31.13.95.8
1 52.21.23.108
1 52.21.5.92
1 52.21.72.118
1 52.23.182.232
1 52.6.231.171
1 54.173.116.85
1 61.83.156.71
1 64.4.46.89
1 72.29.166.157
1 84.240.3.129
1 91.189.94.25
2 107.23.245.169
2 124.106.174.104
2 124.106.174.161
2 124.106.175.129
2 128.121.22.133
2 185.11.124.4
2 74.125.25.108
3
3 124.106.175.56
3 216.58.220.238
4 103.245.222.133
6 23.201.102.90
7 74.125.28.16
10 173.194.203.16
Number of instances of a particular IP connecting to particular port with connection states:
1 33306 128.121.22.133 ESTABLISHED chrome
1 33307 128.121.22.133 ESTABLISHED chrome
1 34253 124.106.175.129 ESTABLISHED chrome
1 34254 124.106.175.129 ESTABLISHED chrome
1 34535 192.30.252.90 ESTABLISHED chrome
1 35586 173.194.126.199 ESTABLISHED chrome
1 36520 74.125.28.16 ESTABLISHED thunderbird
1 36521 74.125.28.16 ESTABLISHED thunderbird
1 36522 74.125.28.16 ESTABLISHED thunderbird
1 36523 74.125.28.16 ESTABLISHED thunderbird
1 36524 74.125.28.16 ESTABLISHED thunderbird
1 36525 74.125.28.16 ESTABLISHED thunderbird
1 36526 74.125.28.16 ESTABLISHED thunderbird
1 38223 127.0.0.1 ESTABLISHED
1 39106 107.23.245.169 ESTABLISHED chrome
1 39108 107.23.245.169 TIME_WAIT
1 39272 72.29.166.157 CLOSE_WAIT gvfsd-http
1 39343 104.34.103.43 ESTABLISHED skype
1 40549 124.106.174.83 ESTABLISHED chrome
1 41492 54.173.116.85 ESTABLISHED chrome
1 41652 216.58.221.35 ESTABLISHED chrome
1 41839 74.125.25.108 ESTABLISHED thunderbird
1 41844 74.125.25.108 ESTABLISHED thunderbird
1 41968 122.54.231.245 ESTABLISHED chrome
1 42078 91.189.94.25 CLOSE_WAIT ubuntu-geoip-
1 42633 23.201.102.90 ESTABLISHED chrome
1 42634 23.201.102.90 ESTABLISHED chrome
1 42635 23.201.102.90 ESTABLISHED chrome
1 42636 23.201.102.90 ESTABLISHED chrome
1 42637 23.201.102.90 ESTABLISHED chrome
1 42638 23.201.102.90 ESTABLISHED chrome
1 43153 31.13.95.12 ESTABLISHED chrome
1 43967 61.83.156.71 ESTABLISHED skype
1 44350 64.4.46.89 ESTABLISHED skype
1 45159 84.240.3.129 ESTABLISHED xchat
1 47356 173.194.203.16 ESTABLISHED thunderbird
1 47357 173.194.203.16 ESTABLISHED thunderbird
1 47358 173.194.203.16 ESTABLISHED thunderbird
1 47361 173.194.203.16 ESTABLISHED thunderbird
1 47362 173.194.203.16 ESTABLISHED thunderbird
1 47363 173.194.203.16 ESTABLISHED thunderbird
1 47364 173.194.203.16 ESTABLISHED thunderbird
1 47365 173.194.203.16 ESTABLISHED thunderbird
1 47366 173.194.203.16 ESTABLISHED thunderbird
1 47367 173.194.203.16 ESTABLISHED thunderbird
1 47613 31.13.95.8 ESTABLISHED chrome
1 47909 111.254.2.21 ESTABLISHED skype
1 48820 185.11.124.4 ESTABLISHED chrome
1 48821 185.11.124.4 ESTABLISHED chrome
1 48863 52.23.182.232 ESTABLISHED chrome
1 48934 173.194.33.136 ESTABLISHED chrome
1 49216 111.221.77.142 ESTABLISHED skype
1 50291 173.194.117.195 ESTABLISHED chrome
1 50929 124.106.174.104 ESTABLISHED chrome
1 50930 124.106.174.104 ESTABLISHED chrome
1 51830 157.56.53.50 ESTABLISHED skype
1 51852 52.6.231.171 ESTABLISHED chrome
1 52456 218.250.208.11 ESTABLISHED skype
1 52768 103.245.222.133 CLOSE_WAIT chrome
1 52769 103.245.222.133 CLOSE_WAIT chrome
1 52775 103.245.222.133 ESTABLISHED chrome
1 52780 103.245.222.133 ESTABLISHED chrome
1 53433 52.21.72.118 ESTABLISHED chrome
1 53814 124.106.175.56 ESTABLISHED chrome
1 53815 124.106.175.56 ESTABLISHED chrome
1 53816 124.106.175.56 ESTABLISHED chrome
1 54277 192.30.252.91 ESTABLISHED chrome
1 55059 192.30.252.86 ESTABLISHED chrome
1 56293 192.30.252.127 TIME_WAIT
1 56334 173.194.203.109 ESTABLISHED thunderbird
1 56911 124.106.174.161 ESTABLISHED chrome
1 56912 124.106.174.161 ESTABLISHED chrome
1 58636 52.21.5.92 ESTABLISHED chrome
1 58693 162.213.33.243 ESTABLISHED python
1 59312 124.106.174.155 ESTABLISHED chrome
1 59482 52.21.23.108 ESTABLISHED chrome
1 59952 216.58.220.238 ESTABLISHED chrome
1 59957 216.58.220.238 ESTABLISHED chrome
1 59975 216.58.220.238 ESTABLISHED chrome
1 60823 192.241.166.202 ESTABLISHED chrome
1 8005
2 1
SYN_RECV connections:
Most CPU Intensive:
gerald 8100 10.8 2.9 1037620 240196 ? Sl 15:48 0:56 | | \_ /opt/google/chrome/chrome --type=renderer --lang=en-US --force-fieldtrials=AffiliationBasedMatching/Enabled/AppBannerTriggering/Aggressive/AudioProcessing48kHzSupport/Default/*AutofillClassifier/Default/CaptivePortalInterstitial/Enabled/ChildAccountDetection/Disabled/ChromeDashboard/Default/ChromotingQUIC/Disabled/*ClientSideDetectionModel/Model0/DataReductionProxyUseDataSaverOnVPN/Control/*DomRel-Enable/enable/*EnableSessionCrashedBubbleUI/Enabled/*EnhancedBookmarks/Default/*ExtensionContentVerification/Enforce/*ExtensionDeveloperModeWarning/Default/*ExtensionInstallVerification/None/*IconNTP/Default/InstanceID/Enabled/*NewProfileManagement/Enabled/*NewVideoRendererTrial/Enabled/*OmniboxBundledExperimentV1/Unused_2/*PasswordGeneration/Disabled/PasswordLinkInSettings/Enabled/*PluginPowerSaver/Enabled/*PrerenderFromOmnibox/OmniboxPrerenderEnabled/*QUIC/Enabled1ConCubic/RefreshTokenDeviceId/Enabled/ReportCertificateErrors/ShowAndPossiblySend/SHA1IdentityUIWarning/Enabled/SHA1ToolbarUIJanuary2016/Warning/SHA1ToolbarUIJanuary2017/Error/*SafeBrowsingIncidentReportingService/Default/SafeBrowsingReportPhishingErrorLink/Disabled/SafeBrowsingSocialEngineeringStrings/Disabled/*SdchPersistence/Enabled/SessionRestoreBackgroundLoading/Restore/*SlimmingPaint/EnableSlimmingPaint/SyncBackingDatabase32K/Enabled/*UMA-Dynamic-Binary-Uniformity-Trial/default/*UMA-Population-Restrict/normal/*UMA-Uniformity-Trial-100-Percent/group_01/*UMA-Uniformity-Trial-20-Percent/group_03/*UMA-Uniformity-Trial-50-Percent/default/*UseDelayAgnosticAEC/DefaultEnabled/*VarationsServiceControl/Default/VoiceTrigger/Install/ --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-delegated-renderer --num-raster-threads=2 --content-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --video-image-texture-target=3553 --disable-accelerated-video-decode --disable-webrtc-hw-encoding --disable-gpu-compositing --channel=3730.621.798343073 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd
gerald 3730 6.4 4.3 2052136 346968 ? SLl Oct17 396:07 \_ /opt/google/chrome/chrome
Most Memory Intensive:
gerald 9269 1.3 5.0 1873740 410252 ? Sl Oct17 69:47 \_ /usr/lib/thunderbird/thunderbird
gerald 3730 6.4 4.3 2052136 346968 ? SLl Oct17 396:07 \_ /opt/google/chrome/chrome