Illegal characters not allowed

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Illegal characters not allowed

Post by Box293 »

Do you have it documented anywhere what characters are not allowed to be used in the name and description fields?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Illegal characters not allowed

Post by mmestnik »

Yes, though it took some looking.
http://nagios.sourceforge.net/docs/3_0/ ... ml#service
Service wrote:service_description;: This directive is used to define the description of the service, which may contain spaces, dashes, and colons (semicolons, apostrophes, and quotation marks should be avoided). No two services associated with the same host can have the same description. Services are uniquely identified with their host_name and service_description directives.
It's never a bad idea to just assume that the allowed chars are: A–Z, a–z, and 0–9. This offers 62 uniq digits or base62, using just these you should be able to express quite a bit with little effort.

One thing to also avoid is '$', unless you intend to access a macro.
kquinby
Posts: 5
Joined: Mon Apr 12, 2010 3:25 pm

Re: Illegal characters not allowed

Post by kquinby »

What do you do if a service name you are checking contains a "$"

SQL 2005 and above services use this for named instances. mssql$instancename

Is there an escape character we can use in the check string?
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Illegal characters not allowed

Post by mmestnik »

If there is an easy way, it's not documented. The writer of the check command should have some idea how to do this. If I was writing a check I'd replace some other char for '$', like '~' as in 's/~/$/g'.

I would try '\$' and other unix/windows like escapes.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Illegal characters not allowed

Post by Box293 »

Thanks for this mmestnik :D
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
kquinby
Posts: 5
Joined: Mon Apr 12, 2010 3:25 pm

Re: Illegal characters not allowed

Post by kquinby »

I did find the answer in the other forum. Either put the service name in single quotes with an escape $ 'mssql$$instancename' which I confirmed worked, or without quote as with a \
mssql\$$instancename
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Illegal characters not allowed

Post by mmestnik »

So $$ passes as a $, the null/blank macro(this I did not know). After that you'd need the '\' or '''(s) to escape the '$' from shell expansion.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Illegal characters not allowed

Post by Box293 »

For anyone interested, after looking at some code I was able to find the following.
if (form.tfName.value.match(/[^a-zA-Z0-9 .\:_-]/))

I assume that these are the values allowed, anything else is illegal.
/[^a-zA-Z0-9 .\:_-]/
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Illegal characters not allowed

Post by mmestnik »

So rather all of these:

Code: Select all

for ech in {0,1,2}{0,1,2,3,4,5,6,7}{0,1,2,3,4,5,6,7}; do echo -e '\0'$ech; done | grep -a '[a-zA-Z0-9 .:_-]' | tr -d '\n' | hexdump -C
00000000  20 2d 2e 30 31 32 33 34  35 36 37 38 39 3a 41 42  | -.0123456789:AB|
00000010  43 44 45 46 47 48 49 4a  4b 4c 4d 4e 4f 50 51 52  |CDEFGHIJKLMNOPQR|
00000020  53 54 55 56 57 58 59 5a  5f 61 62 63 64 65 66 67  |STUVWXYZ_abcdefg|
00000030  68 69 6a 6b 6c 6d 6e 6f  70 71 72 73 74 75 76 77  |hijklmnopqrstuvw|
00000040  78 79 7a                                          |xyz|
00000043
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Illegal characters not allowed

Post by Box293 »

Awesome, thats a nice bit of code btw :mrgreen:
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked