Project of communication
Project of communication
Hi everybody,
I'm from France and excuse my english,
I'm currently in a job training and my boss asked me to do a project.
He wants that Nagios communicate his notifications towards an external software of IT asset management written in Java whiwh has a MySQL database.
The goal is doing statistics and for that receiving notifications without losing it.
But:
He don't want plugins like NDOutils,
and also he don't want use mail server (it could be down).
What kind of solutions do you think about?
I'm from France and excuse my english,
I'm currently in a job training and my boss asked me to do a project.
He wants that Nagios communicate his notifications towards an external software of IT asset management written in Java whiwh has a MySQL database.
The goal is doing statistics and for that receiving notifications without losing it.
But:
He don't want plugins like NDOutils,
and also he don't want use mail server (it could be down).
What kind of solutions do you think about?
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Project of communication
sounds like you need to write an event handler or other notification command to make the additions to your database that you want. Otherwise I really see NDOutils as about the only other real option.
Note I am moving this to core support, as it is not related to the plugins package.
Note I am moving this to core support, as it is not related to the plugins package.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: Project of communication
No i wish Nagios send notifications to a temporary text file leavin the deafault email solution running.
I put this in misccommands
Does it work?
what i have to put instead of $CONTACTEMAIL$ ?
Thanks.
"HOST ALERT:\n
\n
Notification Type: $NOTIFICATIONTYPE$\n
Host: $HOSTNAME$\n
State: $HOSTSTATE$\n
Address: $HOSTADDRESS$\n
Info: $HOSTOUTPUT$\n
\n
Date/Time: $LONGDATETIME$\n"
|
/tmp/textnotif.txt
"HOST ALERT:
$HOSTNAME$
is
$HOSTSTATE$ - $NOTIFICATIONTYPE$"
$CONTACTEMAIL$
notify_service_by_txt
/usr/bin/printf "%b"
"SERVICE ALERT:\n
\nNotification Type: $NOTIFICATIONTYPE$\n
\n
Service: $SERVICEDESC$\n
Host: $HOSTALIAS$\n
Address: $HOSTADDRESS$\n
State: $SERVICESTATE$\n
\n
Date/Time: $LONGDATETIME$\n
\n
Additional Info:\n
\n
$SERVICEOUTPUT$"
|
/tmp/textnotif.txt
"SERVICE ALERT:
$HOSTALIAS$ - $SERVICEDESC$
is
$SERVICESTATE$ - $NOTIFICATIONTYPE$"
$CONTACTEMAIL$
I put this in misccommands
Does it work?
what i have to put instead of $CONTACTEMAIL$ ?
Thanks.
"HOST ALERT:\n
\n
Notification Type: $NOTIFICATIONTYPE$\n
Host: $HOSTNAME$\n
State: $HOSTSTATE$\n
Address: $HOSTADDRESS$\n
Info: $HOSTOUTPUT$\n
\n
Date/Time: $LONGDATETIME$\n"
|
/tmp/textnotif.txt
"HOST ALERT:
$HOSTNAME$
is
$HOSTSTATE$ - $NOTIFICATIONTYPE$"
$CONTACTEMAIL$
notify_service_by_txt
/usr/bin/printf "%b"
"SERVICE ALERT:\n
\nNotification Type: $NOTIFICATIONTYPE$\n
\n
Service: $SERVICEDESC$\n
Host: $HOSTALIAS$\n
Address: $HOSTADDRESS$\n
State: $SERVICESTATE$\n
\n
Date/Time: $LONGDATETIME$\n
\n
Additional Info:\n
\n
$SERVICEOUTPUT$"
|
/tmp/textnotif.txt
"SERVICE ALERT:
$HOSTALIAS$ - $SERVICEDESC$
is
$SERVICESTATE$ - $NOTIFICATIONTYPE$"
$CONTACTEMAIL$
Last edited by kiko67 on Wed Apr 30, 2014 9:14 am, edited 1 time in total.
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Project of communication
I'm sorry, that is really hard to understand what you are doing with those commands, could you format and use
Code: Select all
[ /code] tags(minus the spaces). The idea of appending to a text file or creating lots of indiviual text files will work. However I should note that you can only have one notification type per contact, so you cannot do email and text file notifications without dual contacts.Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: Project of communication
Thanks for your help,
i enter these commands in my misccommands file:
/bin/echo -e "HOST ALERT:\n\n
Notification Type: $
NOTIFICATIONTYPE$\n
Host: $HOSTNAME$\n
State: $HOSSTATE$\n
Address: $HOSTADDRESS$\n
Info: $HOSTOUTPUT$\n
Date/Time: $LONGDATETIME$\n"
>>
/tmp/notif_text.txt
"HOST ALERT: $HOSTNAME$ is $HOSTSTATE$' - $NOTIFICATIONTYPE$"
and i don't know what to put as email address
if i put nagios@localhost is it correct ?
And when i enter the command in my prompt the file /tmp/notif-text.txt is created with:
HOST ALERT:localhost is $ - $
Notification type: $
Host: Localhost
State: $
Address: $
Info: $
Date/Time: $
But after when i put the same command in my misccommand file the notifications aren't written as a text.
Why ?
How should i proceed to have notifications only (and not the all log file) in a text file?
i enter these commands in my misccommands file:
/bin/echo -e "HOST ALERT:\n\n
Notification Type: $
NOTIFICATIONTYPE$\n
Host: $HOSTNAME$\n
State: $HOSSTATE$\n
Address: $HOSTADDRESS$\n
Info: $HOSTOUTPUT$\n
Date/Time: $LONGDATETIME$\n"
>>
/tmp/notif_text.txt
"HOST ALERT: $HOSTNAME$ is $HOSTSTATE$' - $NOTIFICATIONTYPE$"
and i don't know what to put as email address
if i put nagios@localhost is it correct ?
And when i enter the command in my prompt the file /tmp/notif-text.txt is created with:
HOST ALERT:localhost is $ - $
Notification type: $
Host: Localhost
State: $
Address: $
Info: $
Date/Time: $
But after when i put the same command in my misccommand file the notifications aren't written as a text.
Why ?
How should i proceed to have notifications only (and not the all log file) in a text file?
Re: Project of communication
Probably not. If you are referring to the $CONTACTEMAIL$ macro, this is the email address to send the notification to, so it should be a real email.kiko67 wrote:and i don't know what to put as email address
if i put nagios@localhost is it correct ?
How are you calling this script? As an event handler, or some other way? It looks like $HOSTNAME$ is the only populated macro.kiko67 wrote: And when i enter the command in my prompt the file /tmp/notif-text.txt is created with:
HOST ALERT:localhost is $ - $
Notification type: $
Host: Localhost
State: $
Address: $
Info: $
Date/Time: $
But after when i put the same command in my misccommand file the notifications aren't written as a text.
Why ?
Could you clarify? Are you just trying to log notifications?kiko67 wrote: How should i proceed to have notifications only (and not the all log file) in a text file?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Project of communication
I enter this script in my NConf plugin. It is saved in /etc/nagios/global/misccommand.cfg like this:kiko67 wrote:How are you calling this script? As an event handler, or some other way? It looks like $HOSTNAME$ is the only populated macro
define command{
command name notify-host-by-txt
command_line /bin/echo -e "HOST ALERT:\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" >> /tmp/notif_texte.txt "HOST ALERT: $HOSTNAME$ is $HOSTSTATE$ - $NOTIFICATIONTYPE$"
Yes my goal is to send notifications to a text file.kiko67 wrote:Could you clarify? Are you just trying to log notifications?
Three days that i work on it.
After that, a script of another software will search in this text file and enter the datas in a database.
But it will be another stuff.
Now, i have to find the solution to write notifications in a text file.
Thx
Re: Project of communication
What is the purpose of the macros at the end:kiko67 wrote:command_line /bin/echo -e "HOST ALERT:\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" >> /tmp/notif_texte.txt "HOST ALERT: $HOSTNAME$ is $HOSTSTATE$ - $NOTIFICATIONTYPE$"
Code: Select all
"HOST ALERT: $HOSTNAME$ is $HOSTSTATE$ - $NOTIFICATIONTYPE$"Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Project of communication
I copy these macros from email notification command but i remove it and i try without it.kiko67 wrote:What is the purpose of the macros at the end:
The problem is to understand which is the right solution to send the notifications to a text file and not only to an email ?
Because the log file is too big and i want only notifications in a text.
I think as notification because i've created a contact and put this command in /etc/nagios/global/misccommand.cfg file like the "notify-by-email" command.kiko67 wrote:Are these commands run as event handlers or as notification handlers?
I'm in a job training, and nagios was already installed with NConf 1.2.5 plugin to configure it.....
And this task is driving me crazy!
Thanks for your help.
Re: Project of communication
Thanks to everybody,
the command works, i don't know how but it works.
Now the second phase of the project is to make an agent that will search and find in our text file the intresting datas and put it in a database.
Thanks for your help.
the command works, i don't know how but it works.
Now the second phase of the project is to make an agent that will search and find in our text file the intresting datas and put it in a database.
Thanks for your help.