[SOLVED] Shell Scripting: RHEL server scan - What’s my spec??
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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 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.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,802
Rep:
Quote:
Originally Posted by scasey
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.