2728N/A * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 252N/A * U.S. Government Rights - Commercial software. Government users are subject 252N/A * to the Sun Microsystems, Inc. standard license agreement and applicable 252N/A * provisions of the FAR and its supplements. 252N/A * This distribution may include materials developed by third parties. Sun, 252N/A * Sun Microsystems, the Sun logo and Solaris are trademarks or registered 252N/A * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. 252N/A * Note: this file originally auto-generated by mib2c using 252N/A/* The following code is borrowed from ps.c */ 252N/A#
define NTTYS 20 /* max ttys that can be specified with the -t option */ 252N/A#
define SIZ 30 /* max processes that can be specified with -p and -g */ 252N/A#
define ARGSIZ 30 /* size of buffer holding args for -t, -p, -u options */ 252N/A#
define MAXLOGIN 8 /* max number of chars in login that will be printed */ 252N/Astatic int maxdev;
/* number of devl structures allocated */ 252N/Astatic char *
procdir =
"/proc";
/* standard /proc directory */ 252N/Astatic int rd_only = 0;
/* flag for remote filesystem read-only */ 252N/A * This function assumes that the password file is hashed 252N/A * (or some such) to allow fast access based on a uid key. 252N/A printf(
"UID PID PPID SZ USR WCHAN TTY CPU CMD \n\n");
252N/A * Locate a particular PID. 252N/A * Return a pointer to the entry or NULL if not found. 252N/A /* Should add a cache here */ 252N/A * Determine root path for remote machine. 252N/A * Determine which processes to print info about by searching 252N/A * the /proc directory and looking at each process. 252N/A /* for each active process --- */ 252N/A * Get the info structure for the process and close quickly. 252N/A /* Read /dev data from psfile. */ 252N/A * call_ftw_for_dev() uses ftw() to pass pathnames under /dev to gdev() 252N/A * along with a status buffer. 252N/A return;
/* successful return, devl populated */ 252N/A * gdev() puts device names and ID into the devl structure for character 252N/A * special files in /dev. The "/dev/" string is stripped from the name 252N/A * and if the resulting pathname exceeds DNSIZE in length then the highest 252N/A * level directory names are stripped until the pathname is DNSIZE or less. 252N/A /* Get more and be ready for syscon & systty. */ 252N/A * Save systty & syscon entries if the console 252N/A * entry hasn't been seen. 252N/A * Put systty & syscon entries in devl when console 252N/A * Make owner root, group sys. 252N/A * gettty returns the user's tty number or ? if none. 252N/Aint *
ip;
/* where the search left off last time */ 252N/A * Special read; unlinks psfile on read error. 252N/A * Special write; unlinks psfile on write error. 252N/A SYSLOG2(
"write_tmp_file() error on write, wbs=%d, bs=%d\n",
252N/A * Return true iff dir is a /proc directory. 252N/A * This works because of the fact that "/proc/0" and "/proc/00" are the 252N/A * same file, namely process 0, and are not linked to each other. Ugly. 252N/A * Make a copy of the directory name without trailing '/'s 252N/A * Append "/0" to the directory path and stat() the file. 252N/A * Append "/00" to the directory path and stat() the file. 252N/A * See if we ended up with the same file. 252N/A * Return TRUE iff we have a regular file with a single link. 252N/A * Initialize the sunProcessTable table by defining its contents and how 252N/A /* create the table structure itself */ 252N/A * if your table is read only, it's easiest to change the 252N/A * HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY 252N/A return;
/* mallocs failed */ 252N/A * Setting up the table's definition 252N/A /* iterator access routines */ 252N/A * registering the table with the master agent 252N/A "Registering table sunProcessTable as a table iterator\n"));
252N/A/* Initializes the sunProcesses module */ 252N/A /* here we initialize all the tables we're planning on supporting */ 252N/A * returns the first data point within the sunProcessTable table data. 252N/A * Set the my_loop_context variable to the first data point structure 252N/A * of your choice (from which you can find the next one). This could 252N/A * be anything from the first node in a linked list, to an integer 252N/A * pointer containing the beginning of an array variable. 252N/A * Set the my_data_context variable to something to be returned to 252N/A * you later that will provide you with the data to return in a given 252N/A * row. * This could be the same pointer as what my_loop_context is 252N/A * set to, or something different. 252N/A * The put_index_data variable contains a list of snmp variable 252N/A * bindings, one for each index in your table. * Set the values of 252N/A * each appropriately according to the data matching the first row 252N/A * and return the put_index_data variable at the end of the function. 252N/A /* vptr = vptr->next_variable; */ 252N/A * functionally the same as sunProcessTable_get_first_data_point, but 252N/A * my_loop_context has already been set to a previous value and should 252N/A * be updated to the next in the list. For example, if it was a 252N/A * linked list, you might want to cast it and the return 252N/A * my_loop_context->next. The my_data_context pointer should be set 252N/A * to something you need later and the indexes in put_index_data 252N/A /* vptr = vptr->next_variable; */ 252N/A * handles requests for the sunProcessTable table, 252N/A * if anything else needs to be done 252N/A /* For caching purposes, find out what the time is now */ 252N/A /* perform anything here that you need to do before each */ 252N/A /* request is processed. */ 252N/A /* the following extracts the my_data_context pointer set in */ 252N/A /* the loop functions above. You can then use the results to */ 252N/A /* help return data for the columns of the sunProcessTable */ 252N/A /* table in question */ 252N/A * XXX: no row existed, if you support creation and this is a 252N/A * set, start dealing with it here, else continue 252N/A /* extracts the information about the table from the request */ 252N/A /* table_info->colnum contains the column number requested */ 252N/A /* table_info->indexes contains a linked list of snmp variable */ 252N/A /* bindings for the indexes of the table. Values in the list */ 252N/A /* have been set corresponding to the indexes of the request */ 252N/A * the table_iterator helper should change all GETNEXTs 252N/A * into GETs for you automatically, so you don't have to 252N/A * worry about the GETNEXT case. Only GETs and SETs need 252N/A * to be dealt with here 252N/A /* We shouldn't get here */ 252N/A"problem encountered in sunProcessTable_handler: unknown column\n");
252N/A/* XXX don't know about 64 bit */ 252N/A "problem encountered in sunProcessTable_handler: unsupported mode\n");