Get servers hostname using Nagios - nagios

I am sure that this must be simple but can not seem to find out how.
I want to display in Nagios the hostname of the host that I have setup. It would be purely information but gives me a way to check that the machine set up in Nagios is called the same as the actual servers hostname.
Thanks

Write your own plugin that would take $HOSTNAME$ and compare it to the local hostname value, returning the appropriate nagios-friendly results.

Related

How to use ansible api(by python) to get Windows host info?

I know how to use ansible to connect to Windows hosts. And I also can get some info by setup module. But now I want to get info through the ansible api. It's not hard to do this if the host is a Linux system, but I don't know how to do that if the host is a Windows system.
ok,I know how to do that.There is a option named connection,this option's default value is 'ssh',you can change it to 'winrm',then you can use the api to manage windows host

pnp4nagios not logging performance data for new host

We've just updated Nagios from 3.5.x to the current version (4.0.7) and subsequently added a new host for monitoring.
The new host shows as 'Down' in Nagios, and this seems to be related to the fact that pnp4nagios is not logging performance data (the individual checks for users, http etc are all find).
Initially there was an error that the directory
/usr/local/pnp4nagios/var/perfdata/newhost.com
that contains the xml setup and rrd files for the new host was missing), so I manually created this directory, but now it complains that the files are missing.
Does anyone know the appropriate steps to overcome this issue?
Thanks,
Toby
PS I'd tag this 'pnp4nagios', but that tag doesn't exist and I can't create them
UPDATE
It's possible that pnp4nagios is a red herring/symptom. Looking more closely I realise that Nagios actually believes the host is down, even though all services are up. The host status information is '(Host check timed out after 30.01 seconds)'...does this make any more sense?
It's indeed very unlikely that pnp4nagios has something to do with your host being down. pnp actually exports output and performance data to feed the rrd database and xml files (via npcd module or evenhandler command).
The fact that nagios reports the host check timed out after 30 sec means that :
- you have a problem with your host check command, please double-check the syntax
- this check command times out after a certain timelapse (most likely defined in nagios.conf) because the plugin was still running.
I'd recommend running this command from the server's prompt. You want to do something like :
/path/to/libexec/check_command -H ipaddress -args
For example:
/usr/local/libexec/nagios/check_ping -H 192.168.1.1 -w 200,40% -c 500,80% -timeout 120
See if something might be hanging. Having the output would be helpful.
Once your host check returns correct output and performance data to nagios, pnp will hopefuly do the rest.
In the unlikely event it helps anyone, pnp4nagios was indeed a red herring. The problem was that ping wasn't enabled for the host being checked, and this is the test for whether a host is up or not. Hence this was failing, despite other services being reported as working.

Enumerate logon sessions remotely

I want to enumerate logon sessions on a remote host (citrix terminal server). What I found so far is LsaEnumerateLogonSessions() / LsaGetLogonSessionData(), but you can't call it remotely.
I read some docs about RPC, but if I understood it right, you need an extra application on the remote host that executes your functions (that's something I want to avoid).
Is there a way to implement such a thing? Maybe with the remote desktop api?
Another solution I found: http://msdn.microsoft.com/en-us/library/windows/desktop/aa370669%28v=vs.85%29.aspx
Other options include the WTS APIs: WTSEnumerateSessionsEx. If you want to be Citrix specific you can also use the XenApp PowerShell SDK.
Use Win32_LogonSession, it is possible to call WMI from a remote computer.

Alternative to gethostbyname where I can choose the DNS server?

I need to resolve some hostnames from my application. Is there any alternative to gethostbyname where I can give as a parameter my own DNS server to use as a resolver?
I have already coded my own function, but I thought there may be one I don't know about.
I am using Linux/C language. My libc is uclibc. But I am also curious about GNU LibC.
Thanks.
You'll need to do your own query, but it isn't difficult.
To do this, you would want to use the res_query() family of functions, which allow you to specify the resolver through an environmental variable:
The res_init() function reads the configuration files (see resolv.conf(5)) to get the default domain name, search order and name server address(es). If no server is given, the local host is tried. If no domain is given, that associated with the local host is used. It can be overridden with the environment variable LOCALDOMAIN
IBM's docs go a little more in depth with how to set the variable:
The configured search list (struct state.defdname and struct state.dnsrch) can be overridden by setting the environment variable LOCALDOMAIN to a space-separated list of up to 6 search domains with a total of 256 characters (including spaces). If a search list is specified, the default local domain is not used on queries.
Notes -
You should call setenv() prior to calling res_init(), or the setting will not be picked up. Remember to unset it once done, if applicable
If you use hostnames for the search domains, /etc/hosts still takes precedence.
res_init() was made properly reentrant in uclibc in 2007, so I'm pretty sure you could just use it for whatever purpose.
These functions have the additional benefit of being able to retrieve more detailed data (MX, etc) as well. Still, if you have something smaller that works equally well, there's no sense in not using it.
You can change the default DNS and use your own DNS server and then set it back to original DNS once you are done with your DNS services in your application.
First query the DNS and save the old DNS.
Set new DNS
Do your DNS services
Set the original back
Basically all the above steps is done by editing /etc/resolv.conf which can done by http://linux.die.net/man/3/resolver command in Linux.

Hosting Multiple Domains on Same Server Port with Apache2

How do I configure Apache2 via webmin or command-line (I'm using RHEL5 Linux) so that I can have multiple domains on the same server on the same port but in different subdirectories?
For instance, trying to get homerentals.ws and homerepair.ws to be detected on port 80 (default port) on the same server. I know that my DNS holds the two addresses and web hits currently go to the same test page. Now all I need is for web hits to go to a subdirectory, but not show this subdirectory. For instance, I do not want people going to http://homerentals.ws and being redirected back to http://homerentals.ws/homerentals/. Instead, http://homerentals.ws would go to /var/www/html/homerentals, while http://homerepair.ws would go to var/www/html/homerepair, but would not look any differently in the URL.
On IIS, I did this once with host-header detection. But I don't know how to do it on RHEL5 Linux via webmin or file editing. I'm stuck.
The feature you're describing is known as virtual hosts. Have a look at Apache's documentation. In general you need to edit /etc/apache2/httpd.conf file to make things happen (maybe it can be edited through webmin, but I'm not familiar with it).

Resources