I have a function in my_sup.erl like this:
init([ems_media_sup]) ->
{ok, {{simple_one_for_one, ?MAX_RESTART, ?MAX_TIME}, [
{ems_media_sup, {ems_media, start_link, []}, temporary, 2000, worker, [ems_media]}]
}};
But there is no function named start_link/1 in ems_media.erl, I want to know why there is no error when run
supervisor:start_link(?MODULE, [ems_media_sup])
So, How to know what happened next after call init([ems_media_sup])
That's because my_sup is of type simple_one_for_one - so it will only start child processes when explicitly asked to do so through supervisor:start_child/2.
If the supervisor had been of any other type (one_for_one, one_for_all or rest_for_one) it would have attempted to start all children in the child specification at startup, but a simple_one_for_one supervisor is for creating large numbers of children that only vary by their argument list, so in that case the child specification in the init function only plays the role of a template.
Related
I am trying two run two tests on a single Test Class in Laravel dusk. It passes when ran individually but fails when ran as part of a suite.
Here, my first test passes, but second test is failing.
Exception looks like:
There was 1 error:
1) Tests\Browser\Front\JobApplyTest::jobseeker_can_apply_to_a_job
Illuminate\Contracts\Container\BindingResolutionException: Target class [env] does not exist.
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:879
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:758
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:851
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:694
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:836
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:1423
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:571
/home/ellite/code/labs/jagirhouse/app/Core/Providers/TelescopeServiceProvider.php:26
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php:60
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php:60
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php:279
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php:61
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Telescope.php:323
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Telescope.php:281
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Telescope.php:330
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Telescope.php:475
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Watchers/QueryWatcher.php:48
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:404
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:249
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Connection.php:887
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Connection.php:728
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Connection.php:683
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Connection.php:502
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:109
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:364
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:227
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/home/ellite/code/labs/jagirhouse/database/migrations/2014_10_12_000000_create_users_table.php:46
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:394
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:403
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:202
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:167
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:85
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:585
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:94
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Command/Command.php:298
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php:68
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php:28
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:55
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Command/Command.php:298
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Application.php:1005
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Application.php:299
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Application.php:171
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Application.php:94
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Application.php:186
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:260
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:413
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:66
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseMigrations.php:19
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:126
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:91
/home/ellite/code/labs/jagirhouse/vendor/laravel/dusk/src/TestCase.php:23
Caused by
ReflectionException: Class "env" does not exist
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:877
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:758
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:851
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:694
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:836
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:1423
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:571
/home/ellite/code/labs/jagirhouse/app/Core/Providers/TelescopeServiceProvider.php:26
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php:60
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php:60
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php:279
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php:61
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Telescope.php:323
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Telescope.php:281
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Telescope.php:330
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Telescope.php:475
/home/ellite/code/labs/jagirhouse/vendor/laravel/telescope/src/Watchers/QueryWatcher.php:48
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:404
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:249
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Connection.php:887
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Connection.php:728
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Connection.php:683
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Connection.php:502
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:109
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:364
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:227
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/home/ellite/code/labs/jagirhouse/database/migrations/2014_10_12_000000_create_users_table.php:46
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:394
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:403
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:202
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:167
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:85
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:585
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:94
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Command/Command.php:298
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php:68
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php:28
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:55
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Command/Command.php:298
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Application.php:1005
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Application.php:299
/home/ellite/code/labs/jagirhouse/vendor/symfony/console/Application.php:171
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Application.php:94
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Console/Application.php:186
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:260
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:413
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:66
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseMigrations.php:19
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:126
/home/ellite/code/labs/jagirhouse/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:91
/home/ellite/code/labs/jagirhouse/vendor/laravel/dusk/src/TestCase.php:23
Automated tests are supposed to be side-effect free. That means well-designed tests should be possible to execute in any order and still receive the same results per test.
So when you have a test which passes or fails depending on other tests, then your tests are not properly isolated.
Find out what pre-conditions a test assumes (like specific data being in a specific database table or specific global variables hold a specific value) and ensure that your pre-conditions are fulfilled before the actual test is performed.
I want to get the current restart policy of an AppServer (RUNNING, STOPPED or PREVIOUS) using Jython.
servers = AdminTask.listServers('[-serverType APPLICATION_SERVER]').splitlines()
for server in servers:
print server
print AdminConfig.showAttribute(server, "monitoringPolicy")
break
This gave me an exception that the attribute is invalid:
An exception occurred when executing the file "test.py". Information
about the exception: com.ibm.ws.scripting.ScriptingException:
WASX7080E: Invalid attributes for type "Server" -- "monitoringPolicy".
But I could get the attribute using print AdminConfig.showall(server):
...
[monitoringPolicy [[autoRestart true]
[maximumStartupAttempts 3]
[nodeRestartState STOPPED]
[pingInterval 60]
[pingTimeout 300]]]
...
For me it looks like monitoringPolicy is the key of an array, so that it should be possible to get the restart state with
policy = AdminConfig.showAttribute(server, "monitoringPolicy")
restartState = policy["restartState"] # Should be "STOPPED"
Where is the problem?
Edit
After taking a deeper look in the list output, I saw that I missed a top level property processDefinitions, which is the parent of monitoringPolicy.
pd = AdminConfig.showAttribute(server, "processDefinitions")
print pd
This prints:
[(cells/CnxCell/nodes/CnxNode01/servers/UtilCluster_server1|server.xml#JavaProcessDef_1578492353152)]
But I'm not able to get any of the child propertys from this object:
# TypeError: sequence subscript must be integer or slice
print pd["monitoringPolicy"]
# AttributeError: 'string' object has no attribute 'monitoringPolicy'
print pd.monitoringPolicy
MonitoringPolicy has his own type. This prints the server and the state, so 'RUNNING', 'STOPPED'
servers = AdminTask.listServers('[-serverType APPLICATION_SERVER]').splitlines()
for server in servers:
print(server)
mpol = AdminConfig.list("MonitoringPolicy", server)
print(AdminConfig.showAttribute(mpol, 'nodeRestartState'))
I am not sure of the behaviour of error messages in Substrate runtimes in relation to Substrate UI, and if they inherently cause a transaction failure or not.
For example in the democracy SRML I see the following line:
ensure!(!<Cancellations<T>>::exists(h), "cannot cancel the same proposal twice");
Which presumably is a macro that ensures that the transaction fails or stops processing if the h (the proposal hash) already exists. There is clearly a message associated with this error.
Am I right to assume that the transaction fails (without the rest of the SRML code being executed) when this test fails?
If so, how do I detect the failure in Substrate UI, and possibly see the message itself?
If not, then presumably some further code is necessary in the runtime module which explicitly creates an error. I have seen Err() - but not in conjunction with ensure!()
As https://github.com/paritytech/substrate/pull/3433 is merged, the ExtrinsicFailed event now includes a DispatchError, which will provide additional error code.
There isn't much documentations available so I will just use system module as example.
First you need to decl_error, note the error variants can only be simple C like enum
https://github.com/paritytech/substrate/blob/5420de3face1349a97eb954ae71c5b0b940c31de/srml/system/src/lib.rs#L334
decl_error! {
/// Error for the System module
pub enum Error {
BadSignature,
BlockFull,
RequireSignedOrigin,
RequireRootOrigin,
RequireNoOrigin,
}
}
Then you need to associate the declared Error type
https://github.com/paritytech/substrate/blob/5420de3face1349a97eb954ae71c5b0b940c31de/srml/system/src/lib.rs#L253
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
type Error = Error;
Then you can just return your Error in dispatch calls when things failed
https://github.com/paritytech/substrate/blob/5420de3face1349a97eb954ae71c5b0b940c31de/srml/system/src/lib.rs#L543
pub fn ensure_root<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<(), Error>
where OuterOrigin: Into<Result<RawOrigin<AccountId>, OuterOrigin>>
{
match o.into() {
Ok(RawOrigin::Root) => Ok(()),
_ => Err(Error::RequireRootOrigin),
}
}
Right now you will only able to see a two numbers, module index and error code from JS side. Later there could be support to include the error details in metadata so that frontend will be able to provide a better response.
Related issue:
https://github.com/paritytech/substrate/issues/2954
The ensure! macro is expaneded as:
#[macro_export]
macro_rules! fail {
( $y:expr ) => {{
return Err($y);
}}
}
#[macro_export]
macro_rules! ensure {
( $x:expr, $y:expr ) => {{
if !$x {
$crate::fail!($y);
}
}}
}
So basically, it's just a quicker way to return Err. At 1.0, the error msg will only be printed to stdout(at least what I've tested so far), doesn't know if it'll be included in blockchain in the future(so can be viewed in substrate ui)..
Can anybody please explain the working of the below code.
"def lambda_handlerOut(event, context):
if len(event) > 0:
success=1
print("length of event outside for--"+str(len(event)))
for record in event['Records']:
print("length of event--"+str(len(event)))
bucket=record['s3']['bucket']['name']
key=record['s3']['object']['key']
print("Bucket--"+bucket)
print("File that triggered this event--"+key)
Thanks in advance.
Regards,
Eleena Jose
This is a Lambda that receives S3 events - for example a PutObject request that creates a new file.
The method is the standard Python function - take a look at the Lambda Function Handler Docs for more details.
The structure of the event is defined here but basically there are some number of Records that are being iterated through with and, for each record, the bucket and key are being extracted and printed.
So, in more detail (comments above the line they reference):
# standard lambda event handler definition
def lambda_handlerOut(event, context):
# make sure that something was given - likely unneeded
if len(event) > 0:
success=1
print("length of event outside for--"+str(len(event)))
# loop through each record in Records
for record in event['Records']:
print("length of event--"+str(len(event)))
# take a look at the event structure - just extracting parts
bucket=record['s3']['bucket']['name']
# key is the object name - that is, the file
key=record['s3']['object']['key']
print("Bucket--"+bucket)
print("File that triggered this event--"+key)
EDIT
As I linked to above, the data in the event object looks something like:
{
"Records":[
{
"eventVersion":"2.0",
"eventSource":"aws:s3",
"awsRegion":"us-east-1",
"eventTime":"1970-01-01T00:00:00.000Z",
"eventName":"ObjectCreated:Put",
"userIdentity":{
"principalId":"AIDAJDPLRKLG7UEXAMPLE"
},
"requestParameters":{
"sourceIPAddress":"127.0.0.1"
},
"responseElements":{
"x-amz-request-id":"C3D13FE58DE4C810",
"x-amz-id-2":"FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD"
},
"s3":{
"s3SchemaVersion":"1.0",
"configurationId":"testConfigRule",
"bucket":{
"name":"mybucket",
"ownerIdentity":{
"principalId":"A3NL1KOZZKExample"
},
"arn":"arn:aws:s3:::mybucket"
},
"object":{
"key":"HappyFace.jpg",
"size":1024,
"eTag":"d41d8cd98f00b204e9800998ecf8427e",
"versionId":"096fKKXTRTtl3on89fVO.nfljtsv6qko",
"sequencer":"0055AED6DCD90281E5"
}
}
}
]
}
So, as an example, bucket=record['s3']['bucket']['name'] starts by getting the s3 record from the data which leaves:
"s3":{
"s3SchemaVersion":"1.0",
"configurationId":"testConfigRule",
"bucket":{
"name":"mybucket",
"ownerIdentity":{
"principalId":"A3NL1KOZZKExample"
},
"arn":"arn:aws:s3:::mybucket"
},
"object":{
"key":"HappyFace.jpg",
"size":1024,
"eTag":"d41d8cd98f00b204e9800998ecf8427e",
"versionId":"096fKKXTRTtl3on89fVO.nfljtsv6qko",
"sequencer":"0055AED6DCD90281E5"
}
}
From there, it gets the bucket stanza:
"bucket":{
"name":"mybucket",
"ownerIdentity":{
"principalId":"A3NL1KOZZKExample"
},
"arn":"arn:aws:s3:::mybucket"
}
and lastly, the name:
"name":"mybucket"
This is assigned to the variable bucket which is printed out later. The key (which is the file name in this example) works the same way but gets different parts of the event.
Does that make sense now?
I created my own bash script for notify-service-by-email. Problem is that every time alert is triggered, nagios runs this script exactly 4 times instead of once.
I'm running nagios 3.5.1-1 on Red Hat 6.4
commands.cfg
define command{
command_name notify-service-by-email
command_line /home/nagios/scripts/notify_by_email/notify.bash "$NOTIFICATIONTYPE$" "$SERVICEDESC$" "$HOSTNAME$" "$SERVICESTATE$" "$LONGDATETIME$" "$SERVICEOUTPUT$" "$CONTACTEMAIL$"
}
When I ran script manually from command line, it ran once - so it's not loop in the script.
I tried to search for suspicious entry in the main config file, but with no success.
nagios.cfg
log_file=/var/log/nagios/nagios.log
cfg_file=/etc/nagios/objects/commands.cfg
cfg_file=/etc/nagios/objects/commands_manual.cfg
cfg_file=/etc/nagios/objects/contacts.cfg
cfg_file=/etc/nagios/objects/timeperiods.cfg
cfg_file=/etc/nagios/objects/templates.cfg
cfg_file=/etc/nagios/objects/services_prod.cfg
cfg_file=/etc/nagios/objects/services_uat.cfg
cfg_file=/etc/nagios/objects/services_actimize.cfg
cfg_dir=/etc/nagios/servers
cfg_dir=/etc/nagios/objects/SC4
object_cache_file=/var/log/nagios/objects.cache
precached_object_file=/var/log/nagios/objects.precache
resource_file=/etc/nagios/private/resource.cfg
status_file=/var/log/nagios/status.dat
status_update_interval=10
nagios_user=nagios
nagios_group=nagios
check_external_commands=1
command_check_interval=-1
command_file=/var/spool/nagios/cmd/nagios.cmd
external_command_buffer_slots=4096
lock_file=/var/run/nagios.pid
temp_file=/var/log/nagios/nagios.tmp
temp_path=/tmp
event_broker_options=-1
log_rotation_method=d
log_archive_path=/var/log/nagios/archives
use_syslog=1
log_notifications=1
log_service_retries=1
log_host_retries=1
log_event_handlers=1
log_initial_states=0
log_external_commands=1
log_passive_checks=1
service_inter_check_delay_method=s
max_service_check_spread=30
service_interleave_factor=s
host_inter_check_delay_method=s
max_host_check_spread=30
max_concurrent_checks=0
check_result_reaper_frequency=10
max_check_result_reaper_time=30
check_result_path=/var/log/nagios/spool/checkresults
max_check_result_file_age=3600
cached_host_check_horizon=15
cached_service_check_horizon=15
enable_predictive_host_dependency_checks=1
enable_predictive_service_dependency_checks=1
soft_state_dependencies=0
auto_reschedule_checks=0
auto_rescheduling_interval=30
auto_rescheduling_window=180
sleep_time=0.25
service_check_timeout=60
host_check_timeout=30
event_handler_timeout=30
notification_timeout=30
ocsp_timeout=5
perfdata_timeout=5
retain_state_information=1
state_retention_file=/var/log/nagios/retention.dat
retention_update_interval=60
use_retained_program_state=1
use_retained_scheduling_info=1
retained_host_attribute_mask=0
retained_service_attribute_mask=0
retained_process_host_attribute_mask=0
retained_process_service_attribute_mask=0
retained_contact_host_attribute_mask=0
retained_contact_service_attribute_mask=0
interval_length=60
check_for_updates=1
bare_update_check=0
use_aggressive_host_checking=0
execute_service_checks=1
accept_passive_service_checks=1
execute_host_checks=1
accept_passive_host_checks=1
enable_notifications=1
enable_event_handlers=1
process_performance_data=1
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tHOSTOUTPUT::$HOSTOUTPUT$
service_perfdata_file_template=HOSTNAME:$HOSTNAME$:\tTIME:$DATE$ $TIME$:\tSERVICEDESC:$SERVICEDESC$:\tSERVICEPERFDATA:$SERVICEPERFDATA$:\tSERVICEOUTPUT:$SERVICEOUTPUT$:
host_perfdata_file_mode=a
service_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
service_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
service_perfdata_file_processing_command=process-service-perfdata-file
obsess_over_services=0
obsess_over_hosts=0
translate_passive_host_checks=0
passive_host_checks_are_soft=0
check_for_orphaned_services=1
check_for_orphaned_hosts=1
check_service_freshness=1
service_freshness_check_interval=60
service_check_timeout_state=c
check_host_freshness=0
host_freshness_check_interval=60
additional_freshness_latency=15
enable_flap_detection=1
low_service_flap_threshold=5.0
high_service_flap_threshold=20.0
low_host_flap_threshold=5.0
high_host_flap_threshold=20.0
date_format=us
p1_file=/usr/sbin/p1.pl
enable_embedded_perl=1
use_embedded_perl_implicitly=1
illegal_object_name_chars=`~!$%^&*|'"<>?,()=
illegal_macro_output_chars=`~$&|'"<>
use_regexp_matching=0
use_true_regexp_matching=0
admin_email=super#secret
admin_pager=super#secret
daemon_dumps_core=0
use_large_installation_tweaks=1
enable_environment_macros=1
debug_level=0
debug_verbosity=1
debug_file=/var/log/nagios/nagios.debug
max_debug_file_size=1000000
Have you encountered similar issue? What else should I check?
Nagios executes command notify-service-by-email for every single defined contact. In my case I have 4 contacts (e-mails) in the contact group. After I defined singe e-mail address, my problem was resolved.