Solved

Linux Script

Posted on 2013-11-14
2
498 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

705 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