Custom command in Nagios not showing up in web gui - nagios

I have a Nagios install and am trying to add check_raid plug in. I have 3 custom cfg files that I added to nagios.cfg called custom-commands.cfg custom-servicegroups.cfg and custom-services.cfg. They live in /usr/local/nagios/etc/objects/ folder. I am not getting any errors but they are not showing up in my web gui so I don't know if they are being performed or not, or their status, etc.
custom-services.cfg looks like:
# service template
define service {
use generic-service
name raid
service_description raid
register 0
normal_check_interval 30
retry_check_interval 5
notification_interval 3600
check_command check_raid
}
custom-servicegroups.cfg looks like:
define servicegroup{
servicegroup_name CUSTOM
alias Custom Checks
}
custom commands looks like:
define command {
command_name check_raid
command_line /usr/lib/nagios/plugins/check_raid $ARG1$
}
I am trying to run the check_raid command on my windows machine in the group windows-servers. I am not getting any errors so I think the config files are good, nagios restarts without any fussing. However the service check_raid is NOT listed on my web interface. Any advice is greatly appreciated. Thanks for your time.

You need to take a look in your nagios.cfg file (located by default at "/usr/local/nagios/etc/nagios.cfg")
At approximately line 30 you will see lines like the following:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
You'll need to add the following lines into your file:
cfg_file=/usr/local/nagios/etc/objects/custom-commands.cfg
cfg_file=/usr/local/nagios/etc/objects/custom-servicegroups.cfg
cfg_file=/usr/local/nagios/etc/objects/custom-services.cfg
Alternatively, around line 50 (depending on your config) you'll see a commented out line like below:
#cfg_dir=/usr/local/nagios/etc/
Uncomment the line and amend it to:
cfg_dir=/usr/local/nagios/etc/objects/
This will always process all .cfg files within that directory so you won't need to add each file individually.

Related

Get shareable link form Mega.nz in command line

I'm trying to work with mega.nz via command line (batch file), use for it megatools
https://github.com/megous/megatools
Sync work fine, download work fine, but i can't found how to generate shareable link to file on mega. Is there any possible way?
May be use Megacmd, or something else?
https://github.com/meganz/MEGAcmd
Can't find command to share file...
put YouUploadFileName
export -a YouUploadFileName
https://github.com/meganz/MEGAcmd/blob/master/UserGuide.md

Nagios alert integration with external tool

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?

Explicitly setting the current directory (pipeline shell)

SHORT: How do I explicitly set the current working directory?
LONG: So I have 52 programs daisy chained together. I have a shell script pipeline that works great. Only problem is I can only run it if I cd into the directory with the files and run it. Some of the sub-programs do not have a mechanism that allows me to explicitly set output directories. They dump everything into the current working directory. This is fine if you are running 1 instance of this pipeline, but not so great if you are trying to process a dozen data-sets one after another. I know I can get the current working directory with:
echo $PWD
But how do I set it?
You can set the current dirctory for individual programs in your pipeline without affecting the other program in your pipeline like this:
PWD=path1 command1 && PWD=path2 command2
In general, you can set any environment variable using that syntax. Here is a real example I tried in bash:
$ PWD=/home ./test.rb && PWD=/ ./test.rb
Running in /home
Running in /

How can i export my event logs to a folder (csv or txt) on every start up automatically?

I was looking for either a batch file, powerscript (not really good with yet)or any way to have my event logs exported to txt or csv on every start up?
Im using windows 7 pro if that helps
This will output last 20 system event logs in eventlog.txt.Not sure what exactly you need from eventlog - it's a big place...
WEVTUtil query-events System /count:20 /rd:true /format:text > eventlog.txt
You can change System to Application,Security or Setup - not sure what exactly you need.
more info:
http://ss64.com/nt/wevtutil.html
check also this:
http://ss64.com/nt/psloglist.html
You can save this (or similar) command to bat file and schedule it on start-up
WEVTUtil query-events System /count:20 /rd:true /format:text > exported_file_name.csv /q:"Event[System[(EventID=1074)]]"
Then gpedit.msc - windows settings - scripts and add to start up.
Thanks #npockmaka for getting this started

how to run CGI script with parameters from console

I've wrote CGI script for www.
This script expects two parameters through GET method, multiply these numbers and write result into the file.
mult.cgi?m=1&n=2
But now I want to use this script from console too.
I'tried something like
./mult.cgi?m=1&n=2
But it didnt work, how can I send parameters to script?
thanks.
QUERY_STRING="m=2&n=4" ./mult.cgi
It acts out like a perl script. (correct me if I'm wrong here)
So if you want to run it via the console:
perl mult.cgi 1 2
as for the parameters, you need to convert it to: $ARGV[1] and $ARGV[2]..
NOTE $ARGV[0] is the cgi script (filename) in this case.
Also, you might be required to put: #!/usr/bin/perl at the very top of the cgi script.
You could try:
telnet hostname 80
GET /path/to/script/mult.cgi?m=1&n=2
Which emulates a port 80 (www) connection to the server and executes the script with given parameters.

Resources