Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SNMP Polling with PHP

  • 01-04-2010 03:23PM
    #1
    Registered Users, Registered Users 2 Posts: 1,158 ✭✭✭


    You may have seen my previous posts about trying to get php working with snmp, now that i FINALLY figured that out with the help of wiZzard on here I have written a few scripts and have snmp data displaying on a web page.

    I want to know can i poll snmp devices with php, say every five minutes or something?

    Is this possible with php?


Comments

  • Registered Users, Registered Users 2 Posts: 6,762 ✭✭✭WizZard


    Yes you can.

    You will need to write a (php) job script and then schedule it to run however often you need using a job scheduler (*nix: cron, Windows:Task Scheduler)

    Have a look at poller.php from Cacti for some examples


  • Registered Users, Registered Users 2 Posts: 1,158 ✭✭✭mossy464


    Thanks again wizZard. Much appreciated.


  • Registered Users, Registered Users 2 Posts: 1,158 ✭✭✭mossy464


    Also, one other question. I wrote a php script to obtain various snmp data like sysUpTime etc. It returns say timeticks... etc.

    How can i take say just the time itself out of this.

    The same for sysContact. It comes back with STRING : Maurice. How can i get rid of the STRING?

    Sorry now for all the different questions im asking


  • Registered Users, Registered Users 2 Posts: 1,158 ✭✭✭mossy464


    Well I found out I can use str_replace to get rid of the STRING part in the snmp messages.

    Another question, what would be the best way to detect new devices connected to the network?

    I was thinking of writing a php script to ping a range of ip addresses every few minutes and therefore detect any new ip's but this could be pretty messy and would not be the most efficient way of doing it. Any suggestions??


Advertisement