summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-06 16:04:43 +0200
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-06 16:04:43 +0200
commitaba1ef97f3fdfea191fe8ace2a41551be3dab027 (patch)
treec794f4997b41ae4f48cae44605fd3a94b6e288f3
parentd54588eaf0fc1ec35cfac988dbb2764069fbc909 (diff)
downloadmonitoring-plugins-aba1ef97f3fdfea191fe8ace2a41551be3dab027.tar.gz
Change function type of get_thresholds to better reflect the options and describe it in general
-rw-r--r--plugins-root/check_icmp.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 541e7955..ce88bec7 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -215,7 +215,7 @@ static int wait_for_reply(int, u_int);
215static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, struct timeval*); 215static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, struct timeval*);
216static int send_icmp_ping(int, struct rta_host *); 216static int send_icmp_ping(int, struct rta_host *);
217static int get_threshold(char *str, threshold *th); 217static int get_threshold(char *str, threshold *th);
218static int get_threshold2(char *str, size_t length, threshold *, threshold *, threshold_mode mode); 218static bool get_threshold2(char *str, size_t length, threshold *, threshold *, threshold_mode mode);
219static void run_checks(void); 219static void run_checks(void);
220static void set_source_ip(char *); 220static void set_source_ip(char *);
221static int add_target(char *); 221static int add_target(char *);
@@ -1842,11 +1842,18 @@ get_threshold(char *str, threshold *th)
1842 return 0; 1842 return 0;
1843} 1843}
1844 1844
1845/* not too good at checking errors, but it'll do (main() should barfe on -1) */ 1845/*
1846static int 1846 * This functions receives a pointer to a string which should contain a threshold for the
1847get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, threshold_mode mode) 1847 * rta, packet_loss, jitter, mos or score mode in the form number,number[m|%]* assigns the
1848{ 1848 * parsed number to the corresponding threshold variable.
1849 if (!str || !length || !warn || !crit) return -1; 1849 * @param[in,out] str String containing the given threshold values
1850 * @param[in] length strlen(str)
1851 * @param[out] warn Pointer to the warn threshold struct to which the values should be assigned
1852 * @param[out] crit Pointer to the crit threshold struct to which the values should be assigned
1853 * @param[in] mode Determines whether this a threshold vor rta, packet_loss, jitter, mos or score (exclusively)
1854 */
1855static bool get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, threshold_mode mode) {
1856 if (!str || !length || !warn || !crit) return false;
1850 1857
1851 char *p = NULL; 1858 char *p = NULL;
1852 bool first_iteration = true; 1859 bool first_iteration = true;
@@ -1900,7 +1907,7 @@ get_threshold2(char *str, size_t length, threshold *warn, threshold *crit, thres
1900 warn->score = atof(p); 1907 warn->score = atof(p);
1901 break; 1908 break;
1902 } 1909 }
1903 return 0; 1910 return true;
1904} 1911}
1905 1912
1906unsigned short 1913unsigned short