macro in cmd line

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dimsum
Posts: 153
Joined: Thu Aug 15, 2013 6:05 pm

macro in cmd line

Post by dimsum »

Hi,

I need to use macro $HOSTDISPLAYNAME$ in the cmd line look like below.
Screen Shot 2564-10-01 at 16.36.41.png
But when I test the command I found $HOSTDISPLAYNAME$ not resolve to real value. Can I work with macro in cmd?
Screen Shot 2564-10-01 at 16.14.01.png
Thanks.
You do not have the required permissions to view the files attached to this post.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: macro in cmd line

Post by gsmith »

Hi

Could you please provide the check_rrdtraf_ruijie.php file?

Thanks
dimsum
Posts: 153
Joined: Thu Aug 15, 2013 6:05 pm

Re: macro in cmd line

Post by dimsum »

Code: Select all

#!/usr/bin/php
<?php

define( "OK",       0);
define( "WARNING",  1);
define( "CRITICAL", 2);
define( "UNKNOWN",  3);


$on_warning = false;
$on_critical = false;

$opciones = getopt("a:A:");


if( isset($opciones['a']) )
    $host_display_name = $opciones['a'];
else if( isset($opciones['A']) )
    $host_display_name = $opciones['A'];

$host_display_name = trim($host_display_name);

if($host_display_name == ""){
    printf("Please fill Host Display Name\n");
    exit(UNKNOWN);
}

printf("OK - ".$host_display_name." Current BW in: 0Mbps Out: .01Mbps|in=0Mb/s;15;20 out=0Mb/s;5;8");

exit(OK);

?>
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: macro in cmd line

Post by benjaminsmith »

Hi,
Thanks for sharing the script. We're are currently working on your issue. We are going to do a bit of research on it and get back to you within 24 hours.

Thanks,
Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: macro in cmd line

Post by gsmith »

Hi

There is no $HOSTDISPLAYNAME$ macro.

Please try using $HOSTNAME$

for example:

gregtest.php file:

Code: Select all

#!/usr/bin/php
<?php

define( "OK",       0);
define( "WARNING",  1);
define( "CRITICAL", 2);
define( "UNKNOWN",  3);


$on_warning = false;
$on_critical = false;
$opciones = getopt("a:A:");

if( isset($opciones['a']) )
    $host_display_name = $opciones['a'];
else if( isset($opciones['A']) )
    $host_display_name = $opciones['A'];

var_dump($host_display_name);
$host_display_name = trim($host_display_name);
printf($host_display_name);

if($host_display_name == ""){
    printf("Please fill Host Display Name\n");
    exit(UNKNOWN);
}

printf("OK - ".$host_display_name." Current BW in: 0Mbps Out: .01Mbps|in=0Mb/s;15;20 out=0Mb/s;5;8");

exit(OK);

?>
command definition:
Image3.jpg
service definition:
Image4.jpg
run command check:
Image5.jpg
Please let me know how you make out.

Thanks
You do not have the required permissions to view the files attached to this post.
Locked