When a critical alarm is detected in NNM I need the data to be written to an SQL DB. Failing this anyone know how to simply write the info to a txt file?
in the event configuration, just enter "perl write_error.pl \"this is my error message\""
(ps. make sure perl is a trusted command, ie. go to $openview/conf/trustedcmds.conf/ and create a file called NNM and enter this one line : "perl=$PERL_BIN\\perl.exe"
and the perl script would be something like. . .
"
$strTextToWriteToFile = (shift)
open (OUTPUT, ">>output.txt"
print OUTPUT "$strTextToWriteToFile\n";
close (OUTPUT);
"
or something like that. . .
and, realisitcally, exporting to a database wouldn't be a whole lot more difficult, but that depends on your experience with SQL and such.
if you want some help with the SQL version or this one, just let me know, and i'll see what i can do. i've got a perl script that creates Remedy trouble tickets by directly writing to the DB, so i might have what you're looking for. . .
This appears to be the way to do it ... OK, so i'm now getting it written to a text file whenever the event alarm fires, which is excellent.
Would you (or anyone else) be willing to share the Perl script you have for directly writing to your DB? From there i will *hopefully* be able to amend to fit our setup...
I suppose this belongs in the "Perl" forum, but maybe no one will notice . Here's the script, it's pretty easy, and actually a lot like the "insert to text file" version.
you would call this the same way: "perl insert_to_db.pl value1 [value2 value3 ...]"
i believe DBI comes with ActivePerl, so with a default install, you should be good to go. This script works well just as a perl script, but takes a little bit of tweaking to get it to work as a CGI script off of a web server, especially if it's an Access Database off of an IIS server.
the worst part is getting the DBI connect to work. if you haven't played with this before, go into the "Database Sources" icon in the control panel (if you're using Windows and not Linux/Unix.) and add a 'User DSN' (Data Source Name).
like i said, give it a shot, and definitely write back if it's not working, or you have any questions, i'll be glad to help.
- alex
################# BEGIN INSERT_TO_DB.PL ##############
#!D:\PERL\bin\perl.exe
use DBI;
################### GET PASSED INFO #################
# add a "shift" to the right hand side for each value being read in from the command line
$hndDBHandle = DBI->connect('dbi:ODBC:MyDatabase','$strUserName','$strPassword') || print "Cannot connect to the DB: $!<BR>";
##### CONFIGURE HANDLE TO BE ABLE TO READ REALLY LONG VARIABLES ###################
$hndDBHandle->{'LongReadLen'} = 6000 ; # to better handle long variable strings
$hndDBHandle->{LongTruncOk} = 1 ; # TRUE. if it's longer than 6000 characters, just truncate the dumb thing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.