?
Solved

Linux Script

Posted on 2013-11-14
2
Medium Priority
?
499 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 750 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 750 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

762 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