How to use 'Mobile Phone Number' in custom commands

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
uglystory
Posts: 5
Joined: Fri Mar 21, 2014 2:52 am

How to use 'Mobile Phone Number' in custom commands

Post by uglystory »

Hello,

In reference to my earlier post, there is indeed a way how to use user's mobile phone (or any other information) in your custom commands.
Please see the code below for some ideas.
If you uncomment the lines in the end, you will get all metadata of the specific user.

Regards,
Tamar

Code: Select all

#!/usr/bin/php -q
<?php

require_once('/usr/local/nagiosxi/html/includes/components/componenthelper.inc.php');

if ($argc > 1) {
	print "Username: $argv[1]\n";

	$user_id = get_user_id($argv[1]);
	print "ID: $user_id\n";
	
	$user_name = get_user_meta($user_id, "name");
	print "Name: $user_name\n";

	$user_mobile_number = get_user_meta($user_id, "mobile_number");
	print "Mobile number: $user_mobile_number\n";
}
else {
	print "No username was passed.\n";
	exit(1);
}

//$all_user_meta = get_all_user_meta($user_id);
//var_dump($all_user_meta);

?>
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to use 'Mobile Phone Number' in custom commands

Post by tmcdonald »

Thanks for the post! Looks like you have a good grasp of the concept.
Former Nagios employee
Locked