Got special request from my sparing. He ask me to add some device ip on our monitoring system. Our working pattern is always like this. If we want to make any testing or anything else. We doing around this time. And test until it done. So far i’m okay and no problem about it.

Okay the flow is, we need to add a group of ip but the device is not support with SNMP. So, the monitoring system is doing ping only to know the status of the device. The ip is start from 1 and end with 250. So… As you i said before that i’m so malas, so i made a simple script. Btw i just google and do some modify at the script to match with my environment.

So the key of the script is “PING”. I need to ping the ip first and know the status, up or down. If the ip is LIVE, so i need to add some line. This command line similar like we add manually the ip into the system but using command line. So i just selit inside the row.

The command line is only support for single ip only and cannot add bulk ip. I found this Ping Script.


  ping -c 1 $1 > /dev/null
  [ $? -eq 0 ] && echo $i,Up
  [ $? -eq 1 ] && echo $i,Down

for i in 10.20.10.{1..250}
is_alive_ping $i & disown

From that script i understand that it do a loop process. Then it will echo the status up or down. I do some tweak after it detect the ip is up. If the ip is up, the script need to execute add ip command. If the ip is down, don’t do anything.

So i add like this.

  [ $? -eq 0 ] && echo $i,Up
  [ $? -eq 0 ] && ./addhost.php -P $i "" "Hardware Name"
  #[ $? -eq 1 ] && echo $i,Down

I just remain the UP status, because i want to know currently which line the process was running. After that i save & execute the script. Then wait until it finish.

Are you lazy like me? Don’t forget to subscribe my Youtube Channel guys.