/* ** onstat.c - Server on status. ** ** This program tells you if your server is switched on. A common problem ** is when staff attempt to use a server or desktop when the power is not ** switched on. This may help diagnose such a situation. ** ** 29-Apr-2005, ver 1.00 ** ** COMPILE: ** cc -o onstat onstat.c ** ** INSTALLATION: ** cp onstat /usr/bin ** ** USAGE: ** onstat ** ** SEE ALSO: ** onstat - the Perl version. ** ** COPYRIGHT: Copyright (c) 2005 Nathan Kroenert. ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License ** as published by the Free Software Foundation; either version 2 ** of the License, or (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software Foundation, ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** (http://www.gnu.org/copyleft/gpl.html) ** ** HISTORY: ** 29-Apr-2005 Nathan Kroenert Created this. */ #include #include #include int main(int argc, char **argv) { int a,b,c,d,e; a=5; b=10; c=20; d=40; e=1; /* Here, we test the Add, Divide and Multiply units ** of the Integer Unit. If == 1, we are working and on! */ if ( ((((b / a) * c) - d) + e) == 1) { printf("The system is on\n"); exit(0); } else { printf("The system is off, or malfunctioning!\n"); printf("Shutting down system in 10 seconds!\n"); sleep(10); /* system("/usr/sbin/shutdown -i 5 -g 10"); */ exit(1); } }