|[Date Prev] [Date Next]||[Thread Prev] [Thread Next]||[Date Index] [Thread Index]|
Re: [nocol-users] MySQL monitor?
> > I'd love to write a good Perl DBI monitor, where you could specify > > username, password, port, and DBD type in the config file and have a SQL > > statement to use to test it. > > Looks like I don't have to, now =) > > If anyone feels up to writing a FAQ on how to write a Perl based monitor, > > I'll be happy to contribute it when complete. Otherwise, I'm too busy > > working on the HUP situation to read the current Perl monitors and > > determine what I need to do. > > > > Here's one I'd hacked out of ciscomon. It works pretty well. I didn't spend > a lot of time making the config file easy to use--the lines are very long > but you can't use a continuation character. I don't change if very often > anyway... Config file looks like this: > > # Config file for SQLmon nocol monitor > # > # Format: > # POLLINTERVAL 600 (only the last one takes effect) > # <name> <addr> <maxseverity> <DBI driver> <username> <password> <SQL > query-string> > # > ## > POLLINTERVAL 120 > # > sql1 184.108.40.206 Critical dbi:mysql:mysql:localhost nocol xxyy select * > from user > sql2 220.127.116.11 Error dbi:mysql:mysql:sql2 nocol xxyy select * > from user > Why even have people put the dbi: in the config file? Correct me if I'm wrong, but can't you just assume that and add it when you make the connection? > The first two fields are the standard sitename and siteaddr that nocol > wants. The third is the maximum severity that the device will rise to. The > third is the dbi driver string. The above works for mysql; others may be > different. Note that you have to include the hostname here--the script > doesn't try to pull it from field 1 or 2. Next two are the username and > password to access the database. Everything from there on is the sql query > to execute. If the query is successful it uses the return value in the > "value" field. If not it sets that to 0 and bumps the severity. The above > query--in case you're not dbi proficient--is selecting everything in the > user table of the mysql database. > > The script will die if either the username/password doesn't work or if your > SQL is invalid. *nod* So I noticed. I think you'd probably want to have it fail rather than have the script die. I'll take a look at it and send some more feedback later on. > > The script itself is attached. > Thanks for the help to all of us, Rick. --Nathan ____________________________________________________________________ Nathan Clemons, Systems Engineer WinStar Internet and Hosting Services 800 South Main St. Mansfield, MA 02048 ____________________________________________________________________ email@example.com www.winstar.com (v) 800-234-0002 ext.1109 firstname.lastname@example.org (f) 508-261-0430