int zbx_module_uninit()
{
    int ret_code = ZBX_MODULE_OK;

    log(LOG_INFO, "Uninitializing...");

    if (!check_if_forked()) {
        goto on_error;
    }

    free_item_list(item_list);
    item_list = NULL;

    if (!call_py_fn_with_int_rc(mod_zabbix.uninit_fn, NULL, &ret_code)) {
        goto on_error;
    }

    if (ret_code == ZBX_MODULE_OK) {
        log(LOG_INFO, "Uninitialization finished successfully");
    } else {
        log(LOG_ERR, "Uninitialization failed");
    }

on_exit:
    unload_objects();
    Py_Finalize();
    unload_python_lib();
    return ret_code;

on_error:
    ret_code = ZBX_MODULE_FAIL;
    goto on_exit;
}
Example #2
0
int agi_deinit() {
	int ec;

	clean_input();		/* remove all words from memory */
	agi_unload_resources();	/* unload resources in memory */
	loader->unload_resource(rLOGIC, 0);
	ec = loader->deinit();
	unload_objects();
	unload_words();

	clear_image_stack();

	return ec;
}
int zbx_module_init()
{
    int ret_code = ZBX_MODULE_OK;

    log(LOG_INFO, "Initializing (zabbix_%s, python %s)...",
            MODULE_TYPE, PY_VERSION);

    if (!set_after_fork_handler()) {
        goto on_error;
    }

    if (!load_python_lib()) {
        goto on_error;
    }

    Py_SetProgramName(program_name);
    Py_Initialize();

    if (!load_objects()) {
        goto on_error;
    }

    if (!set_module_constants()) {
        goto on_error;
    }

    if (!call_init_fn(&ret_code)) {
        goto on_error;
    }

    if (ret_code == ZBX_MODULE_OK) {
        log(LOG_INFO, "Initialization finished successfully");
    } else {
        log(LOG_ERR, "Initialization failed");
    }

on_exit:
    return ret_code;

on_error:
    ret_code = ZBX_MODULE_FAIL;
    unload_objects();
    Py_Finalize();
    unload_python_lib();
    goto on_exit;
}