This won't work.
Nagios class is used only on the nagios server, nagios::target (used on all the monitored nodes) can't use variables defined in the main nagios class. That's one of the reasons why here are used some (questionable) top scope variables.