Ad Widget

Collapse

Item scripted

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cuervo1980
    Junior Member
    • Dec 2008
    • 1

    #1

    Item scripted

    Hello,

    I am trying to save disk space on my server database and I've done an script that returns which users are conected to the monitored server.

    This script is simple, it execute the command w, and if there is someone connected it returns a list of: "[Time]: [IP] [(user)]"; But if no one is in, returns "Nobody".

    My question is, is there a way to make that the server only save in the database the value of the item when it is different from the previous value?

    I've tryed to do that the script returns " " when w returns the same that the previous execution (saved on a local file). In this case, the server do what want, saving only when the item change his value, but the server begin to miss other monitored items, like processor load making to appear blanks spaces in graphs.

    I hope you can help me. Excuse my english...
    Andrés
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    You're going to have to write a wrapper script to the who command.

    Your script will need to store the previous value of the command and then return a difference between the two.

    Here is some pseudocode which might help:
    who > who_old #run this first to preload the script


    the script:
    who > who_current
    diff who_old who_current | tail -n+2 > results
    mv who_current who_old


    You will then see the login changes in the results file. This may not work if you see a lot of people login and logout on a regular basis as it assumes some consistancey of change in the results set.

    Hope that helps.
    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

    Working...