Trying to make a script in Nagios
Howdy everyone
as the subject already told you, i'm trying to make a script in/for Nagios. This is the first time i'm doing this, so bare with me :) Oke, the goal is that i can check some files/folders on a REMOTE server (which is protected with a login and pass). Now, I already did a ssh-keyswap, so i can connect to the remote server without needing to fill in a login and pass. I've got some examples (Nagios plugins) from a friend, but I've got some questions (consider i'm new to all of this), my friend is a busy man so he doesn't got loads of time: in his code he got something like: Code:
PATH="" what does that progname/progpath do? what does this do (see the BOLD piece) Code:
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'` if someone got any tips for writing a nagios plugin, feel free to share it with me and the rest who's reading this ;) kind regards Brownie EDIT Maybe good to know, i want to use seperated script. I mean that i want to make a control script (which checks the files/folders) and a main script (which copies the control scripts to the remote server and then executes them) |
Hello,
The part of the script you indicate is not 'required'. It's put in place to easily switch paths depending on OS. Throughout the script variables are used instead of the commands. If you need to change the path to a command because you want to execute the script say on AIX instead of Debian, you just change the paths in the variables and your script works on AIX. In Bash $0 is a special variable holding the scripts own name (Advanced Bash Scripting Guide). Quote:
You can easily copy those lines in a script and execute it to see what it does. That makes it easier to understand. Code:
#!/bin/bash Eric |
Thanks for the info !
this is what i got so far Code:
#!/bin/bash Code:
Usage: check_test.sh -d <path> -w <warning> -c <critical> Code:
./check_test.sh: line 57: ssh: No such file or directory |
Okay, this problem is solved...
I put the Code:
PATH="" So what did i do wrong with Code:
PATH="" can someone help? |
Hi,
Open a console and type Code:
echo $PATH Kind regards, Eric |
Code:
echo $PATH okay, now i'm a little bit further. I'm going to show you some code, except some variables because i don't use them (yet) main script Code:
# Exit codes Code:
#!/usr/bin/ksh but all i get is the first echo Code:
echo dit is het subscriptje or is it something else? Also, when i figured out what's the problem, how do i get this variable ($test) send back to the local server (so i can handle this 1 as a result, so i can send a message to someone) thanks in advance Brownie EDIT This is the output btw Code:
test |
ok, now i've got this (so ignore my prev post)
it's only the subscript because the main hasn't changed Code:
#!/usr/bin/ksh Code:
test UPDATE found it ;) Code:
#!/usr/bin/ksh |
up to the next step :hattip:
|
Quote:
Smooth!! You're on a roll buddy :D Keep it up. Kind regards, Eric |
haha :D thx :cool:
|
i'm back with another question ;)
but i also want to say is that when i ask a question, i don't sit and wait for someone to give me the answer, but i also try to find the answer myself (best way to learn anything). it seems that i ask a lot of question, but that's because i'm a rookie compared to most of you guys anyway, everything works, but now i want to SCP a file from the REMOTE server to the LOCAL server, and that's where it goes wrong... subscript: Code:
#!/usr/bin/ksh output Code:
Host key verification failed. where does it go wrong? |
does it have to do anything with this in /etc/ssh/sshd_conf ?
Code:
#RSAAuthentication yes Code:
[root@host .ssh]# ll |
change of plans !
instead of using a file to store my output in, can't i better work with STANDARD OUT (or something like that?) |
All times are GMT -5. The time now is 09:08 AM. |