Solved

Linux Script

Posted on 2013-11-14
2
492 Views
Last Modified: 2013-12-05
Hello,

Can I get a linux Red Hat script to monitor resources such as:
- top consuming resources
- memory and swap usage
- CPU utilization
- disk space usage
- network monitoring
I would like the output written to a file every hour. Basically this would be a snapshot of the server and some help with the formatting to make it better to read would be apreaciated.

Thanks.
0
Comment
Question by:redkasote
2 Comments
 
LVL 34

Accepted Solution

by:
Seth Simmons earned 250 total points
ID: 39649744
#!/bin/bash
date +"%m-%d-%y %H%M" >> foo.txt
top -abcn 1 >> foo.txt
free -m >> foo.txt
iostat -cd 1 2 >> foo.txt
vmstat -tw 1 2 >> foo.txt
df -h >> foo.txt
ifconfig eth0 >> foo.txt

Open in new window


this will provide a few different things

the first line will echo the current date and time to the file

top will show output of processes; in this case sorted by memory usage (RES column)

free will show free physical memory, swap usage, buffers and file cache

iostat will show some disk statistics; vmstat will show memory/cpu statistics

note that both iostat and vmstat by default will show totals since last reboot on the first output which is why the command has a 2 indicating it will run twice; first total since reboot and second current statistics

df will show free space and ifconfig will show the output of the network interface (change to what interface you want or just the command itself for all interfaces).  not sure what exactly you're looking for with this but it will show packet statistics.

to run hourly just add this in crontab
* */1 * * * foo.sh

also, if you get command not found for iostat and vmstat, they are both part of sysstat package so you can install that if it isn't already
0
 
LVL 6

Assisted Solution

by:xeroxzerox
xeroxzerox earned 250 total points
ID: 39655509
best option is to use & configure SSMTP.. it gives you all status of system..it also support & send mail to admin for status attachment..
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now