Solved

Need help writing custom script for Linux admin task

Posted on 2009-06-30
1
289 Views
Last Modified: 2012-05-07
I'm spending a lot of time manually reporting basic Linux system stats that I get from either Cacti monitoring tool and/or Top and ps command.  I'm essentially writing a report in following format below.

I'm pretty sure this could be done in Shell scripting and Cron job, not sure if it would be easier as a Perl script.  Either way I'm open to learning the most efficient and simplest solution for the above admin task.  
Host: <name value>
 

CPU Util: <value> (if Idle % is 100 - 60% print "Good" ; if Idle % is 60 - 30% print "Fair"; if Idle % is 30 - 0% print "Bad")
 

Memory Util: <value> (if Free Mem % is 100 - 60% print "Good" ; if Free Mem % is 60 - 30% print "Fair"; if Free Mem % is 30 - 0% print "Bad")
 

Up since: (check date PID was started;  calculate number of days/hours PID has been runninig; print value)
 

Email Frequency: Select (every 60 mins | every 24 hours )

Format HTML 

Send email to recipients

End.

Open in new window

0
Comment
Question by:gmahler5th
1 Comment
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
Comment Utility
echo ''
echo Host: `uname -n` '< br>'
echo CPU/Memory Util: '< br>
'
top -b -n 1|head -6|tail -4
echo '

Open in new window

< br>'
echo Up since: `w|awk '(NR==1){print $3" "$4}'` '< br>'
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

728 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

10 Experts available now in Live!

Get 1:1 Help Now