If you want to monitor a specific
Here in above sample we are monitoring port
#linux #monitoring #sysadmin #icinga2 #host #tcp #port
tcp port
on Icinga2
you just need to add another tcp
variable:object Host "host-web" {
import "generic-host-tpl"
address = "YOUR_SERVER_IP_ADDRESS"
vars.os = "Linux"
vars.tcp["OPTIONAL_NAME"]={
tcp_port=8181
}
Here in above sample we are monitoring port
8181
of host-web
which has the IP address of YOUR_SERVER_IP_ADDRESS
(change it to your server ip address remote or local).#linux #monitoring #sysadmin #icinga2 #host #tcp #port
How to monitor network cards on
Ok for now we have added the plugin to nagios folder and ran some tests on target server's network interfaces. We need to add a command to
In brief it creates a new command called
Now we need to use this command in a service. We have to create a new service which will be used in our hosts configuration sections
Again in brief the service will be applied on hosts that have a variable section of
The final part is to add this service to your desired host. Go to
Add the service like below into your host:
You can go even further like me :) and add these data into
#icinga2 #icinga #service #host #command #nagios #interface #network
Icinga2
? (part-2)Ok for now we have added the plugin to nagios folder and ran some tests on target server's network interfaces. We need to add a command to
Icinga2
to use it in service section of Icinga2
. To create a new command create a new file in /etc/icinga2/conf.d/commands/check_nwc_command.conf
and with the following content:object CheckCommand "YOUR_COMMAND_NAME" {
import "plugin-check-command"
command = [ PluginDir + "/check_nwc_health", "--mode", "interface-usage" ]
arguments = {
"-H" = "$address$"
"-C" = "$community$"
"--name" = "$int$"
}
}
In brief it creates a new command called
YOUR_COMMAND_NAME
that calls the script check_nwc_health
with interface-usage
argument to get the bandwidth data.Now we need to use this command in a service. We have to create a new service which will be used in our hosts configuration sections
/etc/icinga2/conf.d/services/if_traffic.conf
:apply Service for (display_name => config in host.vars.int) {
import "generic-service"
check_command = "YOUR_COMMAND_NAME"
vars += config
assign where host.vars.int
}
Again in brief the service will be applied on hosts that have a variable section of
int
in their configuration that we will see a little bit later. YOUR_COMMAND_NAME
is the name that we have given in the first part when creating the command.The final part is to add this service to your desired host. Go to
/etc/icinga2/conf.d/hosts
and open the file which relates to your host. Host files content start with:object Host "host-54 (Infra)" {
Add the service like below into your host:
vars.int["YOUR DISPLAY NAME"] = {
int = "Device 1af4:0001 2"
community = "YOUR SERVER COMMUNITY STRING"
}
int
is the part that we give the interface name, this should be given from the output of list-interfaces
in part-1.You can go even further like me :) and add these data into
Grafana
dashboard to have a better understanding of what is happening around you.#icinga2 #icinga #service #host #command #nagios #interface #network