Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Ok I'll bite... why? Why do you need spaces in the hostname macro?
If you enter it as $ HOSTNAME $ it's obviously not going to translate the macro into a hostname because whitespace is a string delimiter, if you put the spaces in and single quotes it's only going to pass the literal string "$ HOSTNAME $" otherwise it's just going to pass "$" which basically means invalid macro.
Explain what you are trying to accomplish and we can probably come up with a better solution
The sms vendor have to follow some certain rules .They pushed me to make a space in between the macro, before i was getting sms without any issues( they were no spaces in the macro) now nagios cant read the macro at all its just simply throwing the NOTIFICATIONTYPE blah blah....
I knew that changing the macro nagios will get confused, Is there any way i can send the message by giving spaces in between the macro.
Please guide me how to do that at the same time i will try also
I'm having a hard time thinking of any rule that would dictate the syntax of Nagios config files. They literally should not be able to tell the difference between there being spaces or not. You said it was working fine before, so unless I'm missing something, just get rid of the spaces again.
I think you've got a slight misunderstanding as to how the macros function and why it's failing.
The macro text ($HOSTNAME$) will never ever leave the internal nagios processing engine... it will never reach your SMS gateway provider, however if you enter $ HOSTNAME $ then nagios does not translate it and passes that text string to your provider. So suppose you were to get $ HOSTNAME $ to translate, it would work exactly the same as it does now without putting the spaces, that is to say: it won't work at all.
The issue is that whatever text your macros are translating into is causing your provider to be unable to deliver the message, are there any special characters in your hosts or services? Can you echo the command you are trying to execute to a file so you can see the exact message you are trying to send to them? Is it a managed service, are you able to work with them to work out why certain messages are not allowed to pass through their system?
The problem here is the message; we need to work out if it's a problem on your side or the provider side, it's not the macro translation that is the issue.
I totally agree with you!! its nothing to do with the macro the problem is they system wont accept $HOSTNAME$ they are asking me to put space on the macro $ HOSTNAME $
but this will never work with nagios.
Is there any way i can translate the $ HOSTNAME $ to $HOSTNAME$ ? Or a any script will translate this
The problem might be that the macros are not URL encoded, but you're inserting them into a URL. Try using curl instead of wget, which can perform the URL-encoding for you. For example:
No. Again, you have misunderstood the problem. Even if inserting spaces in the macro names worked like you expected (which would be extremely difficult to do, and would involve extensive modification of Nagios' code), SMS notifications would still not work for you. Please re-read jsmurphy's explanation above if you do not understand why. Rather than focusing on what you think the solution is, I am trying to focus on the actual problem of not being able to send notifications.
Please try using the command definition I posted above without modifications and let me know how it goes.
You've obviously been in contact with your SMS provider about this. If the above does not work, then it would help if you posted part of your exchange with them that included their advice and rationale for inserting spaces in the macro, as well as the "rules" you mentioned that must be followed. There was probably some miscommunication there that resulted in your insistence on putting spaces where they don't belong.