Required Custom Feature

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Required Custom Feature

Post by rlinux57 »

Any option if we can show servers uptime to public using nagios core ?
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: Required Custom Feature

Post by rhassing »

You could use a plugin which monitors the uptime.
I would use snmp to monitor this:

Code: Select all

#!/bin/sh
#
# 2003-01-11, Fredrik Wanglund
#
# This plugin gets the uptime from a host via snmp.
#
# To use the plugn, do the following:
#
# First, create a checkcommand (typically in etc/checkcommands.cfg):
#
# define command {
# command_name                    uptime_by_snmp
# command_line                    /usr/lib/nagios/plugins//uptime_by_snmp $HOSTADDRESS$ $ARG1$
# }
#
  =f your Nagios-plugin is not located in /usr/lib/nagios/plugins//,
# You have to change the path in the command-definition AND the
# variable NAGIOSPLUGSDIR below.
#
# Second, Add a service-definition (typically in etc/services.cfg):
#
# define service {
# host_name                      server
# service_description            Uptime
# check_command                  uptime_by_snmp!public
# use                            generic-service
# normal_check_interval          10
# }
#
# Replace the 'use' statement with whatever template you would like to use,
# or fill up the definition with required parameters if you dont want to
# use any template.
#
# The arguments to the 'check_command' is:
# 1) The command-name, disk_by_snmp
# 2) The SNMP community-string
#
# READY.
#
#
#
# Change this if you have installed NAgios in a non-default place:
NAGIOSPLUGSDIR=/usr/lib/nagios/plugins
UPTIMESDIR=/tmp/uptimes


UPT=`$NAGIOSPLUGSDIR/check_snmp -H $1 -o .1.3.6.1.2.1.1.3.0 -C $2`

RES=$?

if [ $RES = 0 ]; then

        TICKS=`echo $UPT|cut -d "(" -f 2|cut -d ")" -f 1`
        if [ -f $UPTIMESDIR/$1 ]; then
                if [ -s $UPTIMESDIR/$1 ]; then
                        MAXTICKS=`cat $UPTIMESDIR/$1|cut -d ":" -f 2`
                else
                        MAXTICKS=0
                fi
                if [ $TICKS -gt $MAXTICKS ]; then
                        DATE=`date "+%s"`
                        echo "$DATE, $1, $MAXTICKS, $TICKS" >> /tmp/ticks
                        echo "$DATE:$TICKS" > $UPTIMESDIR/$1
                fi
        else
        echo "$1: $TICKS" >> /tmp/ticks
        fi

        RET=`echo $UPT|cut -d ")" -f 2`
else
        RET=$UPT
        RES=1
fi

RET="Uptime: $RET"
echo $RET
exit $RES
Rob Hassing
Image
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Required Custom Feature

Post by tmcdonald »

I think OP is asking how to expose the Core web interface to the public - is this correct, @rlinux57?

If that's the case, you could add in a contact called "public" or "guest" or something similar, and give it the appropriate permissions to suit your needs:

https://assets.nagios.com/downloads/nag ... iauth.html

Then either hand out the credentials, display the information on-screen publicly, or use another frontend to parse out that information and display it.
Former Nagios employee
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Re: Required Custom Feature

Post by rlinux57 »

Yes @tmcdonald, i want to show server's uptime to my clients.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Required Custom Feature

Post by rkennedy »

Does the above solution that @tmcdonald posted work for you? With read only permissions they'll be able to take a look at the system, but not make any changes.
Former Nagios Employee
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Re: Required Custom Feature

Post by rlinux57 »

Somehow, but need your help. After creating user by below command, how can i gave privileges to my clients to access and read only uptime status of several servers. ?

Code: Select all

htpasswd /usr/local/nagios/etc/htpasswd.users <username>
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Required Custom Feature

Post by rkennedy »

You will need to modify /usr/local/nagios/etc/cgi.cfg in order to do this, and modify the following -

Code: Select all

authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
To add a read only user -

Code: Select all

authorized_for_all_services=nagiosadmin,readonlyuser
authorized_for_all_hosts=nagiosadmin,readonlyuser
Former Nagios Employee
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Re: Required Custom Feature

Post by rlinux57 »

Is it possible to define only specific hosts and services for read only users. ?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Required Custom Feature

Post by tgriep »

Take a look at this guide to see if this is what you are looking for.
https://assets.nagios.com/downloads/nag ... iauth.html
If they are setup as a contact for that host / service, then that is all they will see.
Be sure to check out our Knowledgebase for helpful articles and solutions!
rlinux57
Posts: 324
Joined: Mon Dec 08, 2014 12:03 am

Re: Required Custom Feature

Post by rlinux57 »

I have do it but didn't find any suitable option that i want. I just need to show information to client as mentioned in screenshot. please find attachment.
Attachments
nag screenshot.jpg
Locked