USERxx variables not usable in action_url and notes_url - nagios

I am using Nagios Core 3.5.0 and I have the following service definition:
service {
...
action_url http://$USER10$/static/html/node.html?node=$USER3$&host=$HOSTADDRESS$
}
The USERxx variables have been set correctly in resource.cfg.
However, the URL that gets generated does not get the value at all for the USER variables but gets the value for HOSTADDRESS.
Is there something that I need to do to all USER variables to be available for the action_url and notes_url?

The USER variables should definitely be available, as per here: Nagios 3.x manual
In fact, we're running Nagios 3.5.1 and have successfully done this to link to pnp4nagios graphs:
define host {
name host-pnp
action_url $USER10$?host=$HOSTNAME$
register 0
}
Have you defined the resource.cfg in your nagios.cfg correctly using something like this?
resource_file=/usr/local/nagios/etc/resource.cfg
My guess is that you've not defined the resource file correctly, so the macros are not being defined.

Related

How to set SAGEMAKER_SUBMIT_DIRECTORY environment variable in sagemaker

I am trying to deploy a model that i have registered. I registered the model using the following code:
step_register = RegisterModel(
name="RegisterCustomModel",
estimator=estimator,
model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
content_types=["text/csv"],
response_types=["text/csv"],
inference_instances=["ml.t2.medium", "ml.m5.large"],
transform_instances=["ml.m5.large"],
model_package_group_name=model_package_group_name,
approval_status=model_approval_status,
model_metrics=model_metrics,
)
However, I am getting an error when i deploy this model which I believe is because the environment variable SAGEMAKER_SUBMIT_DIRECTORY is not set.
My question is, can I set the environment variable SAGEMAKER_SUBMIT_DIRECTORY in the RegisterModel function and if I can, how do I do that?

Options vs Query Parameters in Apache Camel

Apache camel components page have fields under option and query parameters but no clear path position for parameters , from samples I was able to make out they go along options .
I would like to know the difference between options and query parameters.
When an application with Apache Camel starts, it registers the routes in the Camel Context, and once the context is started, components present in from () and to () cannot be modified, for example:
String param = "a = xxxx & y = bbb";
...
to ("http4: //api.xxx.yy?" + stop)
...
It will only be evaluated at startup, so even if the value of the string in the param variable changes, the route will always use a=xxxx&y=bbb as the default since it has already been initialized in the context of Camel (you can see Camel recording the routes in the logs during application startup).
The options can undergo changes not only in construction, depending on the design of the component in question, but can also be exposed for configuration via starters using application.yml or application.properties or via java as in the example below:
application.properties
camel.component.http.http-configuration=br.com.pack.impl.MyHttpConfiguration
In java
HttpConfiguration config = new HttpConfiguration();
config.setProxyAuthMethod("Digest");
config.setProxyAuthUsername("myUser");
config.setProxyAuthPassword("myPassword");
HttpComponent http = context.getComponent("http", HttpComponent.class);
http.setHttpConfiguration(config);
from("direct:start")
.to("http4://www.google.com/search");
I hope it helped to clarify a little more
Options are used to configure Component and Query Parameters are used while creating endpoints.

Get env value to model laravel?

I have problem with date format in laravel model for different operating system (windows & linux) SQL Server
How to get the value from env to model, I create variable in .env for set condition in model when value variable environment 1 = windows and 2 = linux
// 1 FOR WINDOWS
// 2 FOR LINUX SERVER
ENVIRONMENT=1
Any solution / advice for this case?
All variables in your .env files are parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the env() function.
make sure you already execute this command to clear your config after you added that variable to your config.
php artisan config:clear
Retrieving Environment Configuration
<?php
$environment = env("environment", 1)
?>
The second value passed to the env function is the "default value". This value will be used if no environment variable exists for the given key.
see docs here env
in Laravel function env() returns values from .env file.
So if you have ENVIROMENT = 1 in your .env, using env('ENVIRONMENT'), you will get that value.

Get Sencha Touch Platform Name

console.log(Ext.os.Name)
prints the name for OS("Windows"==>in windows machine) for all browser,
But I want to know there is anyway to get the current Platform("chrome","safari","firefox","windows","ios","ios-classic") value based upon the theme currently loaded by sencha.
Because i need configure some of my component based on the browser also.
I dont need Browser name or os name, i need the platform variable used
by sencha framework. like when we using the ios6 it will take the
platform parameter as ios-classic we also pass the platform parameter
in link like http://cdn.sencha.com/touch/sencha-touch-2.3.1a/built-examples/kitchensink/index.html?platform=ios-classic# or
http://cdn.sencha.com/touch/sencha-touch-2.3.1a/built-examples/kitchensink/index.html?platform=windows# this will load the ios6 and windows theme respectively even we use any kind of browser in any OS.
you can use Ext.browser
console.log(Ext.browser.name);
console.log(Ext.browser.version);
Ext.device will not work for browser as it works only for native packing.
you can get what theme is applied by using Ext.theme.name
Ext.theme.name
getting platform for them is not directly provided in Sencha Touch. you can check implementation for that in sencha\app\microloader
I found the following configurations on http://docs-origin.sencha.com/extjs/4.2.2/#!/api/Ext , from that what i have observed is, we can't find the browser's name but we can check whether it is chrome or else like that...
example :
console.log(Ext.isWindows);
true //because i am working in windows
chromeVersion
firefoxVersion
ieVersion
isChrome
isFF10
isFF3_0
isFF3_5
isFF3_6
isFF4
isFF5
isGecko
isGecko10
isGecko3
isGecko4
isGecko5
isIE
isIE10
isIE10m
isIE10p
isIE11
isIE11m
isIE11p
isIE6
isIE7
isIE7m
isIE7p
isIE8
isIE8m
isIE8p
isIE9
isIE9m
isIE9p
isLinux
isMac
isOpera
isOpera10_5
isSafari
isSafari2
isSafari3
isSafari4
isSafari5
isSafari5_0
isWebKit
isWindows
name
operaVersion
safariVersion
In Sencha Touch 2.3 the Ext.device.Device singleton will give you information on the platform and the Ext.device.Browser will give you information on the browser.

how to deal with configuration file in CakePHP

I know that in folder config are file called core.php which I can configure application options as a debug mode, session, cache etc.
But I want do configure file for my application. I want for example configure how many post can be displayed in main page, thubnails size etc.
I think that the best place in config folder but where and when parse thos file in application (bootstrap, AppController another mechanism ?) and what is the best extension .ini or PHP array (for performance reason too). What is the best practice to do this ?
DEFINE OWN CONSTANT FILE
Create a file lets suppose 'site_constants.php' containing some constant variables in app/Config folder. Define the following constants into it:
<?php
define('HTTP_HOST', "http://" . $_SERVER['HTTP_HOST'].'/');
if(HTTP_HOST == 'localhost' || HTTP_HOST == '127.0.0.1')
{
define('SITE_URL', HTTP_HOST.'app_folder_name/');
}
else
{
define('SITE_URL', HTTP_HOST);
}
Include it in app/Config/bootstrap.php
require_once('site_constants.php');
Now you can use it anywhere into your website. And this is also a dynamic.
DEFINE OWN CONFIGURATION FILE
Create a file lets suppose 'my_config.php' containing some constant variables in app/Config folder. Define the constant in the following way:
<?php
$config['PageConfig'] = array('PostPerPage' => 5, 'UserPerPage' => 15);
Then in your app/Controller/AppController.php write the following line in beforeFilter() method:
function beforeFilter()
{
Configure::load('my_config');
}
Now in your controller's method, where you want to access the page number to be listed in your pagination list. You can use it by following code:
$page_config = Configure :: read('PageConfig');
$user_per_page = $page_config['UserPerPage'];
//or
$post_per_page = $page_config['PostPerPage'];
This might looks long process to handle this task, but once done, it will help you in many senses.
Here are the advantages:
you can easily define some more constants (like any file path etc).
you can put all your ajax code into external JS files.
you can directly deploy it onto any server without changing in constants as well as work perfectly onto your localhost.
following standard conventions etc.
CakePHP provides the Configure class for this purpose. See the documentation.
You can use Configure::write($key,$value) in your own config file, and then read the values elsewhere in your application through Configure::read($key). It also allows you to use readers that automate the process and read in external configuration files. CakePHP provides a PHPreader and an INIreader by default and you can create readers to extend it.
Create a new file with configuring variables, like:
Configure::write('Twitter', array(
'consumer_key' => "OTh1sIsY0urC0n5um3rK3Y4T878676",
'consumer_secret' => "OTh1sIsY0ur53cReT76OTIMGjEhiWx94f3LV",
'oauth_access_token' => "12345678-OTh1sIsY0urAcc355K3YT878676Y723n4hqxSyI4",
'oauth_access_token_secret' => "OTh1sIsY0urACC355T0KEnsdjh4T878676FPtRRtjDA29ejYSn"
));
save this file in app/Config/twitter.php
Include that file in app/Config/bootsrap.php:
require_once('twitter.php');
In the Controller (this example 'app/Controller/TwitterController.php'), you can use that like:
$settings = Configure :: read('Twitter');

Resources