Solved

Linux Script

Posted on 2013-11-14
2
494 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

803 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