I would like to send notifications to instant messengers, such as AIM, Facebook, Gadu-Gadu, IAX (Inter-Asterisk Exchange), ICQ, IRC (Internet Relay Chat), Jabber, MSN, Netsend, Tlen, Yahoo, Google Talk (GTalk), Skype, Bonjour, etc. Is it possible to do this using external software controlled via command line?
How can PRTG send instant messages to Jabber, ICQ, MSN, Yahoo, etc., using external software?
4 Replies
This article applies to PRTG Network Monitor 12 or later. Note that we cannot provide guarantees that the approach below still works with the involved external tools.
Use Custom Notifications to Send Instant Messages
Using PRTG's Execute Program notifications option, you can use an instant messenger with command line capabilities to send messages via virtually any instant messaging protocol. This article will show an example of how to send notifications to an ICQ account, using a combination of the following programs:
- PRTG Network Monitor
- Miranda Instant Messenger
- Miranda Command Line Plugin
- NSSM—the Non-Sucking Service Manager
Known issue: The described setup might not work with Windows Server 2012.
Step 1: Install and Prepare Miranda
- Download Miranda IM and install it on your computer in Portable Mode (this is an option during setup), so you can move it to your PRTG server later on.
- In Miranda IM, set up an ICQ account dedicated to sending messages for PRTG (sign up for a new one, if necessary). Add all future recipients of notifications to this account's contact list and test if messages are received on the other side. Note: Although this is an example for ICQ, you can add any other account using one of the supported protocols, e.g. Jabber, MSN, etc.
- Write down the possible recipients' ICQ numbers—you will need them later.
- Download the Command Line plugin and extract it to your Miranda installation directory. To check, make sure the file CmdLine.dll is in the \Plugins sub folder after extracting.
Step 2: Move Miranda to PRTG Server System
Note: When running a cluster, you need to perform the actions in this step on every single node to make sure notifications are also available in case the Master Node fails.
- Copy the Miranda IM directory to the system running your PRTG core server. You can choose any directory, e.g. C:\Miranda IM
- Move the file MimCmd.exe from the Miranda installation directory to the \Notifications\EXE sub folder of your PRTG program directory.
Step 3: Configure Miranda as Windows Service
Now comes the tricky part: You have to make sure that the file miranda32.exe (or miranda64.exe, accordingly) from the Miranda IM directory and the PRTG Server.exe system service (which is PRTG's core server) are running under the same Windows user account, which for PRTG is, by default, the local Windows "system" account. One way is to register the Miranda EXE file as a Windows service, started under the local Windows "system" account.
Note: When running a cluster, you need to perform the actions in this step on every single node to make sure notifications are also available in case the Master Node fails.
- Download and install "NSSM—the Non-Sucking Service Manager", an open source command line tool which lets you easily run an EXE file as Windows service. Extract the ZIP file to a directory on the system running your PRTG core server, e.g. C:\nssm.
- On the Windows command line, enter a command to register Miranda as a service, for example:
C:\nssm\win32> nssm.exe install MirandaIM
- In a GUI window, you will be prompted to enter the path to the application you wish to run as a service and any commandline options to send to it (see NSSM usage documentation). Enter the path to the Miranda application, for example C:\Miranda IM\miranda32.exe, and a service name, for example MirandaIM. You do not need to enter any options. Click on Install service. The service is added with start type "Automatic".
- In the Windows Computer Management console (compmgmt.msc), view the list of services and start the newly created service MirandaIM manually. It should be started under the Windows local "system" account (check this in the task manager). After a successful start, you should see the configured ICQ account as "online" in any of the recipients' messengers. This is mandatory to receive messages later.
Step 4: Set Up Notification in PRTG
- In the PRTG web interface, select Setup | Account Settings | Notifications from the main menu.
- Click on Add new notification and set a check mark for Execute Program.
- In the Program file drop-down menu, select Mimcmd.exe
- In the Parameter field, enter
message <ICQ#1> <ICQ#2> "Message"
to send Message to the ICQ numbers <ICQ#1> and <ICQ#2>.
For example, enter the following to send PRTG's standard notification to ICQ# 12345678:message 12345678 "[%sitename] %device %name %status %down (%message)"
- Click on Save
- The new notification is now shown in the list of notifications. Click on the Test link to send a test message. It should be visible in the recipient's messenger immediately.
- You can add several notifications by repeating the actions in this step.
- Use a sensor's Notifications tab to add a trigger which uses this newly created notification.
Notes
- Instead of an ICQ number you can also enter other IDs as recipients, depending on the messenger accounts configured in Miranda. For example, you can send a message to an MSN ID (usually this is an email address). Account types can also be mixed in one call, for example you can send the same message to ICQ and MSN:
message 12345678 JohnQPublic@msn.com "[%sitename] %device %name %status %down (%message)"
- Instead of using the messenger account IDs as recipients you can also use the profile names as shown in the Miranda contact list. The message will then be sent to the first contact matching the name. For example, to send a message to an ICQ account shown as "Paessler" in the Miranda contact list, you would type:
message Paessler "[%sitename] %device %name %status %down (%message)"
Known Issues
With the command line tool version used, messages might be sent triple (one per minute), although only triggered once. This is because the command line tool does not give back an exit code 0. You can work around this by creating a batch file calling the command line tool with the respective options, then terminating with
EXIT 0
In PRTG you will then use the batch file instead of the command line tool directly.
Trouble Shooting
If you run into a message Could not create connection with Miranda, this indicates an issue in the communication between miranda32.exe and MimCmd.exe (when executed by PRTG). Please make sure the miranda32.exe and PRTG Server.exe services are running under the same Windows user account (usually, this is SYSTEM). This account must have sufficient rights to execute the necessary files. You might need to reconfigure both services, so they run on a Windows domain account.
(A "Thank you" goes to Jon DeSalvatore for sending this hint!)
See Also
Created on Jan 25, 2011 2:33:43 PM by
Daniel Zobel [Paessler Support]
Last change on May 31, 2017 2:43:58 PM by
Gerald Schoch [Paessler Support]
I have followed this guide and are having problems with it, I am using Windows Server 2012 Standard.
I have checked in TaskManager and made sure that Miranda and PRTG Core are both running as the SYSTEM user.
The error I get from running the Mimcmd.exe is "Error sending "EXE": Error4"
Would anyone have gotten this to work on Windows Server 2012 or have any additional help into getting this setup.
I am sorry, but we did not yet test this with Windows Server 2012. Most likely, this is a permissions issue. Please check the permissions of the mimcmd.exe file and make sure the local Windows "SYSTEM" user account has full access rights.
It is possible to send Telegram messages from PRTG:
This is how we connected Telegram to our PRTG instance.
Install Cygwin64 (https://cygwin.com/)
In the wizard:
Select the whole Dev part
Search for: lua, cygwin32-readline, libreadline-devel, libreadline7, openssl, cygwin32-openssl, libopenssl and select packages you can select
install
- execute the following commands:
mkdir /home/install cd /home/install git clone https://github.com/vysheng/tg.git && cd tg ./configure —disable-libconfig make
- add these paths to the windows paths: C:\CYGWIN64\BIN;C:\CYGWIN64\USR\BIN - create the following scripts in /home/install/tg:
File send.expect
#!/usr/bin/expect
cd /home/install/tg
spawn ./telegram -B
expect "User"
send "msg $argv\r"
expect "Sent:"
send "quit\r"
expect eof
puts "Message has been sent”
File message.sh
#!/bin/bash
cd /home/install/tg
mkdir -p ~/.telegram
cp binlog ~/.telegram/binlog
./send.expect $@
File sendmessage.bat
@echo off
"c:\cygwin64\bin\sh.exe" "/home/install/tg/message.sh" %*
exit 0
- Install PSTools Suite (http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx)
- Execute CMD as SYSTEM: psexec -i -s cmd.exe
- In the command box, execute: c:\cygwin64\home\install\tg\telegram -B
- Login in Telegram with your number.
- Quit.
- Copy sendmessage.bat to the PRTG installation folder\Notifications\EXE.
- Restart PRTG
- Create a notification with this Batch file. The first parameter must be the name of the group or user were you want to send the message to (spaces are converted to underscores).
Please log in or register to enter your reply.
Add comment