bplogan Posted August 4, 2008 Share Posted August 4, 2008 I have been assigned a project to create a page that displays the last reboot times of our company servers. All servers are running MS Server 2003. I found a way using ASP.NET but I hate ASP.NET with a passion. Does anyone know of a way to use PHP or javascript to accomplish this? Or does anyone have a different approach? I think I may have to bite the bullet and use ASP, but hopefully someone can suggest something different. Thanks. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/ Share on other sites More sharing options...
bplogan Posted August 4, 2008 Author Share Posted August 4, 2008 Sorry, should have posted this elsewhere...... Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-607044 Share on other sites More sharing options...
trq Posted August 4, 2008 Share Posted August 4, 2008 I'm not a windows user but, It's likely you can use the com interface to interface with the exact same objects used in the .Net examples you have seen. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-607048 Share on other sites More sharing options...
JD* Posted August 4, 2008 Share Posted August 4, 2008 You could parse the log files and find the last occurance of the restart, or see if there is a specific file that is touched when a reboot occurs and use that information (with some PHP command line greps) to get the time and then do some math to figure out the time. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-607159 Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 Orrrr, you could switch to a Linux-based server (because Windows sucks) and just use the uptime command. >_> Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-607164 Share on other sites More sharing options...
JD* Posted August 4, 2008 Share Posted August 4, 2008 Orrrr, you could switch to a Linux-based server (because Windows sucks) and just use the uptime command. >_> As he stated in his post, it's for his company...sometimes we don't have the option to switch. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-607170 Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 The net statistics server command can get you the uptime. You'll need to do some work with the return though to actually get a date. Hint: Use the exec() command. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-607172 Share on other sites More sharing options...
trq Posted August 4, 2008 Share Posted August 4, 2008 Orrrr, you could switch to a Linux-based server (because Windows sucks) and just use the uptime command. >_> Ragging on other OS's definately isn't the prefered method of Linux advocacy. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-607175 Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 I'm not advocating Linux, I'm just saying that Windows does suck. =P In general. Especially for big servers. And I'm sure Windows' feelings aren't hurt. =) Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-607177 Share on other sites More sharing options...
bplogan Posted August 5, 2008 Author Share Posted August 5, 2008 Ya, windows does suck, lol. I wish I could get them to switch.....I can't thank you all enough for the ideas, I will explore them all and get back to you. Again, thanks for geting me started. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608238 Share on other sites More sharing options...
ShaunO Posted August 5, 2008 Share Posted August 5, 2008 Here's a fun one that I just made up now. $lastRebootDate = exec("net statistics workstation | find /i \"Statistics since\""); $lastRebootDate = str_replace("Statistics since ", "", $lastRebootDate); echo $lastRebootDate; Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608253 Share on other sites More sharing options...
cooldude832 Posted August 5, 2008 Share Posted August 5, 2008 I'm not advocating Linux, I'm just saying that Windows does suck. =P In general. Especially for big servers. And I'm sure Windows' feelings aren't hurt. =) Not to start a war here but saying something sucks when its been number 1 for so long is a flat out lie. Windows is designed around being portable and usable by a vast number of users. In doing this is leaves some of us who know more about computers limited in our capabilities to use our hardware to its max. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608256 Share on other sites More sharing options...
trq Posted August 5, 2008 Share Posted August 5, 2008 Windows is designed around being portable Huh? It (windows) runs on two maybe three architectures. Linux runs on like 8-12. In doing this is leaves some of us who know more about computers limited in our capabilities to use our hardware to its max. And I'm sorry, but that makes no sense at all. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608258 Share on other sites More sharing options...
cooldude832 Posted August 5, 2008 Share Posted August 5, 2008 portable meaning it can be used by a beginning computer user all the way up to any one. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608263 Share on other sites More sharing options...
trq Posted August 5, 2008 Share Posted August 5, 2008 portable meaning it can be used by a beginning computer user all the way up to any one. Same could be said about *nix. Its just that alot of people are introduced to computers via windows. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608266 Share on other sites More sharing options...
Jabop Posted August 5, 2008 Share Posted August 5, 2008 efights aren't cool by any means but statistics wise, most php applications are ran from linux boxes. we are on a php forum, not aspx. php is open source, mysql is open source, nix is open source. keep it in the family. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608276 Share on other sites More sharing options...
ShaunO Posted August 5, 2008 Share Posted August 5, 2008 How about you guys just stop bickering about an endless argument and realise the question at hand. How to get the last reboot time on Windows using PHP.. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608290 Share on other sites More sharing options...
trq Posted August 5, 2008 Share Posted August 5, 2008 How about you guys just stop bickering about an endless argument and realise the question at hand. How to get the last reboot time on Windows using PHP.. I believe a few solutions have been posted, and I'll have you know it was a pleasant conversation. I don't see any flamming going on. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608292 Share on other sites More sharing options...
cooldude832 Posted August 5, 2008 Share Posted August 5, 2008 <?php class weapon{ public function pick_weapon($weapon){ $this->weapon = $weapon; } public function fire_weapon($weapon,$target){ echo "You fired your ".$weapon." at ".$target; if(stristr($weapon, "fire")){ echo "<br />and you burned them!"; } } } $weap = new weapon; $weap->pick_weapon("Fire_Lazer"); $weapon->fire_weapon("Fire_Lazer","ShaunO"); $weapon->fire_weapon("Fire_Lazer","Jabop"); ?> Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608345 Share on other sites More sharing options...
trq Posted August 5, 2008 Share Posted August 5, 2008 <?php class weapon{ public function pick_weapon($weapon){ $this->weapon = $weapon; } public function fire_weapon($weapon,$target){ echo "You fired your ".$weapon." at ".$target; if(stristr($weapon, "fire")){ echo "<br />and you burned them!"; } } } $weap = new weapon; $weap->pick_weapon("Flamethrower"); $weapon->fire_weapon("Flamethrower","ShaunO"); $weapon->fire_weapon("Flamethrower","Jabop"); ?> Hehe, its a shame that code would output nothing but errors Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608347 Share on other sites More sharing options...
cooldude832 Posted August 5, 2008 Share Posted August 5, 2008 I just shut down me server for the night so couldn't test it. Note I changed to my fire_lazer from my flamethrower Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608348 Share on other sites More sharing options...
Stooney Posted August 5, 2008 Share Posted August 5, 2008 Not sure if it will help, but a quick command via command prompt in windows is (for xp) systeminfo | find "System Up Time" (for vista) systeminfo | find "System Boot Time" might be able to use shell_exec() or something to get it. Link to comment https://forums.phpfreaks.com/topic/118002-get-the-last-reboot-from-server/#findComment-608370 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.