Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need help writing custom script for Linux admin task

Posted on 2009-06-30
1
Medium Priority
?
295 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 2000 total points
ID: 24757765
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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.…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

926 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