LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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: 14

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: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
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
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
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: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,802

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
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



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 03:55 PM.

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
Open Source Consulting | Domain Registration