- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Create a lookup file or an array
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 10:05 AM
06-20-2003 10:05 AM
I was looking for some ideas on a config file which will be used as a lookup.
What I am trying to achieve is I will be running a monitor script and when I receive an elert I would like to then check a config file to see who is the support team and the support manager. This will be based on the server name, application and maybe some other data I receive.
I know I could have an entry in a config file like below and then use a while loop or a for loop to read in each line.
# Support Team Manager Server App Object
Email Email Joe Bloggs eclipse Exch mail
The while loop would then read in the file and check the detailes against the alert that has been generated from the server and send an email to the correct support team and manager if necessary. Do you think the above method is a good way to do this or any ideas on keeping this data so it is easy to maintain and add to or delete.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 10:18 AM
06-20-2003 10:18 AM
Re: Create a lookup file or an array
What you describe would be very easy and fast in Perl, also awk, and doable in the shell.
I would lean towards Perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 10:25 AM
06-20-2003 10:25 AM
Re: Create a lookup file or an array
My vote goes to the lookup file. This way you don't have to modify your script and you can give control to others to modify only the configuration.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 10:32 AM
06-20-2003 10:32 AM
Re: Create a lookup file or an array
This looks ok just use sleep in your loop
you don't need to check about 50 times in sec.
Also check that you work with file so if you
open it close in the end (all in loop)
In the end see that this script when he run
the preformance of running.
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 10:45 AM
06-20-2003 10:45 AM
Re: Create a lookup file or an array
I then have a script monitoring for particular issues and if one arises, depending on the issue I just do a for loop against the Phones.db file and a grep for the name I want. When a match is found, I pass that variable to sendmail and send a message out to that users phone.
excerpt from Phones.DB
Name Phone# Email
Jim XXXXXX XXXXX
Bob XXXXXX XXXXX
excerpt from Monitor.sh
for i in `grep $USER Phones.DB | /usr/bin/awk '{print$2}'`
I would probably use Perl as Clay said but don't know it yet, I will soon hopefully though as I picked up a couple of books he recommended.
Jim Mallett
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 10:56 AM
06-20-2003 10:56 AM
Re: Create a lookup file or an array
for USERINFO in `grep HOSTNAME /usr/configfile|awk '{ print $2,$3, $4 }'
do
echo $USERINFO
done
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 01:08 PM
06-20-2003 01:08 PM
Re: Create a lookup file or an array
something faster, but more complex would be to do something like NIS and create files with appropriate indexs from your configuration file. Then, instead of looping through every line, a simple grep using the index will return your desired information.
This method does require updating your index files whenever there is a change to your configuration file, creating an extra step whenever a change is made. But, your probably going to create a front end script to make changes to your configuration file.
A script that asks the user for the required information and does some error checking/data validation before adding/deleting it to/from your configuration file. This front end would also limit one user at a time to be making changes.
It would be easy to add your index updating to such a front end. But, while simple to do it still requires someone to write and that will take time. And, the extra step adds complexity.
NIS already has the scripts to index things like the password file, the hosts file, email aliases, etc., so it isn't like your starting from stratch. You only have to make copies and then modify your copies to slice and dice your configuration file appropriately for your application.
Not only will indexing make your application run faster but by properly organizing your data, it will be simplier to write and therefore, easier to maintain also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2003 06:20 PM
06-20-2003 06:20 PM
Re: Create a lookup file or an array
%oncall_person ( manager -> 1232342424,
test -> 32323,
amen -> 666 ),
this will always remain in memory - fastest way to lookup - lookup tables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2003 08:36 AM
06-21-2003 08:36 AM
Re: Create a lookup file or an array
Thanks for all the helpful feedback. I will be using a shell script to search for the entry in the config file as I do not know perl as well as shell scripting. Its another thing to put on my long list of things to learn!!
Curt, I do not have any experience with NIS, so I was wondering if you could elaborate on how NIS uses index files and then checks the config file so I can then decide if it is a better solution.
Thanks again to everyone for their input.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2003 02:22 PM
06-21-2003 02:22 PM
Re: Create a lookup file or an array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2003 03:16 PM
06-21-2003 03:16 PM
Re: Create a lookup file or an array
http://thor.prohosting.com/~nupshot21/perl/perl_dbm.shtml#DBM005C
http://adamspiers.org/computing/dbm/
http://www.jlmeek.com/demo/hash.txt
that should give you some examples to work with
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2003 09:42 AM
06-22-2003 09:42 AM
Solution#!/usr/local/bin/perl -w
#
# output the value of a key from a DBM
# database given the database name and key.
#
use Fcntl;
use NDBM_File;
if ($#ARGV != 2) {
print "usage: $ARGV[0] databaseName keyValue\n";
exit 1;
}
$dbName = $ARGV[1];
$key = $ARGV[2];
tie %hash, "NDBM_File", $dbName, O_RDONLY|O_EXCL, 0644; ||
die "Cannot open database file, $dbName: $!\n";
$value = $hash{$key};
if (!defined($value)) {
print "$key not stored\n";
exit 2;
} else {
print "$value\n";
}
untie %hash;
exit 0;
that should be a good start on a perl script for returning a value from a DBM database given the database name and key.