Nagios alert integration with external tool - nagios

I'm integrating alerts and events from Nagios to my system. On searching I have found an integration of Moogsoft with Nagios(click). I have followed this, but it was not successful.
In their 'Step 2: Configurations:' they mentioned about 'HOSTNAME',
'BASIC_AUTH' etc. I can't found any of these keys in the respective downloaded file. Can anyone provide clarification or suggest any other solution? Any help would be greatful.

I suspect this is bad documentation.
Both scripts simply echo (slightly formatted) output from Nagios and pipe this to the 'nc' command with the destination host and port number. The 'nc' command does not support HTTP authentication (like for instance 'curl' does), so it makes no sense why those options would be documented. Also, none of the HOSTNAME -to- BASIC_AUTH_PASS variables are ever used in the two shell scripts.
Set recStation to the 'hostname' OR 'ip address' of the Moogsoft server.
Set recPort to the port number the Moogsoft server is listening on.
For example:
recStation="192.168.0.199"
recPort="9000"
And give it a shot.
Note that IF your Moogsoft system does require HTTP authentication, these scripts simply will not work. But it would be a simple matter to create a new shell script that used something like 'curl' to add authentication support.

Check out this link I found.
By the looks of it, you set the variables in the send-host-event.sh and send-service-event.sh files in the following way:
<FIELD>=<value>
So I assume you can place the variables directly after the recStation and recPort declarations.
Try this (change the values between the "<>"):
# Host name, IP and Port should match those set for recStation
HOSTNAME="<hostname/ipaddress:9000>"
BASIC_AUTH=<false/true>
# Only need to set these variables if BASIC_AUTH is set to true
BASIC_AUTH_USER="<auth_username>"
BASIC_AUTH_PASS="<auth_password>"
I hope that helps?

Related

WinSCP "Too many parameters for command 'open'." error

I am trying to connect to an SFTP with the following command to move all .csv files from one location to another and I'm getting the "Too many parameters for command 'open'." error.
option echo off
option batch on
option confirm off
open sftp://XXX#XXX.com/ —hostkey="ssh-rsa 2048 XX:XX:XX:XX:XX:XX:XX" —rawsettings ProxyMethod=3 ProxyHost=proxy.uk.XXX.com
cd /XX/XX/XX/IN/LOAD
lcd \\XX.local\EMEA\XX\XX\Import_Location
put *.csv -nopreservetime=on -nopermissions=on
exit
I added the —hostkey parameter due to the "The server's host key was not found in the cache" error, the batch file was working fine before that, but I want to correct the host key error.
I checked all the dashes, the quotes, the only thing I'm confused about is whether the hostkey parameter is correct. The information online on WinSCP and some forums says you have to use SHA-256 fingerprint of the host key only which is a different format to the MD5 detail XX:XX:XX:XX.... Please can you help which one it is?
—hostkey="ssh-rsa 2048 XX:XX:XX:XX:XX:XX:XX"
OR
—hostkey="ssh-rsa 2056 AbC50IDzyx.....="
This is a similar query to mine, but I cannot see what the difference is so that theirs works and mine doesn't. Thank you.
The symbol you have at the beginning of —hostkey and —rawsettings is not a simple hyphen-minus (-), but em-dash (—).
Please use hyphen-minus (-) – what is the dash that you find on the standard English [and other] keyboards.
Or even easier, have WinSCP GUI generate a script template for you.
So actually you have the very same problem as in WinSCP forum post you referred to.
Other questions with the same error message, but different problem:
WinSCP command line - Too many parameters for command 'open' when using -rawtransfersettings switch
Getting "Too many parameters for command", when calling WinSCP command-line from VBA
FTP "Too many parameters for command 'synchronize'" with WinSCP
Obtaining the correct hostkey fingerprint:
https://winscp.net/eng/docs/faq_hostkey

How do i log things in Cmd? (IP finder)

This is my code. I am making an IP finder, for Fun and practice. I want to log all of the successful IPs on a separate line for each IP. As a note, successful meaning any IPs that I get a reply from.
:ModeB
CLS
Echo AutoMode On
ping %RANDOM:~-2%.%RANDOM:~-3%.%RANDOM:~-3%.%RANDOM:~-3%
goto ModeB
Basically, this will randomly generate numbers within dots and ping it. It does this repeatedly. Most of these IPs will not work, but it will get replies from some of them. I want to log the IPs I get at least one reply from, and then, and only then, will it truly be an IP finder. Any advice for this project will be appreciated.
There is enough bad willed traffic in the internet, there is no need
to be obtrusive.
%Random% generates numbers between 0 .. 32768 see here
an ip octet is 0 .. 255
your approach has the problem that while verifying the success of your ping you have to store the ipaddress, the next invocation of %random% has another random result.
You should read on redirection, for /f to parse the output of a command etc. ss64.com is a good starting point.
And please choose a different learning object-
To start with, there are much more effective ways of scanning lots of ip's to see which are active, such as the free, open source tool nmap.
Using this method to find active hosts will most likely never find any considering the shear amount of possibilities an ip could be.
I'm not entirely sure batch actually has the capabilities to do what you are looking for, so I would recommend looking into other languages. As a recommendation, VB.NET and Python are good places to start.

Using bukhantsov.org command line query output with options

I am trying to use the tool here business objects query builder output
And there are virtually no examples, so I'm struggling to make it work. It produces no errors, but outputs no file in the directory where the batch file is, that I can see.
Here is the code inside querybuilder.bat:
set lib=c:\Program Files\Business Objects\Common\4.0\java\lib
java -cp "querybuilder.jar;poi-3.8-20120326.jar;%lib%\*" org.bukhantsov.querybuilder.Program %*
Here is the code inside what I am running, which I've named RunQuery_ALLACTIVE.bat, except of course with my Server, Username, and Password changed for the purpose of this post.
I have this all on one line, with no line breaks.
querybuilder.bat -cms:SERVER -username:OURUSERNAME -password:OURPASSWORD -query:"SELECT * FROM CI_INFOOBJECTS where SI_SCHEDULE_STATUS = 9 order by SI_NAME" -auth:windowsad -excel "Output.xls"
Can't tell if the - options go on different LINES ?
Can't tell if I'm supposed to put output file in quotes, or if it should be an existing file or not?
can't tell if for Windows AD (which we use), I would put "Windows AD" or WindowsAD, I'm assuming no spaces obviously.
Tons of unanswered questions on this tool - it LOOKS cool, but has anyone actually successfully used it? Can't really find comments or history on the 'net..
To answer your questions:
The options go on the same line, not on different ones
As Joe said, you'll need to specify the output file as -excel:"Output.xls"
If you want to use Windows AD, you'll probably need to specify secWinAD (case-sensitive).
If you're not sure about the command line options, I suggest you build up gradually: first only specify the required options, then add the optional ones one by one so you know which one is giving you problems.
Also, I noticed that the download page contains a version compiled for XI3.x and BI4. Make sure you use the correct version, corresponding to the version of BusinessObjects you're using. Also, verify the path in the batch file to see if it points to a valid folder containing the JAR files for the BusinessObjects environment.
Update:
I just noticed that the same author/developer created another application (GUI, not command line) that might be a bit easier to use. Have a look here.

Multiple commands on Nagios remote host

I have a machine monitored by nagios that has the following line in nrpe.cfg
include_dir=/etc/nagios/cfgs/
The 'cfgs' dir consists of following files with various commands.
servers.cfg
database.cfg
regular.cfg
However, some commands are repeated among these cfg files but they differ in the arguments. Eg: check_disk command on database has different threshold and on servers have different threshold for the same command.
My question is: If there are multiple definitions of a command, which command is picked up by nrpe? Is there some way to identify it?
You generally can not have duplication in command names in your nrpe.cfg files - though no error is thrown if there are duplicates. I've had this happen before (accidentally) with very large configs, and nrpd has always chosen to use the very LAST matching command it found. In my case, being a single config file, it was always easy to spot the LAST matching command in the file. With many included files, this could be an issue. I believe it would load these files in alphabetical order with the include_dir command you provided.
In any case, I'd look for more unique names for these duplicates. Such as 'check_disk_db' for the one checking database disks. These names can be just about anything you want them to be - but remember to change them on the Nagios side as well. Using unique command names would make your life as a Nagios admin much easier.
As far as figuring out which is actually being used. You can turn on debugging. The debugging output doesn't include the file the command came from, but does show you what options were passed and exactly which actual commands where executed via the check command. This info should be enough to see which nrpe command was selected.

if-then batch to map drives

I am trying to get a couple scripts to work with each other, but I am not entirely familiar with the if-then commands, I am using wizapp and I have my info ready to go, but I don't know how to map a specific location based on the output of wizapp, as a for instance
if %siteid%=="0"
How do I map that to a drive, I have 10 different drives that have to be mapped using that
info, and I am lost, siteid will obviously be different in each if then statement?
This is relatively easy to do. I will provide manual instructions as it is extremely useful to learn and will improve your coding skills.
C:\windows\system32> net view
Server Name Remark
---------------------------------------------------------------------------------
\\PC1
\\PC2
\\PC3
\\PC4
\\PC5
\\PC6
\\PC7
\\PC8
\\PC9
\\SERVER
The command completed successfully.
C:\windows\system32> net view \\PC1
Shared resources at \\PC1
Share name Type Used as Comment
-------------------------------------------------------------------------------
SharedDocs Disk
The command completed successfully.
C:\windows\system32> net use ( Drive letter A-Z ) \\PC1\SharedDocs
The command completed successfully.
Now open up My Computer and youll see that PC1 is registered as a drive onto your computer.

Resources