Ad Widget

Collapse

Monitor anything with Zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zaniwoop
    Senior Member
    • Jan 2010
    • 232

    #1

    Monitor anything with Zabbix

    After reading a weblog about monitoring the weather with Zabbix, it got be thinking about what else, besides computers, I can monitor.

    The following will allow you monitor currency exchange rates. Might not be something that many people will use, but the concept is there.

    Add to Server's zabbix_agentd.conf:
    Code:
    UserParameter=currency[*],curl --silent 'http://themoneyconverter.com/$1/rss.xml' | sed -r "s/<title>/\n<title>/g" | grep "$1/$2" | cut -f2 -d"=" | cut -f2 -d" "
    create and item with a key currency[CC1,CC2], where CC1 and CC2 are the 3 letter currency codes that you want to convert.

    example:
    Attached Files
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    Cool! If you have not already you should put this in the Wiki. That's a pretty neat use of Zabbix showing that it's not just about systems monitoring. :-)
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • Zaniwoop
      Senior Member
      • Jan 2010
      • 232

      #3
      Ok, done that.

      Comment

      • alixen
        Senior Member
        • Apr 2006
        • 474

        #4
        Cool !

        I was wondering that it may be interesting to use an external script instead of an agent parameter since exchange rates don't depend on a specific host
        It is also easier to setup (no UserParameter in client).

        Regards,
        Alixen
        http://www.alixen.fr/zabbix.html

        Comment

        • frater
          Senior Member
          • Oct 2010
          • 340

          #5
          Originally posted by alixen
          Cool !

          I was wondering that it may be interesting to use an external script instead of an agent parameter since exchange rates don't depend on a specific host
          It is also easier to setup (no UserParameter in client).

          Regards,
          Alixen
          I think this post was intended to show the power of the agent. The whole exchange-rate is irrelevant (although I'm implementing it now).

          It made it clear how to pass a parameter (EUR GBP) and use only 1 formula.
          Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

          Comment

          • Zaniwoop
            Senior Member
            • Jan 2010
            • 232

            #6
            It was the principle of simplicity and power that I was trying show.

            Running a script would still require that it be run on a server.

            Comment

            • coza2eire
              Junior Member
              • Aug 2009
              • 11

              #7
              Old thread, I know, but having an issues with 16.4 Numbers and Currency monitor

              Hi All,

              I hope that this thread is still being monitored as it is quite dated.
              I have configured a item to monitor currency between ZAR/EUR as a test to see how this cool little monitor works.
              After finding that hte rss feed at "http://themoneyconverter.com" appears to now be different as to when this thread was initially created, I tweaked my item a bit and when running the command from cli, found it to return the correct information. it is returning, in my example item here (ZAR/EUR) 14.35541. when the item runs the userparameter, it was reporting that "Received value [] is not suitable for value type [Numeric (float)]. after some further investigation, I had found what would appear to be a bug in version 2.0. I am currently running 2.2 but tried to manipulate the script/userparameter so as to ONLY collect the first 5 characters in the result retrieved (so as to ensure that if this bug was still around, that this would pin it down to the bug being hte issue).

              unfortuantely, I am still receiving an error stating that data is invalid as shown below:

              Received value [14.35] is not suitable for value type [Numeric (float)]

              My userparamter is as follows:

              UserParameter=currency[*],curl -s 'http://themoneyconverter.com/rss-feed/$2/rss.xml' | grep -A 5 "$1/$2" | cut -f2 -d"=" | cut -f2 -d" " | cut -c1-5

              Bearing in mind that I am only a novice linux user (i.e.), Im sure I have done something wrong here..., I would appreciate any feedback as to what the issue may be. It would seem as though it is not recognising the data as being numerical for some reason...

              thanks in advance

              Comment

              • Zaniwoop
                Senior Member
                • Jan 2010
                • 232

                #8
                The result returned includes several blank lines before and after the value

                Code:
                <blank>
                0.06964
                <blank>
                <blank>
                <blank>
                If you change the -A parameter in the first grep statement from -A 5 to -A 2, it suppresses the last 3 blank lines.

                This may help.

                Comment

                • coza2eire
                  Junior Member
                  • Aug 2009
                  • 11

                  #9
                  Originally posted by Zaniwoop
                  The result returned includes several blank lines before and after the value

                  Code:
                  <blank>
                  0.06964
                  <blank>
                  <blank>
                  <blank>
                  If you change the -A parameter in the first grep statement from -A 5 to -A 2, it suppresses the last 3 blank lines.

                  This may help.
                  thanks for the tip Zaniwoop,
                  I'll give that a go and update with a result.
                  thanks,

                  Comment

                  • coza2eire
                    Junior Member
                    • Aug 2009
                    • 11

                    #10
                    Originally posted by coza2eire
                    thanks for the tip Zaniwoop,
                    I'll give that a go and update with a result.
                    thanks,
                    Hi Zaniwoop,

                    Made that amendment but no luck... still receiving the same error.
                    I had to change the parameter to A 3 as the currency rate is 3 lines below the [$1/$1] variable... but, interestingly enough, when I input the following parameter (i.e.) I don't make use of the $1/$2 variable but rather grep "South African Rand" as this takes me directly to the line containing the currency value,

                    UserParameter=currency[*],curl -s 'http://themoneyconverter.com/rss-feed/$2/rss.xml' | grep "South African Rand" | cut -f2 -d"=" | cut -f2 -d" " | cut -c1-5

                    It works perfectly... so you are right on the money with the line/space issue! I suppose, the only down side is that now this parameter is only really useful for ZAR currency. I will need to try figure out a way of resolving the variable / grep issue to try make use of monitoring multiple currencies more efficiently... I'd better get cracking so!

                    Thanks again Zaniwoop, your help was most definitely appreciated.

                    Comment

                    • Zaniwoop
                      Senior Member
                      • Jan 2010
                      • 232

                      #11
                      I would assume it works for all currencies

                      Comment

                      • aib
                        Senior Member
                        • Jan 2014
                        • 1615

                        #12
                        I'm sorry about that - I like awk
                        And this is my example:
                        Code:
                        UserParameter=currency[*],curl -s http://themoneyconverter.com/rss-feed/$1/rss.xml  | grep -A 2 $2 | grep "description" | awk -F '=' '{printf "%2.2f\n", $$2};'
                        and the output

                        Code:
                        [root@zabbix ~]# curl -s http://themoneyconverter.com/rss-feed/EUR/rss.xml | grep -A 2 ZAR | grep "description"  | awk -F '=' '{printf "%2.2f\n", $$2};'
                        14.24
                        Last edited by aib; 22-07-2014, 21:07.
                        Sincerely yours,
                        Aleksey

                        Comment

                        • esawyja
                          Member
                          Zabbix Certified Specialist
                          • Dec 2011
                          • 54

                          #13
                          I could not get your example with awk to work
                          NinjaGen8:~ # curl -s http://themoneyconverter.com/rss-feed/EUR/rss.xml | grep -A 2 ZAR | grep "description" | awk -F '=' '{printf "%2.2f\n", $$2};'
                          0.00
                          NinjaGen8:~ #

                          but this one works for me
                          NinjaGen8:~ # curl -s http://themoneyconverter.com/rss-feed/EUR/rss.xml | grep -A 2 ZAR | grep "description" | cut -d = -f 2 | cut -d S -f 1
                          14.22850
                          NinjaGen8:~ #

                          Comment

                          Working...