We've moved to a new support system!

The Nagios Answer Hub is a place where you can get help with technical questions from our experts. There, you can quickly open tickets and join discussion boards.

Request Nagios Answer Hub access here: https://info.nagios.com/answer-hub-access-new-users

After completing the access form, you will be given access to a portal where new tickets can be created. We will keep the old customer forum sections and ticket system available for current cases to be resolved.

Go to the Answer Hub

How to utilise macros "HOSTADDRESS" in my code

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

How to utilise macros "HOSTADDRESS" in my code

Postby dhlao » Mon Jan 03, 2022 10:36 pm

I'm going to create a check command that is written in C. Like those built-in ones that come with Nagios Core, I want to make it able to get the argument such as hostaddress, warning and critical threshold.
I've checked check_ping and check_snmp, then I found that they all rely on an unknown variable "optarg". It's not declared in the codes so I assume it's included in one of those headers (common.h, utils.h, etc.).
The problem is those headers have dependency with the other headers that make it impossible to include all of them.
If I know where and how that "optarg" is declared, I can just simply skip those unnecessary library/header. My problem is, I've no idea where it is.
Posts: 14
Joined: Thu Apr 29, 2021 10:23 am

Re: How to utilise macros "HOSTADDRESS" in my code

Postby mcapra » Tue Jan 04, 2022 11:00 am

I think this is what you're looking for:
https://github.com/nagios-plugins/nagio ... l/getopt.c

But there's a variety of ways to handle command-line arguments in C.
Former Nagios employee
User avatar
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Return to Community Support

Who is online

Users browsing this forum: Google [Bot] and 10 guests