How to get the host name of a device into the graph

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
whatz
Posts: 1
Joined: Fri Mar 02, 2012 5:30 pm

How to get the host name of a device into the graph

Post by whatz »

In the tree view on the left multiple levels can be defined to classify information. In the end the final branch the tree shows hosts. Now the hostname here can be free defined by the user and is then used on top of the graphs as a label. Is it possible to add the real device name (queryable via SNMP) of a device to the graph? If yes, can you please share how?

Thank you.
Attachments
cacti_hostname.png
cacti_hostname.png (67.82 KiB) Viewed 1892 times
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: How to get the host name of a device into the graph

Post by noname »

whatz wrote:Is it possible to add the real device name (queryable via SNMP) of a device to the graph?
This is a dirty hack. At your own risk :P

In function form_save() of host.php, change from

Code: Select all

	if ((isset($_POST["save_component_host"])) && (empty($_POST["add_dq_x"]))) {
		if (...) {
			raise_message(4);
		}else{
			$host_id = api_device_save($_POST["id"], $_POST["host_template_id"], $_POST["description"],
				...
to

Code: Select all

	if ((isset($_POST["save_component_host"])) && (empty($_POST["add_dq_x"]))) {
		if (...) {
			raise_message(4);
		}else{
			$snmp_hostname = cacti_snmp_get(
				$_POST["hostname"],
				$_POST["snmp_community"],
				".1.3.6.1.2.1.1.5.0",
				$_POST["snmp_version"],
				$_POST["snmp_username"],
				$_POST["snmp_password"],
				$_POST["snmp_auth_protocol"],
				$_POST["snmp_priv_passphrase"],
				$_POST["snmp_priv_protocol"],
				$_POST["snmp_context"],
				$_POST["snmp_port"],
				$_POST["snmp_timeout"],
				read_config_option("snmp_retries"),
				SNMP_WEBUI);

			if (!empty($snmp_hostname)) {
				$_POST["description"] = $snmp_hostname;
			}

			$host_id = api_device_save($_POST["id"], $_POST["host_template_id"], $_POST["description"],
				...
It forces to overwrite "Description" field by sysName.0 (.1.3.6.1.2.1.1.5.0) when you hit 'Create' or 'Save' button at device settings -- even if you set the field to empty.
(But nothing changed if there is any misconfiguration at SNMP options)

// tested (not fully) on Cacti 0.8.7i
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest