OpenVAS Scanner 23.40.3
heartbeat.c File Reference

Function for heartbeat. More...

#include "../misc/heartbeat.h"
#include "../misc/plugutils.h"
#include <gvm/base/prefs.h>
#include <gvm/boreas/cli.h>
Include dependency graph for heartbeat.c:

Go to the source code of this file.

Macros

#define G_LOG_DOMAIN   "sd main"
 GLib log domain.

Functions

int check_host_still_alive (kb_t kb, const char *hostname)
 Check if the hosts is still alive and set it as dead if not.

Detailed Description

Function for heartbeat.

Definition in file heartbeat.c.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "sd main"

GLib log domain.

Definition at line 22 of file heartbeat.c.

Function Documentation

◆ check_host_still_alive()

int check_host_still_alive ( kb_t kb,
const char * hostname )

Check if the hosts is still alive and set it as dead if not.

Parameters
kbHost kb where the host is set as dead.
Returns
1 if considered alive, 0 if it is dead. -1 on error or option disabled.

Definition at line 33 of file heartbeat.c.

34{
35 int is_alive = 0;
36 boreas_error_t alive_err;
37
38 /* Heartbeat will work only with boreas enabled. We check if we
39 have all what we need before running a heartbeat check. */
40 if (prefs_get_bool ("test_alive_hosts_only"))
41 {
42 const gchar *alive_test_str = prefs_get ("ALIVE_TEST");
43
44 /* Don't perform a hearbeat check if the host is always considered
45 alive or the alive test is not valid. */
46 if (!(alive_test_str
47 && atoi (alive_test_str) >= ALIVE_TEST_TCP_ACK_SERVICE
48 && atoi (alive_test_str) < 32 // max value for alive test combi.
49 && !((atoi (alive_test_str)) & ALIVE_TEST_CONSIDER_ALIVE)))
50 return -1;
51 }
52 else
53 {
54 g_warning ("%s: Trying to perform an alive test, but Boreas is not "
55 "enabled. Heartbeat check for %s will not be performed",
56 __func__, hostname);
57 return -1;
58 }
59
60 alive_err = is_host_alive (hostname, &is_alive);
61 if (alive_err)
62 {
63 g_warning ("%s: Heartbeat check failed for %s with error %d.", __func__,
64 hostname, alive_err);
65 return -1;
66 }
67
68 if (is_alive == 0)
69 {
70 g_message ("%s: Heartbeat check was not successful. The host %s has"
71 " been set as dead.",
72 __func__, hostname);
73 kb_item_set_int_with_main_kb_check (kb, "Host/dead", 1);
74 return 0;
75 }
76
77 return 1;
78}
const char * hostname
int kb_item_set_int_with_main_kb_check(kb_t kb, const char *name, int value)
Check if the current kb corresponds to the original scanid, if it matches it call kb_item_set_int....
Definition plugutils.c:609

References hostname, and kb_item_set_int_with_main_kb_check().

Referenced by nasl_end_denial(), and update_running_processes().

Here is the call graph for this function:
Here is the caller graph for this function: