Shinken Monitoring : How to set timeout for a service check explicitly? - nagios

From the shinken.cfg this values can be set..,
service_check_timeout=60
timeout_exit_status=3
But as it is getting applied globally for all the service checks..,
Is it possible to have service specific timeout and timeout_exit_status..?

Follow this link
Timeout can be set at the command level

Related

build mode - activate logs with a certain level

I'm using QX 5.0.2.
In Build mode, is there a way to (re)activate logs and only show warning+error (log level?)?
Env key 'qx.debug' = true seems to reactivate logs but I can't find the env key for log level (to set it for example to warning).
Thanks in advance.
I think what you're looking for is the static addFilter method, documented at http://www.qooxdoo.org/devel/api/#qx.log.Logger. It lets you filter messages by the class from which they originate, by log level, and on an all-appenders basis or per appender.
Derrell

Watson Assistant V2 API: change session timeout

Using the Watson Assistant V2 API it is necessary to create a session handle first (create_session(assistantid)) which returns the session ID to use in the individual call to message(assistantid,sessionid,request). The session maintains the conversation state and therefore is the equivalent to the context id parameter of the V1 API.
Unfortunately it seems that there's a 5 minute session timeout by default. The response includes the following header attribute:
{...,"x-watson-session-timeout": [
"x-watson-session-timeout",
"session_timeout=300"
],...}
Any attempt to change this parameter by using the set_default_headers() method of the assistant object or by adding the optional header parameter to the create_session() call seems to have no effect. As I have not found any documentation of how to update this parameter correctly I just tried several alternatives:
1) self.assistant.set_default_headers({'x-watson-session-timeout':"['x-watson-session-timeout','session_timeout=3600']"})
2) self.assistant.set_default_headers({'x-watson-session-timeout':"'x-watson-session-timeout','session_timeout=3600'"})
3)self.assistant.set_default_headers({'x-watson-session-timeout':"session_timeout=3600"})
4)self.assistant.set_default_headers({'x-watson-session-timeout':"3600"})
5)self.assistant.set_default_headers({'session_timeout':"3600"})
Nothing is effective. The value of the parameter in the header of the response is still 300.
Do I use incorrect dict pairs to update the parameter? Is there another way to maintain the conversation state longer than 5 minutes using the V2 API? Is it not possible to change it at all?
The value of the session timeout is not under the control of the caller, and is in fact related to the Assistant plan you are using. For the free and standard the timeout is indeed 5 minutes. For the other plans the timeout is larger.
See Retaining information across dialog turns
The current session lasts for as long a user interacts with the assistant, and then up to 60 minutes of inactivity for Plus or Premium plans (5 minutes for Lite or Standard plans).
You can call watson assistant for an other session and resend your message. Keep your context...
Or just increase timeout limit in assistant setting on IBM Cloud with the right plan.
function createSession(end) {
assistant.createSession({
assistantId: watsonID }).then(res => {
sessionId=res.result.session_id;
if(end){
console.log("\x1b[32m%s\x1b[0m","new session "+sessionId);
}else{
console.log("session id :"+ sessionId);
console.log("http://"+host+":"+port);
}
});
}
createSession();
function callWatsonClient(payload,res) {
assistant.message(payload,function(err, data) {
if(data == null){
createSession(true);
//this not keep the context
var data ={result:{context:"",output:{generic:[{text:"session expirée, renvoyez le message"}]}}};
res.send(data);
}else{
//normal job
console.log("\x1b[33m%s\x1b[0m" ,JSON.stringify(data.result.output));
}

EC2 Windows User Data: Script does not run as expected

I need run my custom script when new instance initiated. Minimum instance configuration is 2 so that i always have 2 instance running.
I did the following steps to configure and check the user data;
Create an AMI of one of the instance say instance1.
Copy Launch configuration from the existing one and change the AMI to the new one i created.
In the advanced details, user data i pasted the following scripts as a sample
<script>
echo Current date and time >> %SystemRoot%\Temp\test.log
echo %DATE% %TIME% >> %SystemRoot%\Temp\test.log
</script>
I update the launch configuration of auto scaling group to the new one
I terminate another instance which i didn't took AMI so that new instance automatically initiated and my user data need to be executed
After initiated, i go to the remote desktop and check the %SystemRoot%\Temp path, but test.log not created.
So i verified the log as specified in the aws document and find the following log
2018/06/07 00:21:01Z: Userdata execution begins
2018/06/07 00:21:01Z: Zero or more than one <persist> tag was not provided
2018/06/07 00:21:01Z: Unregistering the persist scheduled task
2018/06/07 00:21:03Z: Zero or more than one <runAsLocalSystem> tag was not provided
2018/06/07 00:21:03Z: Zero or more than one <script> tag was not provided
2018/06/07 00:21:03Z: Zero or more than one <powershellArguments> tag was not provided
2018/06/07 00:21:03Z: <powershell> tag was provided.. running powershell content
2018/06/08 09:41:39Z: Userdata execution begins
2018/06/08 09:41:39Z: Failed to get metadata: The result from http://169.254.169.254/latest/user-data was empty
2018/06/08 09:41:44Z: Unable to execute userdata: Userdata was not provided
2018/06/08 09:41:44Z: Userdata execution done
2018/06/08 10:26:28Z: Userdata execution begins
2018/06/08 10:26:28Z: Failed to get metadata: The result from http://169.254.169.254/latest/user-data was empty
2018/06/08 10:26:32Z: Unable to execute userdata: Userdata was not provided
2018/06/08 10:26:32Z: Userdata execution done
Can anyone help me where i missed?

How to fix a AutomaticUrlReservationCreationFailureException when using Nancy FX Self Host

When using Nancy FX, I came across the following exception which was thrown when trying to fire up a web service: AutomaticUrlReservationCreationFailureException
Having looked into it in a bit more detail, I discovered that the way to fix this was to run up a cmd prompt (as an administrator), then run the following command:
netsh http add urlacl url=http://+:1234/ user=DOMAIN\username
where
DOMAIN\username is the id of the user the service will be run under
1234 is the port that the service will be run on
I write this here in case anyone else comes across the same issue and spends a fruitless half hour or so looking for an answer - hopefully they will find this sooner than I did!
If you're creating your own NancyFx host, it may be easier for you to flag your HostConfiguration this way
HostConfiguration hostConfigs = new HostConfiguration()
{
UrlReservations = new UrlReservations() { CreateAutomatically = true }
};
or...
HostConfiguration hostConfigs = new HostConfiguration();
hostConfigs.UrlReservations.CreateAutomatically = true;
And then finally have something like
NancyHost nancyHost = new NancyHost(new Uri("http://+:80"), new DefaultNancyBootstrapper(), hostConfigs);
The Message of the AutomaticUrlReservationCreationFailureException will tell you this
The Nancy self host was unable to start, as no namespace reservation existed for the provided url(s).
Please either enable CreateNamespaceReservations on the HostConfiguration provided to the NancyHost, or create the reservations manually with the (elevated) command(s):
http add urlacl url=http://+:8888/nancy/ user=Everyone
http add urlacl url=http://127.0.0.1:8888/nancy/ user=Everyone
http add urlacl url=http://+:8889/nancytoo/ user=Everyone
The suggested reservations is based on the base URIs that you pass into the host when you create it.
The AutomaticUrlReservationCreationFailureException will also appear if you are running NancyFX from Visual Studio.
So make sure you are running as administrator in order for NancyFX to set up the underlying configurations

How to set http header If-Modified-Since on a WebRequest in Windows Phone 7?

Trying to set the 'If-Modified-Since' header in wp7:
request.Headers[HttpRequestHeader.IfModifiedSince] = dateString;
Gives the error:
This header must be modified with the appropriate property.
Which means that the property .IsModifiedSince should be used on the request class, as described in MSDN: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.ifmodifiedsince.aspx
But this property does not exist in Silverlight i.e. WP7.
Has anyone been able to set this header for a http request on Windows Phone 7?
Shawn Wildermuth posted this problem back in September 2010, with no solution:
http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/8aec7481-2cf3-4047-b0d4-05d4313a9e4c
Thank you!
You can just use the string that HttpRequestHeader.IfModifiedSince represents:
request.Headers["If-Modified-Since"] = dateString;
I've had to do this with a number of other headers which WP7 doesn't expose helper methods for setting.
Update
Based on the remarks at http://msdn.microsoft.com/en-us/library/8y7x3zz2(v=VS.95).aspx it would appear that it is not possible to set this header in WP7.
As an alternative you could create your own proxy server to handle the caching for your app.
This can only be set on the HTTPWebRequest object so casting the WebRequest should allow you to set the property eg:
((HttpWebRequest)request).IfModifiedSince = modifiedDate;
It takes a DateTime object so you may need to parse the string first.
The short answer is: It cannot be done, not supported.
Solution would be, as Matt Lacey states, to create a proxy class to handle this.
That proxy would set
request.AllowStreamReadBuffering = false;
and then parse the response until the header ends or the header value has been found.
Note! This workaround limits the data downloaded to the phone, but not the work needed by the server to process the request.
request.Headers.Add("If-Modified-Since", datestring);

Resources