aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_loadavg.c
blob: 2a78bcf41bacc05854e0884f3ae7bee5f2282fec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* $Id: plugin_loadavg.c,v 1.1 2004/01/15 04:29:45 reinelt Exp $
 *
 * plugin for load average
 *
 * Copyright 2003 Michael Reinelt <reinelt@eunet.at>
 * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 *
 * This file is part of LCD4Linux.
 *
 * LCD4Linux 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, or (at your option)
 * any later version.
 *
 * LCD4Linux 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 * $Log: plugin_loadavg.c,v $
 * Revision 1.1  2004/01/15 04:29:45  reinelt
 * moved lcd4linux.conf.sample to *.old
 * lcd4linux.conf.sample with new layout
 * new plugins 'loadavg' and 'meminfo'
 * text widget have pre- and postfix
 *
 */

/* 
 * exported functions:
 *
 * int plugin_init_loadavg (void)
 *  adds functions for load average
 *
 */


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include "debug.h"
#include "plugin.h"


static void my_loadavg (RESULT *result, RESULT *arg1)
{
  int nelem, index;
  double loadavg[3];
  
  nelem=getloadavg(loadavg, 3);
  if (nelem<0) {
    error ("getloadavg() failed!");
    SetResult(&result, R_STRING, "");
    return;
  }

  index=R2N(arg1);
  if (index<1 || index>nelem) {
    error ("loadavg(%d): index out of range!", index);
    SetResult(&result, R_STRING, "");
    return;
  }
  
  SetResult(&result, R_NUMBER, &(loadavg[index-1]));
  return;
  
}


int plugin_init_loadavg (void)
{
  AddFunction ("loadavg", 1, my_loadavg);
  return 0;
}
'>436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
/* config.h.in.  Generated from configure.in by autoheader.  */

/* Define to 1 if the `closedir' function returns void instead of `int'. */
#undef CLOSEDIR_VOID

/* Found some version of curses that we're going to use */
#undef HAS_CURSES

/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H

/* Define to 1 if you have the <asm/io.h> header file. */
#undef HAVE_ASM_IO_H

/* Define to 1 if you have the <asm/types.h> header file. */
#undef HAVE_ASM_TYPES_H

/* Define to 1 if you have the <dbus/dbus.h> header file. */
#undef HAVE_DBUS_DBUS_H

/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
   */
#undef HAVE_DIRENT_H

/* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2

/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H

/* Define to 1 if you have the `floor' function. */
#undef HAVE_FLOOR

/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK

/* Define to 1 if you have the <ftdi.h> header file. */
#undef HAVE_FTDI_H

/* Define to 1 if you have the <gd/gd.h> header file. */
#undef HAVE_GD_GD_H

/* Define to 1 if you have the <gd.h> header file. */
#undef HAVE_GD_H

/* Define to 1 if you have the `gethostbyname' function. */
#undef HAVE_GETHOSTBYNAME

/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY

/* Define if you have the iconv() function and it works. */
#undef HAVE_ICONV

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM

/* Define to 1 if you have the <linux/dvb/frontend.h> header file. */
#undef HAVE_LINUX_DVB_FRONTEND_H

/* Define to 1 if you have the <linux/errno.h> header file. */
#undef HAVE_LINUX_ERRNO_H

/* Define to 1 if you have the <linux/hd44780.h> header file. */
#undef HAVE_LINUX_HD44780_H

/* Define to 1 if you have the <linux/isdn.h> header file. */
#undef HAVE_LINUX_ISDN_H

/* Define to 1 if you have the <linux/lcd-linux.h> header file. */
#undef HAVE_LINUX_LCD_LINUX_H

/* Define to 1 if you have the <linux/parport.h> header file. */
#undef HAVE_LINUX_PARPORT_H

/* Define to 1 if you have the <linux/ppdev.h> header file. */
#undef HAVE_LINUX_PPDEV_H

/* Define to 1 if you have the <linux/wireless.h> header file. */
#undef HAVE_LINUX_WIRELESS_H

/* Define to 1 if you have the <luise.h> header file. */
#undef HAVE_LUISE_H

/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET

/* Define to 1 if you have the <mysql/mysql.h> header file. */
#undef HAVE_MYSQL_MYSQL_H

/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H

/* Define to 1 if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H

/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H

/* Define to 1 if you have the <net/if_ppp.h> header file. */
#undef HAVE_NET_IF_PPP_H

/* Define to 1 if you have the <nmeap.h> header file. */
#undef HAVE_NMEAP_H

/* Define to 1 if you have the `pow' function. */
#undef HAVE_POW

/* Define to 1 if you have the `putenv' function. */
#undef HAVE_PUTENV

/* Define to 1 if you have the `regcomp' function. */
#undef HAVE_REGCOMP

/* Define to 1 if you have the <rfb/rfb.h> header file. */
#undef HAVE_RFB_RFB_H

/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT

/* Define to 1 if you have the <serdisplib/serdisp.h> header file. */
#undef HAVE_SERDISPLIB_SERDISP_H

/* Define to 1 if you have the `socket' function. */
#undef HAVE_SOCKET

/* Define to 1 if you have the <sqlite3.h> header file. */
#undef HAVE_SQLITE3_H

/* Define to 1 if you have the `sqrt' function. */
#undef HAVE_SQRT

/* Define to 1 if you have the <st2205.h> header file. */
#undef HAVE_ST2205_H

/* Define to 1 if `stat' has the bug that it succeeds when given the
   zero-length file name argument. */
#undef HAVE_STAT_EMPTY_STRING_BUG

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H

/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP

/* Define to 1 if you have the `strchr' function. */
#undef HAVE_STRCHR

/* Define to 1 if you have the `strcspn' function. */
#undef HAVE_STRCSPN

/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP

/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR

/* Define to 1 if you have the `strftime' function. */
#undef HAVE_STRFTIME

/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H

/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H

/* Define to 1 if you have the `strncasecmp' function. */
#undef HAVE_STRNCASECMP

/* Define to 1 if you have the `strndup' function. */
#undef HAVE_STRNDUP

/* Define to 1 if you have the `strpbrk' function. */
#undef HAVE_STRPBRK

/* Define to 1 if you have the `strrchr' function. */
#undef HAVE_STRRCHR

/* Define to 1 if you have the `strstr' function. */
#undef HAVE_STRSTR

/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL

/* Define to 1 if you have the `strtoul' function. */
#undef HAVE_STRTOUL

/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H

/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
   */
#undef HAVE_SYS_DIR_H

/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H

/* Define to 1 if you have the <sys/io.h> header file. */
#undef HAVE_SYS_IO_H

/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
   */
#undef HAVE_SYS_NDIR_H

/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H

/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H

/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H

/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H

/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H

/* Define to 1 if you have the <sys/vfs.h> header file. */
#undef HAVE_SYS_VFS_H

/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H

/* Define to 1 if you have the `uname' function. */
#undef HAVE_UNAME

/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

/* Define to 1 if you have the <usb.h> header file. */
#undef HAVE_USB_H

/* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK

/* Define to 1 if you have the <vfork.h> header file. */
#undef HAVE_VFORK_H

/* Define to 1 if `fork' works. */
#undef HAVE_WORKING_FORK

/* Define to 1 if `vfork' works. */
#undef HAVE_WORKING_VFORK

/* Define to 1 if you have the <X11/Xlib.h> header file. */
#undef HAVE_X11_XLIB_H

/* Define to 1 if you have the <X11/Xutil.h> header file. */
#undef HAVE_X11_XUTIL_H

/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST

/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
   slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK

/* Set to reflect version of ncurses */
#undef NCURSES_970530

/* If you Curses does not have color define this one */
#undef NO_COLOR_CURSES

/* Name of package */
#undef PACKAGE

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

/* Define to the full name of this package. */
#undef PACKAGE_NAME

/* Define to the full name and version of this package. */
#undef PACKAGE_STRING

/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME

/* Define to the version of this package. */
#undef PACKAGE_VERSION

/* apm plugin */
#undef PLUGIN_APM

/* asterisk plugin */
#undef PLUGIN_ASTERISK

/* button_exec plugin */
#undef PLUGIN_BUTTON_EXEC

/* cpuinfo plugin */
#undef PLUGIN_CPUINFO

/* diskstats plugin */
#undef PLUGIN_DISKSTATS

/* dvb plugin */
#undef PLUGIN_DVB

/* exec plugin */
#undef PLUGIN_EXEC

/* fifo plugin */
#undef PLUGIN_FIFO

/* file plugin */
#undef PLUGIN_FILE

/* gps plugin */
#undef PLUGIN_GPS

/* hddtemp plugin */
#undef PLUGIN_HDDTEMP

/* i2c sensors plugin */
#undef PLUGIN_I2C_SENSORS

/* iconv charset converter plugin */
#undef PLUGIN_ICONV

/* imon plugin */
#undef PLUGIN_IMON

/* ISDN plugin */
#undef PLUGIN_ISDN

/* kvv plugin */
#undef PLUGIN_KVV

/* loadavg plugin */
#undef PLUGIN_LOADAVG

/* meminfo plugin */
#undef PLUGIN_MEMINFO

/* mpd plugin */
#undef PLUGIN_MPD

/* mpris_dbus plugin */
#undef PLUGIN_MPRIS_DBUS

/* mysql plugin */
#undef PLUGIN_MYSQL

/* netdev plugin */
#undef PLUGIN_NETDEV

/* netinfo plugin */
#undef PLUGIN_NETINFO

/* POP3 plugin */
#undef PLUGIN_POP3

/* ppp plugin */
#undef PLUGIN_PPP

/* proc_stat plugin */
#undef PLUGIN_PROC_STAT

/* python plugin */
#undef PLUGIN_PYTHON

/* qnaplog plugin */
#undef PLUGIN_QNAPLOG

/* sample plugin */
#undef PLUGIN_SAMPLE

/* seti plugin */
#undef PLUGIN_SETI

/* statfs plugin */
#undef PLUGIN_STATFS

/* uname plugin */
#undef PLUGIN_UNAME

/* uptime plugin */
#undef PLUGIN_UPTIME

/* w1retap plugin */
#undef PLUGIN_W1RETAP

/* wireless plugin */
#undef PLUGIN_WIRELESS

/* xmms plugin */
#undef PLUGIN_XMMS

/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE

/* Define if you want to turn on SCO-specific code */
#undef SCO_FLAVOR

/* Define to the type of arg 1 for `select'. */
#undef SELECT_TYPE_ARG1

/* Define to the type of args 2, 3 and 4 for `select'. */
#undef SELECT_TYPE_ARG234

/* Define to the type of arg 5 for `select'. */
#undef SELECT_TYPE_ARG5

/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME

/* Use Ncurses? */
#undef USE_NCURSES

/* Use SunOS SysV curses? */
#undef USE_SUNOS_CURSES

/* Use SystemV curses? */
#undef USE_SYSV_CURSES

/* Version number of package */
#undef VERSION

/* Beckmann&Egle driver */
#undef WITH_BECKMANNEGLE

/* BWCT driver */
#undef WITH_BWCT

/* Crystalfontz driver */
#undef WITH_CRYSTALFONTZ

/* Curses driver */
#undef WITH_CURSES

/* CwLinux driver */
#undef WITH_CWLINUX

/* D4D driver */
#undef WITH_D4D

/* Define if using the dmalloc debugging malloc package */
#undef WITH_DMALLOC

/* Electronic Assembly RS232 graphic driver */
#undef WITH_EA232graphic

/* G-15 driver */
#undef WITH_G15

/* GD library */
#undef WITH_GD

/* GLCD2USB driver */
#undef WITH_GLCD2USB

/* HD44780 driver */
#undef WITH_HD44780

/* I2C bus driver */
#undef WITH_I2C

/* image widget */
#undef WITH_IMAGE

/* IRLCD driver */
#undef WITH_IRLCD

/* LCD2USB driver */
#undef WITH_LCD2USB

/* LCD-Linux driver */
#undef WITH_LCDLINUX

/* LCDTerm driver */
#undef WITH_LCDTERM

/* LEDMatrix driver */
#undef WITH_LEDMATRIX

/* LPH7508 driver */
#undef WITH_LPH7508

/* LUIse driver */
#undef WITH_LUISE

/* M50530 driver */
#undef WITH_M50530

/* MatrixOrbital driver */
#undef WITH_MATRIXORBITAL

/* MatrixOrbitalGX driver */
#undef WITH_MATRIXORBITALGX

/* Milford Instruments driver */
#undef WITH_MILINST

/* Noritake driver */
#undef WITH_NORITAKE

/* NULL driver */
#undef WITH_NULL

/* parport bus driver */
#undef WITH_PARPORT

/* Pertelian driver */
#undef WITH_PERTELIAN

/* PHAnderson driver */
#undef WITH_PHANDERSON

/* picoLCD driver */
#undef WITH_PICOLCD

/* picoLCDGraphic driver */
#undef WITH_PICOLCDGRAPHIC

/* PNG driver */
#undef WITH_PNG

/* PPM driver */
#undef WITH_PPM

/* RouterBoard driver */
#undef WITH_ROUTERBOARD

/* Sample driver */
#undef WITH_SAMPLE

/* serdisplib driver */
#undef WITH_SERDISPLIB

/* serial bus driver */
#undef WITH_SERIAL

/* ShuttleVFD driver */
#undef WITH_SHUTTLEVFD

/* SimpleLCD driver */
#undef WITH_SIMPLELCD

/* st2205 driver */
#undef WITH_ST2205

/* T6963 driver */
#undef WITH_T6963

/* TREFON driver */
#undef WITH_TREFON

/* ULA200 driver */
#undef WITH_ULA200

/* USBHUB driver */
#undef WITH_USBHUB

/* USBLCD driver */
#undef WITH_USBLCD

/* vnc driver */
#undef WITH_VNC

/* WincorNixdorf driver */
#undef WITH_WINCORNIXDORF

/* X11 driver */
#undef WITH_X11

/* Define to 1 if the X Window System is missing or not being used. */
#undef X_DISPLAY_MISSING

/* Define to empty if `const' does not conform to ANSI C. */
#undef const

/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t

/* Define to `__inline__' or `__inline' if that's what the C compiler
   calls it, or to nothing if 'inline' is not supported under any name.  */
#ifndef __cplusplus
#undef inline
#endif

/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t

/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t

/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

/* Define to `int' if <sys/types.h> does not define. */
#undef ssize_t

/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t

/* Define as `fork' if `vfork' does not work. */
#undef vfork