LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-14-2020, 06:52 PM   #1
r34per
LQ Newbie
 
Registered: Nov 2017
Posts: 11

Rep: Reputation: Disabled
Shell Scripting: RHEL server scan - Whatís my spec??


Hi All,

Iím not sure if this is the right section for this kind of thing so if itís not, I apologise!

I would like to develop a RHEL server scan script which when run will scan the server and produce a output file with the results. So the scan would include stuff like:
disks, pvís, vgís, lvís, cpu, ram, nicís, nfs setup, packages, services, config setup, users, groups, etc
Basically a all in one snapshot of the server spec, after which all the data gets put into a neat file for the user to review.

I have written a bunch of individual scripts for each task over time but itís really messy. At the time I wrote those scripts, I used whatever method was best to get it working. Some have function structures, others have loop structures and a whole variety of others in between.

Now I am looking to try and collate all those scripts into one nicely structured single script. What Iím hoping for is advice and tips from the community on how best I can achieve this.

The distro Iím currently working with is RHEL 7+ but I would like to make the script as universal as I can, so other versions of RHEL and maybe other distroís like Solaris / HPUX.
The script it self is running bash shell.

Is this the right place to post my efforts and ask for help / improvements? Or does anyone know if someone has already written this kind of script I can use as an example?

Cheers
 
Old 05-15-2020, 12:40 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,774

Rep: Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537
Take advantage of your experience so far to re-write each check as clean fn, with lots of error handling and have the 'main' section call each fn and concat the results into a file.

Ensure you use proper naming, indenting, comments in your code.

For extra points, you could get the main to run the fns in parallel (eg using '&" ) as they seem to be pretty independent, then it would have to concat the results together when all(!) have finished.

In either case, I'd definitely recommend using a dedicated dir to store the results in (maybe you want to store older versions of the results as well).

Also decide what format you want in the report eg csv.
To do that properly (harder than you think), consider using eg Perl which has modules for that & many other formats.

If you are also considering collecting performance stats, have a look at collectl https://www.tecmint.com/linux-perfor...collectl-tool/, http://collectl.sourceforge.net/index.html
 
Old 05-16-2020, 09:35 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,815

Rep: Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317Reputation: 6317
Quote:
Originally Posted by chrism01 View Post
Take advantage of your experience so far to re-write each check as clean fn, with lots of error handling and have the 'main' section call each fn and concat the results into a file.

Ensure you use proper naming, indenting, comments in your code.

For extra points, you could get the main to run the fns in parallel (eg using '&" ) as they seem to be pretty independent, then it would have to concat the results together when all(!) have finished.

In either case, I'd definitely recommend using a dedicated dir to store the results in (maybe you want to store older versions of the results as well).

Also decide what format you want in the report eg csv.
To do that properly (harder than you think), consider using eg Perl which has modules for that & many other formats.

If you are also considering collecting performance stats, have a look at collectl https://www.tecmint.com/linux-perfor...collectl-tool/, http://collectl.sourceforge.net/index.html
Agree with chrism01 about Perl, specifically this module:
https://metacpan.org/pod/Spreadsheet::WriteExcel

If each of your scripts produces a CSV output (or CAN produce one), you can write the output of each script to a separate sheet in a spreadsheet. Makes it easy to look at later. And depending on what you want to do with the data, you can also shovel it into a MySQL table(s), and report on it from there. Check into Google Charts...free visualization plug-ins for web. Pretty flexible, although (as with most things Google), lacking in documentation for a good number of things. Simple PHP can query the database, and output a table, chart, graph, whatever.

Just a thought...don't know what your end goal is.
 
1 members found this post helpful.
Old 05-16-2020, 06:10 PM   #4
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 4,834

Rep: Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765
I'm stricken with the similarity between the OPs specifications and logwatch.
 
1 members found this post helpful.
Old 05-21-2020, 10:14 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: Currently: openSUSE, Raspbian, Slackware. Formerly: CentOS, MacOS, Red Hat. Other: Solaris, Tru64
Posts: 1,921

Rep: Reputation: 295Reputation: 295Reputation: 295
Quote:
Originally Posted by scasey View Post
I'm stricken with the similarity between the OPs specifications and logwatch.
The request in #1 reminds me of the odd little utility/service that Tumbleweed uses to build an /etc/issue file at boot. (That and the "syscheck" utility on Tru64.)

None of the bits of information would necessarily be that tough to write. Depending on the distribution I wouldn't be surprised to learn that something already has been written that does this.
 
  


Reply

Tags
bash, rhel, scan, shell script, spec


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
win32,shell code,shell programming,shell scripting? mr.cracker Linux - Newbie 4 07-12-2013 11:20 PM
LFS RPM SPEC files: Binutils RPM spec for x86 arch nocountryman Linux From Scratch 2 10-25-2010 09:09 AM
iwlist scan - no scan results compu73rg33k Linux - Wireless Networking 6 05-29-2009 02:37 AM
Nessus scan and no port scan possible? memo007 Linux - Security 1 09-08-2008 06:21 PM
To SCAN or not to SCAN? HP750xi Suse 9.2 Pro newtwolinux Linux - Hardware 4 06-22-2005 04:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration