Creating incidents in Nagios - linux

I need to create an incident (using remedy, ICM, or third party tools) automatically whenever a CRITICAL alert pops up on Nagios tool. Can anybody recommend how to do this?

In the nagios configuration where you define a contact, you have two options:
host_notification_commands
service_notification_commands
These ship with the default of host-notify-by-email and service-notify-by-email respectively, and those are defined with the command configuration option. You could define your own command, and put it next to one of the notify commands inside contacts, and It'll get run in addition to a page.
Alternatively, look for a plugin on the Nagios Exchange
An example; IRC notifications plugin:
http://exchange.nagios.org/directory/Addons/Notifications/IRC/nagircbot/details

Remedy can create incidents out of emails. Talk to your remedy admin, figure out the format the email needs to come in, and then modify the notification commands to send the email out as needed

Related

How to properly set VoIP Innovations credentials in RestComm AMI?

I'm having troubles setting up the API username/password from VoIP Innovations in my RestComm AMI.
I've followed the steps described here but the AvailablePhoneNumbers api call returns an empty list.
Then I accessed the instance via ssh and checked for the restcomm.conf file in the standalone folder. My VoiceRSS key was there but the not the VI credentials. I spent some time looking at the other files in $RESTCOMM_HOME and I found one of particular interest: $RESTCOMM_HOME/bin/restcomm/autoconfig.d/config-restcomm.sh
In that file the configVoipInnovations method call was commented and even if it wasn't commented it requires a third argument (the VI endpoint ID, which I'm not sure if it refers to the VI Endpoint Group ID or something else) that wasn't mentioned in the link above.
I also tried editing $RESTCOMM_HOME/standalone/deployments/restcomm.war/WEB-INF/conf/restcomm.conf directly with
<voip-innovations>
<login>my VI Api username</login>
<password>my VI Api password</password>
<endpoint>my VI endpoint group id</endpoint>
<uri>https://backoffice.voipinnovations.com/api2.pl</uri>
</voip-innovations>
But it didn't seem to work. The AvailablePhoneNumbers still returned an empty list.
What am I missing?
#nbermudezs,
In order to send/received SMS you should register an SMS enabled DID. Unfortunately you cannot register such DID via the Admin UI (in contrast with voice DIDs). You should go to your VoipInnovations account dashboard and search for SMS enabled DIDs there. Register the SMS enabled DID of your choice first in VoipInnovations back office and then simply go to Restcomm Admin UI -> Numbers -> +Register Number. From the drop down menu choose US as Country, select the area code for the DID of your choice and in the Number field enter the actual number (without the area code in front of it) then click register. After that you should be able to send/receive SMS from/to your newly registered DID.
#nbermudezs,
Sorry that you are having problems configuring Restcomm for Voip Innovations. When you are using Restcomm AMI, it already comes pre-configured with a default (Demo) Voip Innovation account that will automatically provision DIDs and allow you to choose an Area Code in the United States. Because the configuration script will automatically default to the pre-configured Voip Innovations account, modifying the restcomm.xml file will not work work as expected. Did you try to provision DID using the Admin UI?
On the AMI, this is how to set your VI information
Go to the directory /opt/telestax/restcomm/current/bin/restcomm
edit the file restcomm.conf
Go to the section below and fill out your VI account details. The must be set to PROVISION_PROVIDER='VI'
# DID Provision provider variable declarations
PROVISION_PROVIDER='' # values: VI (VoipInnovation), BW (Bandwidth), NX (Nexmo), VB (Voxbone)
#Username and password for all supported DID provision providers
DID_LOGIN=''
DID_PASSWORD=''
# VoipInnovation Endpoint ID
DID_ENDPOINT=''
Save your changes
You must restart Restcomm as follows
restcomm_stop
restcomm_start

How to send facebook message from linux console (command-line)

Old days many admins use sms-gates for sending important informations from their systems e.g. "Power down, UPS is working now!", "Power Up, UPS is off!" or "CPU Temp too high!". Today in Facebook era we use messenger instead of SMS, so I wonder if I could create a command-line bash or php script for such thing.
The idea - cron checks every 10 minutes the condition and if it is true, sends message to my messenger.
The issues:
I don't want to use my fb account for sending - I'd like to get message
from "System 1", "System 2", because i have more than one system to
admin.
The bash part is easy for me, I need tips for Facebook solutions:
do I have to get FacebookAppId (and do I have to create AppId for
each system or just one AppId)
how to "join/confirm/accept" "System 1" account with my Facebook Account
is it possible to send messages to more than one FBAccount
any other hints what should i look for.
I found Notification App, but i think that it doesn't send message to messenger, so it would be useless.
The Chat API was removed with v2.0 of the Graph API, there is no way to send messages with an API anymore. Btw, messages are for communcation between real users, they should not be used as notification system anyway. SMS is still a good option for those kind of warnings imho.
Using a Page and the /conversations endpoint would not work either:
Pages can only reply to a message - they cannot initiate a conversation. Also, a Page can only respond twice to a particular message, the other party will have to respond before they can reply again.
Source: https://developers.facebook.com/docs/graph-api/reference/v2.3/conversation/messages#publish
I think for your special purpose, twitter may be a better option. Twitter accepts tweets from API. So what you need to do is to set up an account to publish your system status either regularly or event-triggingly and follow it in your own personal account.
And there are already plenty of open source projects focusing on tweeting via API, and t is the one I am currently using.
So there are a couple of command line apps to do this.
There is a libpurple extension (https://github.com/dequis/purple-facebook) which works. However purple doesn't seem to support the idea of message history. This is a shame since I imagine offline messages is the default way most people use facebook.
There is an single use command tool for facebook as well: https://www.npmjs.com/package/fb-messenger-cli which does support history. Unfortunately this is a TUI rather than a command line application and doesn't seem to depend on a separate facebook library.
Some hacking or terrible expect glue could work around this.
I just published a service exactly for that use case :
https://www.nimrod-messenger.io/
It's at an early stage. Feedbacks are more than welcome :-)
Sending facebook message in bash script
IDEA
I needed a script (which work on my work/local mac) that checks server. If there are problems, script will send me messages on Facebook.
Dependencies
need to install: https://github.com/mjkaufer/Messer
Solution, bash script
FB_SENDER_LOGIN=""
FB_SENDER_PASSWORD=""
function send_fb_message {
FB_MESSER_COMAND="messer $FB_SENDER_LOGIN $FB_SENDER_PASSWORD --command='m \"$1\" $2'"
eval "$FB_MESSER_COMAND"
}
RECIPIENT_NAME_DISPLAYED_IN_FACEBOOK_WEBSITE="Vasily Bodnarchuk"
MESSAGE="Houston, we have a problem!!!"
send_fb_message "$RECIPIENT_NAME_DISPLAYED_IN_FACEBOOK_WEBSITE" "$MESSAGE"
Automated Facebook message
I was looking for something like this exactly and found that Messer is the way to go.
Solution
Look at this repo called Messer https://github.com/mjkaufer/Messer
(it works with 2FA too but not with app passwords)
Implementation
See Readme
I needed it to run automatically so I used it's non-interactive mode with a bash script:
message="Hey, what\'s up bro"
FULLPATH/node_modules/.bin/messer --command="m \"Myfriends Name\" $message"
I don't like to install something like this globally through NPM so I used the /node_modules/.bin/messer executable in the project's folder.
Used double quotes escaped instead of single quotes to be able to use variables inside command.
Drawback: Messer can only send, not receive.

trigger a .sh script when a specific subject email is received

Anyway, I have a script that I want to run whenever I receive an email on gmail. And if possible a subject specific email. is such a thing possible and if so, what programs do I need to allow it.
You can't instruct gmail to trigger an external script for you. I think you've got a few basic choices. In order of increasing difficulty and complexity:
1) Configure a gmail filter to deliver your desired messages to a special folder. Write a script to poll that folder, download (or delete or mark as read) messages it finds there, and then launch your local script. Set up a cron on your local machine to run the script every few minutes. You can poll the folder with IMAP or the GMAIL API. IMAP is probably easier. This will be tricky with shell, you're better of with Python, PHP, or similar.
2) Configure a gmail filter to forward your desired messages to an address on a mail server that you control. Use procmail or similar to intercept the incoming messages and launch your script.
3) Set up an account at Mailgun and configure the emails so they get delivered there directly. (Or forward from gmail as in #2.) Configure Mailgun to launch an API request when it receives messages. Build an API handler to receive the request. Launch your process from your API handler.
I have never done it, but I guess the first thing you should do is to take a look at the Google's Gmail API...
What is the Gmail API?
The Gmail API gives you flexible, RESTful access to the user's inbox,
with a natural interface to Threads, Messages, Labels, Drafts, and
History.
It seems to fit what you want - at least, without knowing the details of what you want to do.
The Gmail API can be used in a variety of different applications,
including, typically:
Read-only mail extraction, indexing, and backup
Label management
(add/remove labels)
Automated or programmatic message sending
You can use several programming languages - maybe the trick is using your programming language of choice to write a wrapper for the .sh script... I hope this helps!

Plugins for incoming and outgoing emails in CRM 2011

I need to create two plugins for CRM 2011
Whenever an email is incomging or outgoing I need to check if the email has any attachments in it. If yes I need to set one boolean value to true.
When user (user only, not workflow or automatic message etc.) answers some email I need to fire a plugin that checks incident's status (email is regarding to an incident) and depending on the status do some things.
I'm not really familiar with this whole email tracking concept. We have an email router configured, but that's all I can say.
What are the steps that I need to use in order to achieve plugins described?
For the first plugin I think "Create of email" is enough, right? What about the second plugin and how can I make sure that plugin is fired only when a real person sends an email?
For the first plugin:
To check for attachments for an email you will need to create a plugin which executes on create of the ActivityMimeAttachment entity, which is the entity which stores email attachments.
When an inbound email is processed by the Email Router (or tracked in the Outlook Client) the parent Email record is created first, and then an ActivityMimeAttachment record is created for each attachment.
If you try to check for attachments when an Email is created it will be executing before any attachments are created. However, you may also need a plugin to execute when an Email is created to set the 'Has Attachments' field to false.
The plugin on ActivityMimeAttachment will need to get the parent email activity and set the 'Has Attachments' field to true. This will handle both inbound and outbound emails.
Also note that for 100% accuracy you may need to consider the scenario of a user who is writing an email and adds an attachment, and then deletes it. This could be handled by a plugin running when attachments are deleted, but that logic can get complex (what if two attachments were added but only one was deleted?)
There is some useful sample code for dealing with the ActivityMimeAttachment entity here.
For the second plugin:
A plugin which executes on update of an email would then need to validate the following criteria:
The email direction is outbound (a user has answered an email, e.g. sent a reply)
The email status reason is Sent (the email has actually been delivered and is not saved as a draft)
The email sender and/or owner and/or created by is a real user (filter out automatic and workflow sent emails)
The regarding object is an incident
Then you can implement the required custom validation and logic.
The second item could potentially be achieved using a standard workflow, depending on how complex the custom logic is. If the logic is too complex for a standard workflow, a custom workflow activity might also be useful since additional logic or validation could be added without writing additional code.
For the 1. Plugin: Register on email create and on update (maybe users create the mail first and then update some attachments later)
For the 2. Plugin: Check the following:
plugin context depth should be 1 (this makes sure that no mail created by another plugin is processed)
Check the created by and created on behalf by fields on the email entity to be a non technical users and that no one is acting on behalf of another user creating this mail
Check that regarding object points to incident
If this is not sufficient enough and the users sends mails only via CRM Web GUI you can additionally set a special flag on the record via javascript to make sure that the mail was created using the gui. Than check this status flag in the plugin.

automation of tasks - email using web application

I have a web application that monitors farms in certain areas. Right now I am having a problem of performing automation with some of the tasks.
Users of the web application can send reports or checkins using keywords. If the reports or checkins correspond to certain keywords, for example "alert", I need the web application to send an alert to the user via email using that web application. But that alert must be sent two weeks after the date of the report received, and to that particular user only.
Would it be possible to use cron to perform this? If not, can anyone suggest me a workaround?
A possible approach you might consider is to store an entry in a database for each of these reminder emails you need to send, at the time your user does whatever action in your application that determines the need to send that email exists. Include the recipient, the date to be sent, and the email content as content you store for each entry. Schedule a single cron job to run periodically to process these database records by due date, and populate an email template to be sent out. You can then either delete the database records, or a better option, include a column that indicates they were sent and mark them as sent.
It would help to provide which technology stack you're operating on and what the application is developed in. Others might be able to point you to technology specific approaches or pre-built plugins/extensions that already do this for the situation you're in, to help you avoid the need to write your own code for the solution.

Resources