Solved

Linux Script

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

895 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

20 Experts available now in Live!

Get 1:1 Help Now